{"action":"created","comment":{"url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments/31355251","id":31355251,"diff_hunk":"@@ -7,56 +7,76 @@\n import dateutil.parser\n \n def posts_at_url(url):\n-    \n+\n     current_page = 1\n     max_page = sys.maxint\n \n     while current_page <= max_page:\n \n         url = os.path.expandvars(url)\n-        resp = requests.get(url, params={'page':current_page})\n-        results = json.loads(resp.content) \n+        resp = requests.get(url, params={\"page\": current_page})\n+        results = json.loads(resp.content)\n         current_page += 1\n-        max_page = results['pages']\n+        max_page = results[\"pages\"]\n         total = 0\n-        for p in results['posts']:\n+        for p in results[\"posts\"]:\n             total += 1\n             yield p\n \n def documents(name, url, **kwargs):\n-    \n+\n     for post in posts_at_url(url):\n         yield process_contact(post)\n \n-def convert_custom_field(post_type, attribute, index=0, new_attribute=None):\n-    # Check to make sure the index is in range for the list\n-    if attribute in post_type['custom_fields'] and \\\n-        len(post_type['custom_fields'][attribute]) >= (index + 1):\n-        if new_attribute is None:\n-            post_type[attribute] = post_type['custom_fields'][attribute][index]\n+def process_contact(contact):\n+    del contact[\"comments\"]\n+    contact[\"_id\"] = contact[\"slug\"]\n+\n+    names = [\"email\", \"phone\", \"fax\"]\n+    for name in names:\n+        if name in contact[\"custom_fields\"] and contact[\"custom_fields\"][name]:\n+            contact[name] = contact[\"custom_fields\"][name]\n         else:\n-            post_type[new_attribute] = post_type['custom_fields'][attribute][index]\n+            if name is \"fax\":\n+                contact[name] = {}\n+                if \"fax_num\" in contact[\"custom_fields\"]:\n+                    contact[name][\"num\"] = \\\n+                        contact[\"custom_fields\"][\"fax_num\"]\n+                if \"fax_desc\" in contact[\"custom_fields\"]:\n+                    contact[name][\"desc\"] = \\\n+                        contact[\"custom_fields\"][\"fax_desc\"]\n+            else:\n+                contact[name] = []\n+                for i in range(3):\n+                    contact[name].append({})\n+                    if \"%s_%s_addr\" % (name, i) in contact[\"custom_fields\"]:\n+                        contact[name][i][\"addr\"] = \\\n+                            contact[\"custom_fields\"][\"%s_%s_addr\" % (name, i)]\n+                    elif \"%s_%s_num\" % (name, i) in contact[\"custom_fields\"]:\n+                        contact[name][i][\"num\"] = \\\n+                            contact[\"custom_fields\"][\"%s_%s_num\" % (name, i)]\n+                    if \"%s_%s_desc\" % (name, i) in contact[\"custom_fields\"]:\n+                        contact[name][i][\"desc\"] = \\\n+                            contact[\"custom_fields\"][\"%s_%s_desc\" % (name, i)]\n+    names = [\"sitewide_desc\", \"attn\", \"street\", \"city\", \"state\", \"zip_code\",\n+             \"addr_desc\"]\n+    for name in names:\n+        if name in contact[\"custom_fields\"] and contact[\"custom_fields\"][name]:","path":"_lib/wordpress_contact_processor.py","position":71,"original_position":71,"commit_id":"08bc1d5dcf01d44b82b98598270e9ecc623e90fd","original_commit_id":"08bc1d5dcf01d44b82b98598270e9ecc623e90fd","user":{"login":"Scotchester","id":1044670,"avatar_url":"https://avatars.githubusercontent.com/u/1044670?v=3","gravatar_id":"","url":"https://api.github.com/users/Scotchester","html_url":"https://github.com/Scotchester","followers_url":"https://api.github.com/users/Scotchester/followers","following_url":"https://api.github.com/users/Scotchester/following{/other_user}","gists_url":"https://api.github.com/users/Scotchester/gists{/gist_id}","starred_url":"https://api.github.com/users/Scotchester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Scotchester/subscriptions","organizations_url":"https://api.github.com/users/Scotchester/orgs","repos_url":"https://api.github.com/users/Scotchester/repos","events_url":"https://api.github.com/users/Scotchester/events{/privacy}","received_events_url":"https://api.github.com/users/Scotchester/received_events","type":"User","site_admin":false},"body":"Can't it be shortened to simply `if name in contact[\"custom_fields\"]:` ?","created_at":"2015-05-29T19:07:43Z","updated_at":"2015-05-29T19:07:43Z","html_url":"https://github.com/cfpb/cfgov-refresh/pull/604#discussion_r31355251","pull_request_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604","_links":{"self":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments/31355251"},"html":{"href":"https://github.com/cfpb/cfgov-refresh/pull/604#discussion_r31355251"},"pull_request":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604"}}},"pull_request":{"url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604","id":36522980,"html_url":"https://github.com/cfpb/cfgov-refresh/pull/604","diff_url":"https://github.com/cfpb/cfgov-refresh/pull/604.diff","patch_url":"https://github.com/cfpb/cfgov-refresh/pull/604.patch","issue_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/604","number":604,"state":"open","locked":false,"title":"Refactor sheer processors and templates for cms-toolkit/wp-flapjack upgrade","user":{"login":"kurtw","id":1412978,"avatar_url":"https://avatars.githubusercontent.com/u/1412978?v=3","gravatar_id":"","url":"https://api.github.com/users/kurtw","html_url":"https://github.com/kurtw","followers_url":"https://api.github.com/users/kurtw/followers","following_url":"https://api.github.com/users/kurtw/following{/other_user}","gists_url":"https://api.github.com/users/kurtw/gists{/gist_id}","starred_url":"https://api.github.com/users/kurtw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kurtw/subscriptions","organizations_url":"https://api.github.com/users/kurtw/orgs","repos_url":"https://api.github.com/users/kurtw/repos","events_url":"https://api.github.com/users/kurtw/events{/privacy}","received_events_url":"https://api.github.com/users/kurtw/received_events","type":"User","site_admin":false},"body":"This is mostly a refactor with some formatting kicked in as well. New [cms-toolkit](https://github.com/cfpb/cms-toolkit/pull/60) and [wp-flapjack](https://github.cfpb.gov/flapjack/wp-flapjack/pull/49) code is waiting to be merged. Once it is merged, sheer processors will have to accommodate the new format the meta-data is saved in, while maintaining the ability of indexing the older format. **Note**: Event has not been modified.\r\n\r\n### Additions\r\n- Broke out some types that were handled in a single processor into multiple\r\n\r\n### Changes\r\n- Name of Initiatives is now Sub-pages so the folders and files reflect that as well as the code\r\n\r\n### Testing\r\nComplete testing means indexing older content and also indexing newer content. Newer content should be created locally by pulling down the two repo's linked above, ([and this one](https://github.com/cfpb/wp-json-api/pull/5)) and creating posts on your Unitybox's Wordpress, then indexing from that. \r\n\r\nAfter properly indexing, you could also serve the site and double check the content is there.\r\n\r\n### Review\r\n@dpford\r\n\r\n ","created_at":"2015-05-29T16:38:41Z","updated_at":"2015-05-29T19:07:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a34860ec6326d822a2bf86524ea7258dee4a74e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604/commits","review_comments_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604/comments","review_comment_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/604/comments","statuses_url":"https://api.github.com/repos/cfpb/cfgov-refresh/statuses/08bc1d5dcf01d44b82b98598270e9ecc623e90fd","head":{"label":"kurtw:DF-1850","ref":"DF-1850","sha":"08bc1d5dcf01d44b82b98598270e9ecc623e90fd","user":{"login":"kurtw","id":1412978,"avatar_url":"https://avatars.githubusercontent.com/u/1412978?v=3","gravatar_id":"","url":"https://api.github.com/users/kurtw","html_url":"https://github.com/kurtw","followers_url":"https://api.github.com/users/kurtw/followers","following_url":"https://api.github.com/users/kurtw/following{/other_user}","gists_url":"https://api.github.com/users/kurtw/gists{/gist_id}","starred_url":"https://api.github.com/users/kurtw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kurtw/subscriptions","organizations_url":"https://api.github.com/users/kurtw/orgs","repos_url":"https://api.github.com/users/kurtw/repos","events_url":"https://api.github.com/users/kurtw/events{/privacy}","received_events_url":"https://api.github.com/users/kurtw/received_events","type":"User","site_admin":false},"repo":{"id":26283151,"name":"cfgov-refresh","full_name":"kurtw/cfgov-refresh","owner":{"login":"kurtw","id":1412978,"avatar_url":"https://avatars.githubusercontent.com/u/1412978?v=3","gravatar_id":"","url":"https://api.github.com/users/kurtw","html_url":"https://github.com/kurtw","followers_url":"https://api.github.com/users/kurtw/followers","following_url":"https://api.github.com/users/kurtw/following{/other_user}","gists_url":"https://api.github.com/users/kurtw/gists{/gist_id}","starred_url":"https://api.github.com/users/kurtw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kurtw/subscriptions","organizations_url":"https://api.github.com/users/kurtw/orgs","repos_url":"https://api.github.com/users/kurtw/repos","events_url":"https://api.github.com/users/kurtw/events{/privacy}","received_events_url":"https://api.github.com/users/kurtw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kurtw/cfgov-refresh","description":"","fork":true,"url":"https://api.github.com/repos/kurtw/cfgov-refresh","forks_url":"https://api.github.com/repos/kurtw/cfgov-refresh/forks","keys_url":"https://api.github.com/repos/kurtw/cfgov-refresh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kurtw/cfgov-refresh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kurtw/cfgov-refresh/teams","hooks_url":"https://api.github.com/repos/kurtw/cfgov-refresh/hooks","issue_events_url":"https://api.github.com/repos/kurtw/cfgov-refresh/issues/events{/number}","events_url":"https://api.github.com/repos/kurtw/cfgov-refresh/events","assignees_url":"https://api.github.com/repos/kurtw/cfgov-refresh/assignees{/user}","branches_url":"https://api.github.com/repos/kurtw/cfgov-refresh/branches{/branch}","tags_url":"https://api.github.com/repos/kurtw/cfgov-refresh/tags","blobs_url":"https://api.github.com/repos/kurtw/cfgov-refresh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kurtw/cfgov-refresh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kurtw/cfgov-refresh/git/refs{/sha}","trees_url":"https://api.github.com/repos/kurtw/cfgov-refresh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kurtw/cfgov-refresh/statuses/{sha}","languages_url":"https://api.github.com/repos/kurtw/cfgov-refresh/languages","stargazers_url":"https://api.github.com/repos/kurtw/cfgov-refresh/stargazers","contributors_url":"https://api.github.com/repos/kurtw/cfgov-refresh/contributors","subscribers_url":"https://api.github.com/repos/kurtw/cfgov-refresh/subscribers","subscription_url":"https://api.github.com/repos/kurtw/cfgov-refresh/subscription","commits_url":"https://api.github.com/repos/kurtw/cfgov-refresh/commits{/sha}","git_commits_url":"https://api.github.com/repos/kurtw/cfgov-refresh/git/commits{/sha}","comments_url":"https://api.github.com/repos/kurtw/cfgov-refresh/comments{/number}","issue_comment_url":"https://api.github.com/repos/kurtw/cfgov-refresh/issues/comments{/number}","contents_url":"https://api.github.com/repos/kurtw/cfgov-refresh/contents/{+path}","compare_url":"https://api.github.com/repos/kurtw/cfgov-refresh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kurtw/cfgov-refresh/merges","archive_url":"https://api.github.com/repos/kurtw/cfgov-refresh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kurtw/cfgov-refresh/downloads","issues_url":"https://api.github.com/repos/kurtw/cfgov-refresh/issues{/number}","pulls_url":"https://api.github.com/repos/kurtw/cfgov-refresh/pulls{/number}","milestones_url":"https://api.github.com/repos/kurtw/cfgov-refresh/milestones{/number}","notifications_url":"https://api.github.com/repos/kurtw/cfgov-refresh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kurtw/cfgov-refresh/labels{/name}","releases_url":"https://api.github.com/repos/kurtw/cfgov-refresh/releases{/id}","created_at":"2014-11-06T18:13:46Z","updated_at":"2015-03-27T19:56:38Z","pushed_at":"2015-05-29T16:58:26Z","git_url":"git://github.com/kurtw/cfgov-refresh.git","ssh_url":"git@github.com:kurtw/cfgov-refresh.git","clone_url":"https://github.com/kurtw/cfgov-refresh.git","svn_url":"https://github.com/kurtw/cfgov-refresh","homepage":"http://cfpb.github.io/cfgov-refresh/","size":18256,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"gh-pages"}},"base":{"label":"cfpb:flapjack","ref":"flapjack","sha":"19c72d25048491eb98a4fcee0fdae70829de4ef8","user":{"login":"cfpb","id":1071563,"avatar_url":"https://avatars.githubusercontent.com/u/1071563?v=3","gravatar_id":"","url":"https://api.github.com/users/cfpb","html_url":"https://github.com/cfpb","followers_url":"https://api.github.com/users/cfpb/followers","following_url":"https://api.github.com/users/cfpb/following{/other_user}","gists_url":"https://api.github.com/users/cfpb/gists{/gist_id}","starred_url":"https://api.github.com/users/cfpb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfpb/subscriptions","organizations_url":"https://api.github.com/users/cfpb/orgs","repos_url":"https://api.github.com/users/cfpb/repos","events_url":"https://api.github.com/users/cfpb/events{/privacy}","received_events_url":"https://api.github.com/users/cfpb/received_events","type":"Organization","site_admin":false},"repo":{"id":18852566,"name":"cfgov-refresh","full_name":"cfpb/cfgov-refresh","owner":{"login":"cfpb","id":1071563,"avatar_url":"https://avatars.githubusercontent.com/u/1071563?v=3","gravatar_id":"","url":"https://api.github.com/users/cfpb","html_url":"https://github.com/cfpb","followers_url":"https://api.github.com/users/cfpb/followers","following_url":"https://api.github.com/users/cfpb/following{/other_user}","gists_url":"https://api.github.com/users/cfpb/gists{/gist_id}","starred_url":"https://api.github.com/users/cfpb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfpb/subscriptions","organizations_url":"https://api.github.com/users/cfpb/orgs","repos_url":"https://api.github.com/users/cfpb/repos","events_url":"https://api.github.com/users/cfpb/events{/privacy}","received_events_url":"https://api.github.com/users/cfpb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cfpb/cfgov-refresh","description":"In-progress redesign of the consumerfinance.gov website.","fork":false,"url":"https://api.github.com/repos/cfpb/cfgov-refresh","forks_url":"https://api.github.com/repos/cfpb/cfgov-refresh/forks","keys_url":"https://api.github.com/repos/cfpb/cfgov-refresh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cfpb/cfgov-refresh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cfpb/cfgov-refresh/teams","hooks_url":"https://api.github.com/repos/cfpb/cfgov-refresh/hooks","issue_events_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/events{/number}","events_url":"https://api.github.com/repos/cfpb/cfgov-refresh/events","assignees_url":"https://api.github.com/repos/cfpb/cfgov-refresh/assignees{/user}","branches_url":"https://api.github.com/repos/cfpb/cfgov-refresh/branches{/branch}","tags_url":"https://api.github.com/repos/cfpb/cfgov-refresh/tags","blobs_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/refs{/sha}","trees_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cfpb/cfgov-refresh/statuses/{sha}","languages_url":"https://api.github.com/repos/cfpb/cfgov-refresh/languages","stargazers_url":"https://api.github.com/repos/cfpb/cfgov-refresh/stargazers","contributors_url":"https://api.github.com/repos/cfpb/cfgov-refresh/contributors","subscribers_url":"https://api.github.com/repos/cfpb/cfgov-refresh/subscribers","subscription_url":"https://api.github.com/repos/cfpb/cfgov-refresh/subscription","commits_url":"https://api.github.com/repos/cfpb/cfgov-refresh/commits{/sha}","git_commits_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/commits{/sha}","comments_url":"https://api.github.com/repos/cfpb/cfgov-refresh/comments{/number}","issue_comment_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/comments{/number}","contents_url":"https://api.github.com/repos/cfpb/cfgov-refresh/contents/{+path}","compare_url":"https://api.github.com/repos/cfpb/cfgov-refresh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cfpb/cfgov-refresh/merges","archive_url":"https://api.github.com/repos/cfpb/cfgov-refresh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cfpb/cfgov-refresh/downloads","issues_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues{/number}","pulls_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls{/number}","milestones_url":"https://api.github.com/repos/cfpb/cfgov-refresh/milestones{/number}","notifications_url":"https://api.github.com/repos/cfpb/cfgov-refresh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cfpb/cfgov-refresh/labels{/name}","releases_url":"https://api.github.com/repos/cfpb/cfgov-refresh/releases{/id}","created_at":"2014-04-16T19:22:03Z","updated_at":"2015-05-22T16:51:06Z","pushed_at":"2015-05-29T16:58:26Z","git_url":"git://github.com/cfpb/cfgov-refresh.git","ssh_url":"git@github.com:cfpb/cfgov-refresh.git","clone_url":"https://github.com/cfpb/cfgov-refresh.git","svn_url":"https://github.com/cfpb/cfgov-refresh","homepage":"","size":95066,"stargazers_count":8,"watchers_count":8,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":80,"forks":14,"open_issues":80,"watchers":8,"default_branch":"flapjack"}},"_links":{"self":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604"},"html":{"href":"https://github.com/cfpb/cfgov-refresh/pull/604"},"issue":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/604"},"comments":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/604/comments"},"review_comments":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604/comments"},"review_comment":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604/commits"},"statuses":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/statuses/08bc1d5dcf01d44b82b98598270e9ecc623e90fd"}}}}