From f588e3f619ebd22aaf05e9c2e4dee5180c0766e0 Mon Sep 17 00:00:00 2001 From: Ellwood Zwovic Date: Fri, 14 Jul 2017 21:15:00 -0700 Subject: [PATCH] Address comments on 2e45bf637aa3 --- bpkg/__init__.py | 6 +++--- bpkg/subproc.py | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bpkg/__init__.py b/bpkg/__init__.py index 52ae47d..490a065 100644 --- a/bpkg/__init__.py +++ b/bpkg/__init__.py @@ -255,7 +255,7 @@ class BPKG_OT_refresh(SubprocMixin, bpy.types.Operator): subproc.SubprocError: self._subproc_error, subproc.DownloadError: self._subproc_download_error, subproc.Success: self._subproc_success, - subproc.Result: self._subproc_result, + subproc.RepositoryResult: self._subproc_repository_result, subproc.Aborted: self._subproc_aborted, } @@ -283,9 +283,9 @@ class BPKG_OT_refresh(SubprocMixin, bpy.types.Operator): self.report({'INFO'}, 'Package list retrieved successfully') self.quit() - def _subproc_result(self, result: subproc.Result): + def _subproc_repository_result(self, result: subproc.RepositoryResult): prefs = bpy.context.user_preferences.addons[__package__].preferences - prefs['repo'] = result.data + prefs['repo'] = result.repository self.report({'INFO'}, 'Package list retrieved successfully') self.quit() diff --git a/bpkg/subproc.py b/bpkg/subproc.py index 4367a8d..cf07d17 100644 --- a/bpkg/subproc.py +++ b/bpkg/subproc.py @@ -66,11 +66,11 @@ class DownloadError(SubprocMessage): class Success(SubprocMessage): """Sent when an operation finished sucessfully.""" -class Result(SubprocMessage): - """Sent when an operation returns data to be used on the parent process.""" +class RepositoryResult(SubprocMessage): + """Sent when an operation returns a repository to be used on the parent process.""" - def __init__(self, data): - self.data = data + def __init__(self, repository: dict): + self.repository = repository class Aborted(SubprocMessage): """Sent as response to Abort message.""" @@ -489,7 +489,10 @@ def refresh(pipe_to_blender, storage_path: pathlib.Path, repository_url: str): return repo.to_file(repo_path) # TODO: this always writes even if repo wasn't changed - pipe_to_blender.send(Result(repo.to_dict(sort=True))) + pipe_to_blender.send(RepositoryResult(repo.to_dict(sort=True))) + +def load(pipe_to_blender, storage_path: pathlib.Path): + """Reads the stored repository""" def debug_hang(): """Hangs for an hour. For testing purposes only."""