{"action":"created","comment":{"url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/comments/55449125","id":55449125,"diff_hunk":"@@ -1574,6 +1574,308 @@ def download_file_by_id_helper(\n         print('checksum matches')\n \n \n+@six.add_metaclass(ABCMeta)\n+class Action(object):\n+    \"\"\"\n+    An action to take, such as uploading, downloading, or deleting\n+    a file.  Multi-threaded tasks create a sequence of Actions, which\n+    are then run by a pool of threads.\n+\n+    An action can depend on other actions completing.  An example of\n+    this is making sure a CreateBucketAction happens before an\n+    UploadFileAction.\n+    \"\"\"\n+\n+    def __init__(self, prerequisites):\n+        \"\"\"\n+        :param prerequisites: A list of tasks that must be completed\n+         before this one can be run.\n+        \"\"\"\n+        self.prerequisites = prerequisites\n+        self.done = False\n+\n+    def run(self):\n+        for prereq in self.prerequisites:\n+            prereq.wait_until_done()\n+        self.do_action()\n+        self.done = True\n+\n+    def wait_until_done(self):\n+        # TODO: better implementation\n+        while not self.done:\n+            time.sleep(1)\n+\n+    @abstractmethod\n+    def do_action(self):\n+        \"\"\"\n+        Performs the action, returning only after the action is completed.\n+\n+        Will not be called until all prerequisites are satisfied.\n+        \"\"\"\n+\n+\n+class B2UploadAction(Action):\n+    def __init__(self, full_path, file_name, mod_time):\n+        self.full_path = full_path\n+        self.file_name = file_name\n+        self.mod_time = mod_time\n+\n+    def do_action(self):\n+        raise NotImplementedError()\n+\n+    def __str__(self):\n+        return 'b2_upload(%s, %s, %s)' % (self.full_path, self.file_name, self.mod_time)\n+\n+\n+class B2DownloadAction(Action):\n+    def __init__(self, file_name, file_id):\n+        self.file_name = file_name\n+        self.file_id = file_id\n+\n+    def do_action(self):\n+        raise NotImplementedError()\n+\n+    def __str__(self):\n+        return 'b2_download(%s, %s)' % (self.file_name, self.file_id)\n+\n+\n+class B2DeleteAction(Action):\n+    def __init__(self, file_name, file_id):\n+        self.file_name = file_name\n+        self.file_id = file_id\n+\n+    def do_action(self):\n+        raise NotImplementedError()\n+\n+    def __str__(self):\n+        return 'b2_delete(%s, %s)' % (self.file_name, self.file_id)\n+\n+\n+class LocalDeleteAction(Action):\n+    def __init__(self, full_path):\n+        self.full_path = full_path\n+\n+    def do_action(self):\n+        raise NotImplementedError()\n+\n+    def __str__(self):\n+        return 'local_delete(%s)' % (self.full_path)\n+\n+\n+class FileVersion(object):\n+    \"\"\"\n+    Holds information about one version of a file:\n+\n+       id - The B2 file id, or the local full path name\n+       mod_time - modification time, in seconds\n+       action - \"hide\" or \"upload\" (never \"start\")\n+    \"\"\"\n+\n+    def __init__(self, id, mod_time, action):\n+        self.id = id","path":"b2/b2.py","position":102,"original_position":102,"commit_id":"c934666e62e30a76500899eb5ecd6a7b59aeba82","original_commit_id":"c934666e62e30a76500899eb5ecd6a7b59aeba82","user":{"login":"ppolewicz","id":726553,"avatar_url":"https://avatars.githubusercontent.com/u/726553?v=3","gravatar_id":"","url":"https://api.github.com/users/ppolewicz","html_url":"https://github.com/ppolewicz","followers_url":"https://api.github.com/users/ppolewicz/followers","following_url":"https://api.github.com/users/ppolewicz/following{/other_user}","gists_url":"https://api.github.com/users/ppolewicz/gists{/gist_id}","starred_url":"https://api.github.com/users/ppolewicz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppolewicz/subscriptions","organizations_url":"https://api.github.com/users/ppolewicz/orgs","repos_url":"https://api.github.com/users/ppolewicz/repos","events_url":"https://api.github.com/users/ppolewicz/events{/privacy}","received_events_url":"https://api.github.com/users/ppolewicz/received_events","type":"User","site_admin":false},"body":"`id` is a special word in Python. `id_` would be used by convention. ","created_at":"2016-03-08T23:41:32Z","updated_at":"2016-03-08T23:41:32Z","html_url":"https://github.com/Backblaze/B2_Command_Line_Tool/pull/83#discussion_r55449125","pull_request_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/83","_links":{"self":{"href":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/comments/55449125"},"html":{"href":"https://github.com/Backblaze/B2_Command_Line_Tool/pull/83#discussion_r55449125"},"pull_request":{"href":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/83"}}},"pull_request":{"url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/83","id":62142777,"html_url":"https://github.com/Backblaze/B2_Command_Line_Tool/pull/83","diff_url":"https://github.com/Backblaze/B2_Command_Line_Tool/pull/83.diff","patch_url":"https://github.com/Backblaze/B2_Command_Line_Tool/pull/83.patch","issue_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/issues/83","number":83,"state":"open","locked":false,"title":"Initial work on a unit-testable version of the sync command.","user":{"login":"bwbeach","id":603739,"avatar_url":"https://avatars.githubusercontent.com/u/603739?v=3","gravatar_id":"","url":"https://api.github.com/users/bwbeach","html_url":"https://github.com/bwbeach","followers_url":"https://api.github.com/users/bwbeach/followers","following_url":"https://api.github.com/users/bwbeach/following{/other_user}","gists_url":"https://api.github.com/users/bwbeach/gists{/gist_id}","starred_url":"https://api.github.com/users/bwbeach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwbeach/subscriptions","organizations_url":"https://api.github.com/users/bwbeach/orgs","repos_url":"https://api.github.com/users/bwbeach/repos","events_url":"https://api.github.com/users/bwbeach/events{/privacy}","received_events_url":"https://api.github.com/users/bwbeach/received_events","type":"User","site_admin":false},"body":"The new code is not used yet, but I think it's a good time to merge.\r\n\r\nI'm working towards a sync implementation that can be multi-threaded, and that has clean layering so that it's testable.  The work so far includes folder classes (local and B2) that have a common interface, and a `make_sync_folder_sync_actions` function that figures out what needs to happen to get two folders in sync.\r\n","created_at":"2016-03-08T21:52:40Z","updated_at":"2016-03-08T23:41:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7304478f2e3e0923a102ca7d0a1d628f3e824c79","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/83/commits","review_comments_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/83/comments","review_comment_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/issues/83/comments","statuses_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/statuses/c934666e62e30a76500899eb5ecd6a7b59aeba82","head":{"label":"Backblaze:unit_test","ref":"unit_test","sha":"c934666e62e30a76500899eb5ecd6a7b59aeba82","user":{"login":"Backblaze","id":10283486,"avatar_url":"https://avatars.githubusercontent.com/u/10283486?v=3","gravatar_id":"","url":"https://api.github.com/users/Backblaze","html_url":"https://github.com/Backblaze","followers_url":"https://api.github.com/users/Backblaze/followers","following_url":"https://api.github.com/users/Backblaze/following{/other_user}","gists_url":"https://api.github.com/users/Backblaze/gists{/gist_id}","starred_url":"https://api.github.com/users/Backblaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Backblaze/subscriptions","organizations_url":"https://api.github.com/users/Backblaze/orgs","repos_url":"https://api.github.com/users/Backblaze/repos","events_url":"https://api.github.com/users/Backblaze/events{/privacy}","received_events_url":"https://api.github.com/users/Backblaze/received_events","type":"Organization","site_admin":false},"repo":{"id":46293472,"name":"B2_Command_Line_Tool","full_name":"Backblaze/B2_Command_Line_Tool","owner":{"login":"Backblaze","id":10283486,"avatar_url":"https://avatars.githubusercontent.com/u/10283486?v=3","gravatar_id":"","url":"https://api.github.com/users/Backblaze","html_url":"https://github.com/Backblaze","followers_url":"https://api.github.com/users/Backblaze/followers","following_url":"https://api.github.com/users/Backblaze/following{/other_user}","gists_url":"https://api.github.com/users/Backblaze/gists{/gist_id}","starred_url":"https://api.github.com/users/Backblaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Backblaze/subscriptions","organizations_url":"https://api.github.com/users/Backblaze/orgs","repos_url":"https://api.github.com/users/Backblaze/repos","events_url":"https://api.github.com/users/Backblaze/events{/privacy}","received_events_url":"https://api.github.com/users/Backblaze/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Backblaze/B2_Command_Line_Tool","description":"The command-line tool that gives easy access to all of the capabilities of B2 Cloud Storage","fork":false,"url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool","forks_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/forks","keys_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/teams","hooks_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/hooks","issue_events_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/issues/events{/number}","events_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/events","assignees_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/assignees{/user}","branches_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/branches{/branch}","tags_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/tags","blobs_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/git/refs{/sha}","trees_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/statuses/{sha}","languages_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/languages","stargazers_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/stargazers","contributors_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/contributors","subscribers_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/subscribers","subscription_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/subscription","commits_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/commits{/sha}","git_commits_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/git/commits{/sha}","comments_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/comments{/number}","issue_comment_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/issues/comments{/number}","contents_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/contents/{+path}","compare_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/merges","archive_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/downloads","issues_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/issues{/number}","pulls_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls{/number}","milestones_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/milestones{/number}","notifications_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/labels{/name}","releases_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/releases{/id}","deployments_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/deployments","created_at":"2015-11-16T18:22:50Z","updated_at":"2016-03-02T08:05:04Z","pushed_at":"2016-03-08T21:59:22Z","git_url":"git://github.com/Backblaze/B2_Command_Line_Tool.git","ssh_url":"git@github.com:Backblaze/B2_Command_Line_Tool.git","clone_url":"https://github.com/Backblaze/B2_Command_Line_Tool.git","svn_url":"https://github.com/Backblaze/B2_Command_Line_Tool","homepage":null,"size":259,"stargazers_count":92,"watchers_count":92,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":13,"forks":16,"open_issues":13,"watchers":92,"default_branch":"master"}},"base":{"label":"Backblaze:master","ref":"master","sha":"ca6a01c6a2e074f5df635c2eb340dabddfa58e06","user":{"login":"Backblaze","id":10283486,"avatar_url":"https://avatars.githubusercontent.com/u/10283486?v=3","gravatar_id":"","url":"https://api.github.com/users/Backblaze","html_url":"https://github.com/Backblaze","followers_url":"https://api.github.com/users/Backblaze/followers","following_url":"https://api.github.com/users/Backblaze/following{/other_user}","gists_url":"https://api.github.com/users/Backblaze/gists{/gist_id}","starred_url":"https://api.github.com/users/Backblaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Backblaze/subscriptions","organizations_url":"https://api.github.com/users/Backblaze/orgs","repos_url":"https://api.github.com/users/Backblaze/repos","events_url":"https://api.github.com/users/Backblaze/events{/privacy}","received_events_url":"https://api.github.com/users/Backblaze/received_events","type":"Organization","site_admin":false},"repo":{"id":46293472,"name":"B2_Command_Line_Tool","full_name":"Backblaze/B2_Command_Line_Tool","owner":{"login":"Backblaze","id":10283486,"avatar_url":"https://avatars.githubusercontent.com/u/10283486?v=3","gravatar_id":"","url":"https://api.github.com/users/Backblaze","html_url":"https://github.com/Backblaze","followers_url":"https://api.github.com/users/Backblaze/followers","following_url":"https://api.github.com/users/Backblaze/following{/other_user}","gists_url":"https://api.github.com/users/Backblaze/gists{/gist_id}","starred_url":"https://api.github.com/users/Backblaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Backblaze/subscriptions","organizations_url":"https://api.github.com/users/Backblaze/orgs","repos_url":"https://api.github.com/users/Backblaze/repos","events_url":"https://api.github.com/users/Backblaze/events{/privacy}","received_events_url":"https://api.github.com/users/Backblaze/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Backblaze/B2_Command_Line_Tool","description":"The command-line tool that gives easy access to all of the capabilities of B2 Cloud Storage","fork":false,"url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool","forks_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/forks","keys_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/teams","hooks_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/hooks","issue_events_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/issues/events{/number}","events_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/events","assignees_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/assignees{/user}","branches_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/branches{/branch}","tags_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/tags","blobs_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/git/refs{/sha}","trees_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/statuses/{sha}","languages_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/languages","stargazers_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/stargazers","contributors_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/contributors","subscribers_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/subscribers","subscription_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/subscription","commits_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/commits{/sha}","git_commits_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/git/commits{/sha}","comments_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/comments{/number}","issue_comment_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/issues/comments{/number}","contents_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/contents/{+path}","compare_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/merges","archive_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/downloads","issues_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/issues{/number}","pulls_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls{/number}","milestones_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/milestones{/number}","notifications_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/labels{/name}","releases_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/releases{/id}","deployments_url":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/deployments","created_at":"2015-11-16T18:22:50Z","updated_at":"2016-03-02T08:05:04Z","pushed_at":"2016-03-08T21:59:22Z","git_url":"git://github.com/Backblaze/B2_Command_Line_Tool.git","ssh_url":"git@github.com:Backblaze/B2_Command_Line_Tool.git","clone_url":"https://github.com/Backblaze/B2_Command_Line_Tool.git","svn_url":"https://github.com/Backblaze/B2_Command_Line_Tool","homepage":null,"size":259,"stargazers_count":92,"watchers_count":92,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":13,"forks":16,"open_issues":13,"watchers":92,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/83"},"html":{"href":"https://github.com/Backblaze/B2_Command_Line_Tool/pull/83"},"issue":{"href":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/issues/83"},"comments":{"href":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/issues/83/comments"},"review_comments":{"href":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/83/comments"},"review_comment":{"href":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/pulls/83/commits"},"statuses":{"href":"https://api.github.com/repos/Backblaze/B2_Command_Line_Tool/statuses/c934666e62e30a76500899eb5ecd6a7b59aeba82"}}}}