{"action":"created","comment":{"url":"https://api.github.com/repos/Kinto/kinto.py/pulls/comments/51111501","id":51111501,"diff_hunk":"@@ -0,0 +1,348 @@\n+# -*- coding: utf-8 -*-\n+from __future__ import absolute_import\n+import argparse\n+import getpass\n+import os\n+from six import iteritems\n+\n+from kinto_client import Client\n+from kinto_client.exceptions import KintoException\n+from kinto_client.logging import logging, global_logger, command_log\n+\n+\n+def is_same_record(fields, one, two):\n+    for key in fields:\n+        if one.get(key) != two.get(key):\n+            return False\n+    return True\n+\n+\n+class KintoImporter(object):\n+    # Default configure parser values\n+    include_all_default_parameters = False\n+    include_remote_server = None\n+    include_authentication = None\n+    include_files = None\n+    include_verbosity = None\n+\n+    # Remote Permissions\n+    bucket_permissions = None\n+    collection_permissions = None\n+\n+    # Default values\n+    default_host = \"http://localhost:8888/v1\"\n+    default_bucket = None\n+    default_collection = None\n+    default_auth = None\n+    default_files = None\n+\n+    # Sync flags\n+    create = True\n+    update = True\n+    delete = True\n+\n+    def __init__(self, logger=None, arguments=None,\n+                 local_client=None, remote_client=None,\n+                 *args, **kwargs):\n+        if not hasattr(self, 'record_fields'):\n+            raise ValueError(\n+                \"%r: record_fields attribute is not defined.\" % self)\n+\n+        self.logger = logger or global_logger\n+\n+        self._local_records = None\n+        self._remote_records = None\n+\n+        parser = self.configure_parser(*args, **kwargs)\n+        self.args = self.get_arguments(parser, args=arguments)\n+        self.setup_logger()\n+        self.local_client = self.setup_local_client(local_client)\n+        self.remote_client = self.setup_remote_client(remote_client)\n+\n+    def configure_parser(self, parser=None,\n+                         include_all_default_parameters=None,\n+                         include_remote_server=None,\n+                         include_authentication=None,\n+                         include_files=None,\n+                         include_verbosity=None,\n+                         *args, **kwargs):\n+        \"\"\"Return an argparse.ArgumentParser pre-configured object.\n+        :param argparse.ArgumentParser parser:\n+            The parser to configure. Set to None it will create a new parser.\n+\n+        :param boolean include_all_default_parameters:\n+            Configure the default for parameters defined below.\n+            It is False by default. I can also be defined as a class attribute.","path":"kinto_client/importer.py","position":75,"original_position":75,"commit_id":"9f975ce8a81dea8daeb6e55585cda5e7424c0d6c","original_commit_id":"9f975ce8a81dea8daeb6e55585cda5e7424c0d6c","user":{"login":"leplatrem","id":546692,"avatar_url":"https://avatars.githubusercontent.com/u/546692?v=3","gravatar_id":"","url":"https://api.github.com/users/leplatrem","html_url":"https://github.com/leplatrem","followers_url":"https://api.github.com/users/leplatrem/followers","following_url":"https://api.github.com/users/leplatrem/following{/other_user}","gists_url":"https://api.github.com/users/leplatrem/gists{/gist_id}","starred_url":"https://api.github.com/users/leplatrem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leplatrem/subscriptions","organizations_url":"https://api.github.com/users/leplatrem/orgs","repos_url":"https://api.github.com/users/leplatrem/repos","events_url":"https://api.github.com/users/leplatrem/events{/privacy}","received_events_url":"https://api.github.com/users/leplatrem/received_events","type":"User","site_admin":false},"body":"I find this a bit overkill. Do we have use-cases where we don't want to allow server host or authentication?","created_at":"2016-01-28T11:37:23Z","updated_at":"2016-01-28T11:37:23Z","html_url":"https://github.com/Kinto/kinto.py/pull/34#discussion_r51111501","pull_request_url":"https://api.github.com/repos/Kinto/kinto.py/pulls/34","_links":{"self":{"href":"https://api.github.com/repos/Kinto/kinto.py/pulls/comments/51111501"},"html":{"href":"https://github.com/Kinto/kinto.py/pull/34#discussion_r51111501"},"pull_request":{"href":"https://api.github.com/repos/Kinto/kinto.py/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/Kinto/kinto.py/pulls/34","id":56352145,"html_url":"https://github.com/Kinto/kinto.py/pull/34","diff_url":"https://github.com/Kinto/kinto.py/pull/34.diff","patch_url":"https://github.com/Kinto/kinto.py/pull/34.patch","issue_url":"https://api.github.com/repos/Kinto/kinto.py/issues/34","number":34,"state":"open","locked":false,"title":"Add CLI utilities to Kinto.py","user":{"login":"Natim","id":229453,"avatar_url":"https://avatars.githubusercontent.com/u/229453?v=3","gravatar_id":"","url":"https://api.github.com/users/Natim","html_url":"https://github.com/Natim","followers_url":"https://api.github.com/users/Natim/followers","following_url":"https://api.github.com/users/Natim/following{/other_user}","gists_url":"https://api.github.com/users/Natim/gists{/gist_id}","starred_url":"https://api.github.com/users/Natim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Natim/subscriptions","organizations_url":"https://api.github.com/users/Natim/orgs","repos_url":"https://api.github.com/users/Natim/repos","events_url":"https://api.github.com/users/Natim/events{/privacy}","received_events_url":"https://api.github.com/users/Natim/received_events","type":"User","site_admin":false},"body":"The final aims is to let people easily create sync between a collection and a local data store (usually built from files)","created_at":"2016-01-18T14:56:58Z","updated_at":"2016-01-28T11:37:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2517ae76dcb848f902d1b41b7350b47a7ee5a405","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Kinto/kinto.py/pulls/34/commits","review_comments_url":"https://api.github.com/repos/Kinto/kinto.py/pulls/34/comments","review_comment_url":"https://api.github.com/repos/Kinto/kinto.py/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Kinto/kinto.py/issues/34/comments","statuses_url":"https://api.github.com/repos/Kinto/kinto.py/statuses/9f975ce8a81dea8daeb6e55585cda5e7424c0d6c","head":{"label":"Kinto:import_cli_utilities","ref":"import_cli_utilities","sha":"9f975ce8a81dea8daeb6e55585cda5e7424c0d6c","user":{"login":"Kinto","id":13413813,"avatar_url":"https://avatars.githubusercontent.com/u/13413813?v=3","gravatar_id":"","url":"https://api.github.com/users/Kinto","html_url":"https://github.com/Kinto","followers_url":"https://api.github.com/users/Kinto/followers","following_url":"https://api.github.com/users/Kinto/following{/other_user}","gists_url":"https://api.github.com/users/Kinto/gists{/gist_id}","starred_url":"https://api.github.com/users/Kinto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kinto/subscriptions","organizations_url":"https://api.github.com/users/Kinto/orgs","repos_url":"https://api.github.com/users/Kinto/repos","events_url":"https://api.github.com/users/Kinto/events{/privacy}","received_events_url":"https://api.github.com/users/Kinto/received_events","type":"Organization","site_admin":false},"repo":{"id":37655419,"name":"kinto.py","full_name":"Kinto/kinto.py","owner":{"login":"Kinto","id":13413813,"avatar_url":"https://avatars.githubusercontent.com/u/13413813?v=3","gravatar_id":"","url":"https://api.github.com/users/Kinto","html_url":"https://github.com/Kinto","followers_url":"https://api.github.com/users/Kinto/followers","following_url":"https://api.github.com/users/Kinto/following{/other_user}","gists_url":"https://api.github.com/users/Kinto/gists{/gist_id}","starred_url":"https://api.github.com/users/Kinto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kinto/subscriptions","organizations_url":"https://api.github.com/users/Kinto/orgs","repos_url":"https://api.github.com/users/Kinto/repos","events_url":"https://api.github.com/users/Kinto/events{/privacy}","received_events_url":"https://api.github.com/users/Kinto/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Kinto/kinto.py","description":"Python library to interact with Kinto","fork":false,"url":"https://api.github.com/repos/Kinto/kinto.py","forks_url":"https://api.github.com/repos/Kinto/kinto.py/forks","keys_url":"https://api.github.com/repos/Kinto/kinto.py/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kinto/kinto.py/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kinto/kinto.py/teams","hooks_url":"https://api.github.com/repos/Kinto/kinto.py/hooks","issue_events_url":"https://api.github.com/repos/Kinto/kinto.py/issues/events{/number}","events_url":"https://api.github.com/repos/Kinto/kinto.py/events","assignees_url":"https://api.github.com/repos/Kinto/kinto.py/assignees{/user}","branches_url":"https://api.github.com/repos/Kinto/kinto.py/branches{/branch}","tags_url":"https://api.github.com/repos/Kinto/kinto.py/tags","blobs_url":"https://api.github.com/repos/Kinto/kinto.py/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kinto/kinto.py/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kinto/kinto.py/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kinto/kinto.py/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kinto/kinto.py/statuses/{sha}","languages_url":"https://api.github.com/repos/Kinto/kinto.py/languages","stargazers_url":"https://api.github.com/repos/Kinto/kinto.py/stargazers","contributors_url":"https://api.github.com/repos/Kinto/kinto.py/contributors","subscribers_url":"https://api.github.com/repos/Kinto/kinto.py/subscribers","subscription_url":"https://api.github.com/repos/Kinto/kinto.py/subscription","commits_url":"https://api.github.com/repos/Kinto/kinto.py/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kinto/kinto.py/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kinto/kinto.py/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kinto/kinto.py/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kinto/kinto.py/contents/{+path}","compare_url":"https://api.github.com/repos/Kinto/kinto.py/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kinto/kinto.py/merges","archive_url":"https://api.github.com/repos/Kinto/kinto.py/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kinto/kinto.py/downloads","issues_url":"https://api.github.com/repos/Kinto/kinto.py/issues{/number}","pulls_url":"https://api.github.com/repos/Kinto/kinto.py/pulls{/number}","milestones_url":"https://api.github.com/repos/Kinto/kinto.py/milestones{/number}","notifications_url":"https://api.github.com/repos/Kinto/kinto.py/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kinto/kinto.py/labels{/name}","releases_url":"https://api.github.com/repos/Kinto/kinto.py/releases{/id}","deployments_url":"https://api.github.com/repos/Kinto/kinto.py/deployments","created_at":"2015-06-18T11:24:34Z","updated_at":"2016-01-27T17:35:06Z","pushed_at":"2016-01-27T17:07:48Z","git_url":"git://github.com/Kinto/kinto.py.git","ssh_url":"git@github.com:Kinto/kinto.py.git","clone_url":"https://github.com/Kinto/kinto.py.git","svn_url":"https://github.com/Kinto/kinto.py","homepage":null,"size":145,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":5,"default_branch":"master"}},"base":{"label":"Kinto:master","ref":"master","sha":"afb6fbbf8c0d14a709d31ce74102dc238a4d4167","user":{"login":"Kinto","id":13413813,"avatar_url":"https://avatars.githubusercontent.com/u/13413813?v=3","gravatar_id":"","url":"https://api.github.com/users/Kinto","html_url":"https://github.com/Kinto","followers_url":"https://api.github.com/users/Kinto/followers","following_url":"https://api.github.com/users/Kinto/following{/other_user}","gists_url":"https://api.github.com/users/Kinto/gists{/gist_id}","starred_url":"https://api.github.com/users/Kinto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kinto/subscriptions","organizations_url":"https://api.github.com/users/Kinto/orgs","repos_url":"https://api.github.com/users/Kinto/repos","events_url":"https://api.github.com/users/Kinto/events{/privacy}","received_events_url":"https://api.github.com/users/Kinto/received_events","type":"Organization","site_admin":false},"repo":{"id":37655419,"name":"kinto.py","full_name":"Kinto/kinto.py","owner":{"login":"Kinto","id":13413813,"avatar_url":"https://avatars.githubusercontent.com/u/13413813?v=3","gravatar_id":"","url":"https://api.github.com/users/Kinto","html_url":"https://github.com/Kinto","followers_url":"https://api.github.com/users/Kinto/followers","following_url":"https://api.github.com/users/Kinto/following{/other_user}","gists_url":"https://api.github.com/users/Kinto/gists{/gist_id}","starred_url":"https://api.github.com/users/Kinto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kinto/subscriptions","organizations_url":"https://api.github.com/users/Kinto/orgs","repos_url":"https://api.github.com/users/Kinto/repos","events_url":"https://api.github.com/users/Kinto/events{/privacy}","received_events_url":"https://api.github.com/users/Kinto/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Kinto/kinto.py","description":"Python library to interact with Kinto","fork":false,"url":"https://api.github.com/repos/Kinto/kinto.py","forks_url":"https://api.github.com/repos/Kinto/kinto.py/forks","keys_url":"https://api.github.com/repos/Kinto/kinto.py/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kinto/kinto.py/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kinto/kinto.py/teams","hooks_url":"https://api.github.com/repos/Kinto/kinto.py/hooks","issue_events_url":"https://api.github.com/repos/Kinto/kinto.py/issues/events{/number}","events_url":"https://api.github.com/repos/Kinto/kinto.py/events","assignees_url":"https://api.github.com/repos/Kinto/kinto.py/assignees{/user}","branches_url":"https://api.github.com/repos/Kinto/kinto.py/branches{/branch}","tags_url":"https://api.github.com/repos/Kinto/kinto.py/tags","blobs_url":"https://api.github.com/repos/Kinto/kinto.py/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kinto/kinto.py/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kinto/kinto.py/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kinto/kinto.py/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kinto/kinto.py/statuses/{sha}","languages_url":"https://api.github.com/repos/Kinto/kinto.py/languages","stargazers_url":"https://api.github.com/repos/Kinto/kinto.py/stargazers","contributors_url":"https://api.github.com/repos/Kinto/kinto.py/contributors","subscribers_url":"https://api.github.com/repos/Kinto/kinto.py/subscribers","subscription_url":"https://api.github.com/repos/Kinto/kinto.py/subscription","commits_url":"https://api.github.com/repos/Kinto/kinto.py/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kinto/kinto.py/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kinto/kinto.py/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kinto/kinto.py/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kinto/kinto.py/contents/{+path}","compare_url":"https://api.github.com/repos/Kinto/kinto.py/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kinto/kinto.py/merges","archive_url":"https://api.github.com/repos/Kinto/kinto.py/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kinto/kinto.py/downloads","issues_url":"https://api.github.com/repos/Kinto/kinto.py/issues{/number}","pulls_url":"https://api.github.com/repos/Kinto/kinto.py/pulls{/number}","milestones_url":"https://api.github.com/repos/Kinto/kinto.py/milestones{/number}","notifications_url":"https://api.github.com/repos/Kinto/kinto.py/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kinto/kinto.py/labels{/name}","releases_url":"https://api.github.com/repos/Kinto/kinto.py/releases{/id}","deployments_url":"https://api.github.com/repos/Kinto/kinto.py/deployments","created_at":"2015-06-18T11:24:34Z","updated_at":"2016-01-27T17:35:06Z","pushed_at":"2016-01-27T17:07:48Z","git_url":"git://github.com/Kinto/kinto.py.git","ssh_url":"git@github.com:Kinto/kinto.py.git","clone_url":"https://github.com/Kinto/kinto.py.git","svn_url":"https://github.com/Kinto/kinto.py","homepage":null,"size":145,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Kinto/kinto.py/pulls/34"},"html":{"href":"https://github.com/Kinto/kinto.py/pull/34"},"issue":{"href":"https://api.github.com/repos/Kinto/kinto.py/issues/34"},"comments":{"href":"https://api.github.com/repos/Kinto/kinto.py/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/Kinto/kinto.py/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/Kinto/kinto.py/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Kinto/kinto.py/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/Kinto/kinto.py/statuses/9f975ce8a81dea8daeb6e55585cda5e7424c0d6c"}}}}