{"action":"created","comment":{"url":"https://api.github.com/repos/dean/timesync-cli-python/pulls/comments/31882506","id":31882506,"diff_hunk":"@@ -99,7 +103,27 @@ def parse_all_args():\n     return parser.parse_args()\n \n \n+def read_config():\n+    \"\"\"Returns a dictionary representing the contents of the json file\n+    $HOME/timesyncconf.json or a set of sensible defaults if that file does\n+    not exist.\n+    \"\"\"\n+    sensible_defaults = {\n+        'url': 'http://localhost:3000',\n+        'editor': 'vi',\n+    }\n+    # If $HOME isn't root base_path should be root.\n+    base_path = os.environ.get('HOME') or '/'\n+    path ='{}/.timesyncconf.json'.format(base_path)\n+    if os.path.isfile(path):\n+        with open(path) as f:\n+            contents = json.load(f)\n+            return sensible_defaults.update(contents)\n+    else:\n+        return sensible_defaults\n+\n if __name__ == '__main__':\n+    config = read_config()\n     args = parse_all_args()","path":"timesync","position":85,"original_position":85,"commit_id":"02fd2c04316006112361ce841c3b82bcbb5d3e3b","original_commit_id":"02fd2c04316006112361ce841c3b82bcbb5d3e3b","user":{"login":"dean","id":1235347,"avatar_url":"https://avatars.githubusercontent.com/u/1235347?v=3","gravatar_id":"","url":"https://api.github.com/users/dean","html_url":"https://github.com/dean","followers_url":"https://api.github.com/users/dean/followers","following_url":"https://api.github.com/users/dean/following{/other_user}","gists_url":"https://api.github.com/users/dean/gists{/gist_id}","starred_url":"https://api.github.com/users/dean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dean/subscriptions","organizations_url":"https://api.github.com/users/dean/orgs","repos_url":"https://api.github.com/users/dean/repos","events_url":"https://api.github.com/users/dean/events{/privacy}","received_events_url":"https://api.github.com/users/dean/received_events","type":"User","site_admin":false},"body":"Pass in the config to parse_all_args too (makes sense for defaults, right?), or make it global.","created_at":"2015-06-08T00:04:55Z","updated_at":"2015-06-08T00:04:55Z","html_url":"https://github.com/dean/timesync-cli-python/pull/2#discussion_r31882506","pull_request_url":"https://api.github.com/repos/dean/timesync-cli-python/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/dean/timesync-cli-python/pulls/comments/31882506"},"html":{"href":"https://github.com/dean/timesync-cli-python/pull/2#discussion_r31882506"},"pull_request":{"href":"https://api.github.com/repos/dean/timesync-cli-python/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/dean/timesync-cli-python/pulls/2","id":34332800,"html_url":"https://github.com/dean/timesync-cli-python/pull/2","diff_url":"https://github.com/dean/timesync-cli-python/pull/2.diff","patch_url":"https://github.com/dean/timesync-cli-python/pull/2.patch","issue_url":"https://api.github.com/repos/dean/timesync-cli-python/issues/2","number":2,"state":"open","locked":false,"title":"Get default configuration such as url from file","user":{"login":"iankronquist","id":5192353,"avatar_url":"https://avatars.githubusercontent.com/u/5192353?v=3","gravatar_id":"","url":"https://api.github.com/users/iankronquist","html_url":"https://github.com/iankronquist","followers_url":"https://api.github.com/users/iankronquist/followers","following_url":"https://api.github.com/users/iankronquist/following{/other_user}","gists_url":"https://api.github.com/users/iankronquist/gists{/gist_id}","starred_url":"https://api.github.com/users/iankronquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iankronquist/subscriptions","organizations_url":"https://api.github.com/users/iankronquist/orgs","repos_url":"https://api.github.com/users/iankronquist/repos","events_url":"https://api.github.com/users/iankronquist/events{/privacy}","received_events_url":"https://api.github.com/users/iankronquist/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-29T04:26:52Z","updated_at":"2015-06-08T00:04:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7283499749a043b282a049eb264844e6af897466","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dean/timesync-cli-python/pulls/2/commits","review_comments_url":"https://api.github.com/repos/dean/timesync-cli-python/pulls/2/comments","review_comment_url":"https://api.github.com/repos/dean/timesync-cli-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dean/timesync-cli-python/issues/2/comments","statuses_url":"https://api.github.com/repos/dean/timesync-cli-python/statuses/02fd2c04316006112361ce841c3b82bcbb5d3e3b","head":{"label":"iankronquist:config_file","ref":"config_file","sha":"02fd2c04316006112361ce841c3b82bcbb5d3e3b","user":{"login":"iankronquist","id":5192353,"avatar_url":"https://avatars.githubusercontent.com/u/5192353?v=3","gravatar_id":"","url":"https://api.github.com/users/iankronquist","html_url":"https://github.com/iankronquist","followers_url":"https://api.github.com/users/iankronquist/followers","following_url":"https://api.github.com/users/iankronquist/following{/other_user}","gists_url":"https://api.github.com/users/iankronquist/gists{/gist_id}","starred_url":"https://api.github.com/users/iankronquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iankronquist/subscriptions","organizations_url":"https://api.github.com/users/iankronquist/orgs","repos_url":"https://api.github.com/users/iankronquist/repos","events_url":"https://api.github.com/users/iankronquist/events{/privacy}","received_events_url":"https://api.github.com/users/iankronquist/received_events","type":"User","site_admin":false},"repo":{"id":34772304,"name":"timesync-cli-python","full_name":"iankronquist/timesync-cli-python","owner":{"login":"iankronquist","id":5192353,"avatar_url":"https://avatars.githubusercontent.com/u/5192353?v=3","gravatar_id":"","url":"https://api.github.com/users/iankronquist","html_url":"https://github.com/iankronquist","followers_url":"https://api.github.com/users/iankronquist/followers","following_url":"https://api.github.com/users/iankronquist/following{/other_user}","gists_url":"https://api.github.com/users/iankronquist/gists{/gist_id}","starred_url":"https://api.github.com/users/iankronquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iankronquist/subscriptions","organizations_url":"https://api.github.com/users/iankronquist/orgs","repos_url":"https://api.github.com/users/iankronquist/repos","events_url":"https://api.github.com/users/iankronquist/events{/privacy}","received_events_url":"https://api.github.com/users/iankronquist/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iankronquist/timesync-cli-python","description":"Timesync CLI","fork":true,"url":"https://api.github.com/repos/iankronquist/timesync-cli-python","forks_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/forks","keys_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/teams","hooks_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/hooks","issue_events_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/issues/events{/number}","events_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/events","assignees_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/assignees{/user}","branches_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/branches{/branch}","tags_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/tags","blobs_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/statuses/{sha}","languages_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/languages","stargazers_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/stargazers","contributors_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/contributors","subscribers_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/subscribers","subscription_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/subscription","commits_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/contents/{+path}","compare_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/merges","archive_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/downloads","issues_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/issues{/number}","pulls_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/pulls{/number}","milestones_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/milestones{/number}","notifications_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/labels{/name}","releases_url":"https://api.github.com/repos/iankronquist/timesync-cli-python/releases{/id}","created_at":"2015-04-29T04:26:11Z","updated_at":"2015-04-29T04:26:11Z","pushed_at":"2015-04-29T05:08:34Z","git_url":"git://github.com/iankronquist/timesync-cli-python.git","ssh_url":"git@github.com:iankronquist/timesync-cli-python.git","clone_url":"https://github.com/iankronquist/timesync-cli-python.git","svn_url":"https://github.com/iankronquist/timesync-cli-python","homepage":"","size":90,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dean:master","ref":"master","sha":"4e05b158904c7bcb56f63d04ac4e162acaee6fd6","user":{"login":"dean","id":1235347,"avatar_url":"https://avatars.githubusercontent.com/u/1235347?v=3","gravatar_id":"","url":"https://api.github.com/users/dean","html_url":"https://github.com/dean","followers_url":"https://api.github.com/users/dean/followers","following_url":"https://api.github.com/users/dean/following{/other_user}","gists_url":"https://api.github.com/users/dean/gists{/gist_id}","starred_url":"https://api.github.com/users/dean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dean/subscriptions","organizations_url":"https://api.github.com/users/dean/orgs","repos_url":"https://api.github.com/users/dean/repos","events_url":"https://api.github.com/users/dean/events{/privacy}","received_events_url":"https://api.github.com/users/dean/received_events","type":"User","site_admin":false},"repo":{"id":34691928,"name":"timesync-cli-python","full_name":"dean/timesync-cli-python","owner":{"login":"dean","id":1235347,"avatar_url":"https://avatars.githubusercontent.com/u/1235347?v=3","gravatar_id":"","url":"https://api.github.com/users/dean","html_url":"https://github.com/dean","followers_url":"https://api.github.com/users/dean/followers","following_url":"https://api.github.com/users/dean/following{/other_user}","gists_url":"https://api.github.com/users/dean/gists{/gist_id}","starred_url":"https://api.github.com/users/dean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dean/subscriptions","organizations_url":"https://api.github.com/users/dean/orgs","repos_url":"https://api.github.com/users/dean/repos","events_url":"https://api.github.com/users/dean/events{/privacy}","received_events_url":"https://api.github.com/users/dean/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dean/timesync-cli-python","description":"Timesync CLI","fork":false,"url":"https://api.github.com/repos/dean/timesync-cli-python","forks_url":"https://api.github.com/repos/dean/timesync-cli-python/forks","keys_url":"https://api.github.com/repos/dean/timesync-cli-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dean/timesync-cli-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dean/timesync-cli-python/teams","hooks_url":"https://api.github.com/repos/dean/timesync-cli-python/hooks","issue_events_url":"https://api.github.com/repos/dean/timesync-cli-python/issues/events{/number}","events_url":"https://api.github.com/repos/dean/timesync-cli-python/events","assignees_url":"https://api.github.com/repos/dean/timesync-cli-python/assignees{/user}","branches_url":"https://api.github.com/repos/dean/timesync-cli-python/branches{/branch}","tags_url":"https://api.github.com/repos/dean/timesync-cli-python/tags","blobs_url":"https://api.github.com/repos/dean/timesync-cli-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dean/timesync-cli-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dean/timesync-cli-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/dean/timesync-cli-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dean/timesync-cli-python/statuses/{sha}","languages_url":"https://api.github.com/repos/dean/timesync-cli-python/languages","stargazers_url":"https://api.github.com/repos/dean/timesync-cli-python/stargazers","contributors_url":"https://api.github.com/repos/dean/timesync-cli-python/contributors","subscribers_url":"https://api.github.com/repos/dean/timesync-cli-python/subscribers","subscription_url":"https://api.github.com/repos/dean/timesync-cli-python/subscription","commits_url":"https://api.github.com/repos/dean/timesync-cli-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/dean/timesync-cli-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/dean/timesync-cli-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/dean/timesync-cli-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/dean/timesync-cli-python/contents/{+path}","compare_url":"https://api.github.com/repos/dean/timesync-cli-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dean/timesync-cli-python/merges","archive_url":"https://api.github.com/repos/dean/timesync-cli-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dean/timesync-cli-python/downloads","issues_url":"https://api.github.com/repos/dean/timesync-cli-python/issues{/number}","pulls_url":"https://api.github.com/repos/dean/timesync-cli-python/pulls{/number}","milestones_url":"https://api.github.com/repos/dean/timesync-cli-python/milestones{/number}","notifications_url":"https://api.github.com/repos/dean/timesync-cli-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dean/timesync-cli-python/labels{/name}","releases_url":"https://api.github.com/repos/dean/timesync-cli-python/releases{/id}","created_at":"2015-04-27T21:21:00Z","updated_at":"2015-04-28T22:29:18Z","pushed_at":"2015-04-29T04:26:52Z","git_url":"git://github.com/dean/timesync-cli-python.git","ssh_url":"git@github.com:dean/timesync-cli-python.git","clone_url":"https://github.com/dean/timesync-cli-python.git","svn_url":"https://github.com/dean/timesync-cli-python","homepage":"","size":169,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dean/timesync-cli-python/pulls/2"},"html":{"href":"https://github.com/dean/timesync-cli-python/pull/2"},"issue":{"href":"https://api.github.com/repos/dean/timesync-cli-python/issues/2"},"comments":{"href":"https://api.github.com/repos/dean/timesync-cli-python/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/dean/timesync-cli-python/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/dean/timesync-cli-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dean/timesync-cli-python/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/dean/timesync-cli-python/statuses/02fd2c04316006112361ce841c3b82bcbb5d3e3b"}}}}