{"action":"created","comment":{"url":"https://api.github.com/repos/softvar/json2html/pulls/comments/64862519","id":64862519,"diff_hunk":"@@ -78,88 +78,81 @@ def columnHeadersFromListOfDicts(self, inputtedJson):\n                 -----------------------------\n \n             @contributed by: @muellermichel\n-        '''\n+        \"\"\"\n \n-        if len(inputtedJson) < 2:\n-            return None\n-        if not isinstance(inputtedJson[0], dict):\n+        if not inputted_json or not isinstance(inputted_json[0], dict):\n             return None\n \n-        column_headers = inputtedJson[0].keys()\n+        column_headers = inputted_json[0].keys()\n \n-        for entry in inputtedJson:\n-            if not isinstance(entry, dict):\n-                return None\n-            if len(entry.keys()) != len(column_headers):\n+        for entry in inputted_json:\n+            if not isinstance(entry, dict) or (len(entry.keys()) != len(column_headers)):\n                 return None\n             for header in column_headers:\n                 if header not in entry:\n                     return None\n         return column_headers\n \n-    def iterJson(self, inputtedJson):\n-        '''\n+    def iter_json(self, inputted_json):\n+        \"\"\"\n             Iterate over the JSON and process it\n             to generate the super awesome HTML Table format\n-        '''\n+        \"\"\"\n \n         def markup(entry):\n-            '''\n+            \"\"\"\n                 Check for each value corresponding to its key\n                 and return accordingly\n-            '''\n-            if (isinstance(entry, unicode)):\n+            \"\"\"\n+            if isinstance(entry, unicode):\n                 return unicode(entry)\n-            if (isinstance(entry, int) or isinstance(entry, float)):\n+            if isinstance(entry, int) or isinstance(entry, float):\n                 return str(entry)\n-            if (isinstance(entry, list) == True) and len(entry) == 0:\n+            if isinstance(entry, list) and len(entry) == 0:\n                 return ''\n-            if (isinstance(entry, list) == True):\n-                listMarkup = ''\n-                listMarkup += '<ul><li>'\n-                listMarkup += '</li><li>'.join([markup(child) for child in entry])\n-                listMarkup += '</li></ul>'\n-                return listMarkup\n-            if (isinstance(entry, dict) == True):\n-                return self.iterJson(entry)\n+            if isinstance(entry, list):\n+                list_markup = '<ul><li>'\n+                list_markup += '</li><li>'.join([markup(child) for child in entry])\n+                list_markup += '</li></ul>'\n+                return list_markup\n+            if isinstance(entry, dict):\n+                return self.iter_json(entry)\n \n             # safety: don't do recursion over anything that we don't know about\n             # - iteritems() will most probably fail\n             return ''\n \n-        convertedOutput = ''\n+        converted_output = ''\n \n         global table_attributes\n-        table_init_markup = \"<table %s>\" % (table_attributes)\n-        convertedOutput = convertedOutput + table_init_markup\n+        table_init_markup = \"<table %s>\" % table_attributes\n+        converted_output += table_init_markup\n \n         try:\n-            for (k, v) in inputtedJson.iteritems():\n-                convertedOutput = convertedOutput + '<tr>'\n-                convertedOutput = convertedOutput + '<th>' + markup(k) + '</th>'\n+            for (k, v) in inputted_json.iteritems():\n+                converted_output += '<tr><th>' + markup(k) + '</th>'\n \n-                if (v is None):\n+                if v is None:\n                     v = unicode(\"\")\n-                if(isinstance(v, list)):\n-                    column_headers = self.columnHeadersFromListOfDicts(v)\n+                if isinstance(v, list):\n+                    column_headers = self.column_headers_from_list_of_dicts(v)\n                     if column_headers is not None:\n-                        convertedOutput = convertedOutput + '<td>'\n-                        convertedOutput += table_init_markup\n-                        convertedOutput += '<tr><th>' + '</th><th>'.join(column_headers) + '</th></tr>'\n+                        converted_output += '<td>'\n+                        converted_output += table_init_markup\n+                        converted_output += '<tr><th>' + '</th><th>'.join(column_headers) + '</th></tr>'\n                         for list_entry in v:\n-                            convertedOutput = convertedOutput\n-                            convertedOutput += '<tr><td>'\n-                            convertedOutput += '</td><td>'.join([markup(list_entry[column_header]) for column_header in column_headers])\n-                            convertedOutput += '</td></tr>'\n+                            converted_output += '<tr><td>'\n+                            converted_output += '</td><td>'.join([markup(list_entry[column_header]) for column_header in\n+                                                                 column_headers])","path":"json2html/jsonconv.py","position":175,"original_position":175,"commit_id":"b2657ac935f84b79a605b21500b59c770a364ec2","original_commit_id":"b2657ac935f84b79a605b21500b59c770a364ec2","user":{"login":"muellermichel","id":3378634,"avatar_url":"https://avatars.githubusercontent.com/u/3378634?v=3","gravatar_id":"","url":"https://api.github.com/users/muellermichel","html_url":"https://github.com/muellermichel","followers_url":"https://api.github.com/users/muellermichel/followers","following_url":"https://api.github.com/users/muellermichel/following{/other_user}","gists_url":"https://api.github.com/users/muellermichel/gists{/gist_id}","starred_url":"https://api.github.com/users/muellermichel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muellermichel/subscriptions","organizations_url":"https://api.github.com/users/muellermichel/orgs","repos_url":"https://api.github.com/users/muellermichel/repos","events_url":"https://api.github.com/users/muellermichel/events{/privacy}","received_events_url":"https://api.github.com/users/muellermichel/received_events","type":"User","site_admin":false},"body":"how about\r\n\r\n    converted_output += '</td><td>'.join([\r\n        markup(list_entry[column_header])\r\n        for column_header in column_headers\r\n    ])\r\n\r\nI like this style of closing brackets better, I find it much more readable.","created_at":"2016-05-27T06:35:00Z","updated_at":"2016-05-27T06:35:00Z","html_url":"https://github.com/softvar/json2html/pull/17#discussion_r64862519","pull_request_url":"https://api.github.com/repos/softvar/json2html/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/softvar/json2html/pulls/comments/64862519"},"html":{"href":"https://github.com/softvar/json2html/pull/17#discussion_r64862519"},"pull_request":{"href":"https://api.github.com/repos/softvar/json2html/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/softvar/json2html/pulls/17","id":68344481,"html_url":"https://github.com/softvar/json2html/pull/17","diff_url":"https://github.com/softvar/json2html/pull/17.diff","patch_url":"https://github.com/softvar/json2html/pull/17.patch","issue_url":"https://api.github.com/repos/softvar/json2html/issues/17","number":17,"state":"open","locked":false,"title":"Fixed issue with single-item lists rendering incorrectly. Fixed all naming conventions and coding standards to adhere to PEP8.","user":{"login":"Lekic","id":4584883,"avatar_url":"https://avatars.githubusercontent.com/u/4584883?v=3","gravatar_id":"","url":"https://api.github.com/users/Lekic","html_url":"https://github.com/Lekic","followers_url":"https://api.github.com/users/Lekic/followers","following_url":"https://api.github.com/users/Lekic/following{/other_user}","gists_url":"https://api.github.com/users/Lekic/gists{/gist_id}","starred_url":"https://api.github.com/users/Lekic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lekic/subscriptions","organizations_url":"https://api.github.com/users/Lekic/orgs","repos_url":"https://api.github.com/users/Lekic/repos","events_url":"https://api.github.com/users/Lekic/events{/privacy}","received_events_url":"https://api.github.com/users/Lekic/received_events","type":"User","site_admin":false},"body":"The changes are predominately formatting and conventions, with a minor change in the header generation section that allows for correct handling of one-item lists.","created_at":"2016-04-29T09:23:25Z","updated_at":"2016-05-27T06:35:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8b2b0fd997e377074031aad276112c8ab22d30ca","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/softvar/json2html/pulls/17/commits","review_comments_url":"https://api.github.com/repos/softvar/json2html/pulls/17/comments","review_comment_url":"https://api.github.com/repos/softvar/json2html/pulls/comments{/number}","comments_url":"https://api.github.com/repos/softvar/json2html/issues/17/comments","statuses_url":"https://api.github.com/repos/softvar/json2html/statuses/b2657ac935f84b79a605b21500b59c770a364ec2","head":{"label":"Lekic:master","ref":"master","sha":"b2657ac935f84b79a605b21500b59c770a364ec2","user":{"login":"Lekic","id":4584883,"avatar_url":"https://avatars.githubusercontent.com/u/4584883?v=3","gravatar_id":"","url":"https://api.github.com/users/Lekic","html_url":"https://github.com/Lekic","followers_url":"https://api.github.com/users/Lekic/followers","following_url":"https://api.github.com/users/Lekic/following{/other_user}","gists_url":"https://api.github.com/users/Lekic/gists{/gist_id}","starred_url":"https://api.github.com/users/Lekic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lekic/subscriptions","organizations_url":"https://api.github.com/users/Lekic/orgs","repos_url":"https://api.github.com/users/Lekic/repos","events_url":"https://api.github.com/users/Lekic/events{/privacy}","received_events_url":"https://api.github.com/users/Lekic/received_events","type":"User","site_admin":false},"repo":{"id":57372572,"name":"json2html","full_name":"Lekic/json2html","owner":{"login":"Lekic","id":4584883,"avatar_url":"https://avatars.githubusercontent.com/u/4584883?v=3","gravatar_id":"","url":"https://api.github.com/users/Lekic","html_url":"https://github.com/Lekic","followers_url":"https://api.github.com/users/Lekic/followers","following_url":"https://api.github.com/users/Lekic/following{/other_user}","gists_url":"https://api.github.com/users/Lekic/gists{/gist_id}","starred_url":"https://api.github.com/users/Lekic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lekic/subscriptions","organizations_url":"https://api.github.com/users/Lekic/orgs","repos_url":"https://api.github.com/users/Lekic/repos","events_url":"https://api.github.com/users/Lekic/events{/privacy}","received_events_url":"https://api.github.com/users/Lekic/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Lekic/json2html","description":"python module  for converting complex JSON oject to HTML Table representation","fork":true,"url":"https://api.github.com/repos/Lekic/json2html","forks_url":"https://api.github.com/repos/Lekic/json2html/forks","keys_url":"https://api.github.com/repos/Lekic/json2html/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lekic/json2html/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lekic/json2html/teams","hooks_url":"https://api.github.com/repos/Lekic/json2html/hooks","issue_events_url":"https://api.github.com/repos/Lekic/json2html/issues/events{/number}","events_url":"https://api.github.com/repos/Lekic/json2html/events","assignees_url":"https://api.github.com/repos/Lekic/json2html/assignees{/user}","branches_url":"https://api.github.com/repos/Lekic/json2html/branches{/branch}","tags_url":"https://api.github.com/repos/Lekic/json2html/tags","blobs_url":"https://api.github.com/repos/Lekic/json2html/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lekic/json2html/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lekic/json2html/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lekic/json2html/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lekic/json2html/statuses/{sha}","languages_url":"https://api.github.com/repos/Lekic/json2html/languages","stargazers_url":"https://api.github.com/repos/Lekic/json2html/stargazers","contributors_url":"https://api.github.com/repos/Lekic/json2html/contributors","subscribers_url":"https://api.github.com/repos/Lekic/json2html/subscribers","subscription_url":"https://api.github.com/repos/Lekic/json2html/subscription","commits_url":"https://api.github.com/repos/Lekic/json2html/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lekic/json2html/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lekic/json2html/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lekic/json2html/issues/comments{/number}","contents_url":"https://api.github.com/repos/Lekic/json2html/contents/{+path}","compare_url":"https://api.github.com/repos/Lekic/json2html/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lekic/json2html/merges","archive_url":"https://api.github.com/repos/Lekic/json2html/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lekic/json2html/downloads","issues_url":"https://api.github.com/repos/Lekic/json2html/issues{/number}","pulls_url":"https://api.github.com/repos/Lekic/json2html/pulls{/number}","milestones_url":"https://api.github.com/repos/Lekic/json2html/milestones{/number}","notifications_url":"https://api.github.com/repos/Lekic/json2html/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lekic/json2html/labels{/name}","releases_url":"https://api.github.com/repos/Lekic/json2html/releases{/id}","deployments_url":"https://api.github.com/repos/Lekic/json2html/deployments","created_at":"2016-04-29T09:18:10Z","updated_at":"2016-04-29T09:18:11Z","pushed_at":"2016-04-29T09:21:17Z","git_url":"git://github.com/Lekic/json2html.git","ssh_url":"git@github.com:Lekic/json2html.git","clone_url":"https://github.com/Lekic/json2html.git","svn_url":"https://github.com/Lekic/json2html","homepage":"https://pypi.python.org/pypi/json2html","size":32,"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":"softvar:master","ref":"master","sha":"00e6e42b07fc985c2c818d56b20c1f75984ac9b4","user":{"login":"softvar","id":4180800,"avatar_url":"https://avatars.githubusercontent.com/u/4180800?v=3","gravatar_id":"","url":"https://api.github.com/users/softvar","html_url":"https://github.com/softvar","followers_url":"https://api.github.com/users/softvar/followers","following_url":"https://api.github.com/users/softvar/following{/other_user}","gists_url":"https://api.github.com/users/softvar/gists{/gist_id}","starred_url":"https://api.github.com/users/softvar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softvar/subscriptions","organizations_url":"https://api.github.com/users/softvar/orgs","repos_url":"https://api.github.com/users/softvar/repos","events_url":"https://api.github.com/users/softvar/events{/privacy}","received_events_url":"https://api.github.com/users/softvar/received_events","type":"User","site_admin":false},"repo":{"id":13423891,"name":"json2html","full_name":"softvar/json2html","owner":{"login":"softvar","id":4180800,"avatar_url":"https://avatars.githubusercontent.com/u/4180800?v=3","gravatar_id":"","url":"https://api.github.com/users/softvar","html_url":"https://github.com/softvar","followers_url":"https://api.github.com/users/softvar/followers","following_url":"https://api.github.com/users/softvar/following{/other_user}","gists_url":"https://api.github.com/users/softvar/gists{/gist_id}","starred_url":"https://api.github.com/users/softvar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softvar/subscriptions","organizations_url":"https://api.github.com/users/softvar/orgs","repos_url":"https://api.github.com/users/softvar/repos","events_url":"https://api.github.com/users/softvar/events{/privacy}","received_events_url":"https://api.github.com/users/softvar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/softvar/json2html","description":"python module  for converting complex JSON oject to HTML Table representation","fork":false,"url":"https://api.github.com/repos/softvar/json2html","forks_url":"https://api.github.com/repos/softvar/json2html/forks","keys_url":"https://api.github.com/repos/softvar/json2html/keys{/key_id}","collaborators_url":"https://api.github.com/repos/softvar/json2html/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/softvar/json2html/teams","hooks_url":"https://api.github.com/repos/softvar/json2html/hooks","issue_events_url":"https://api.github.com/repos/softvar/json2html/issues/events{/number}","events_url":"https://api.github.com/repos/softvar/json2html/events","assignees_url":"https://api.github.com/repos/softvar/json2html/assignees{/user}","branches_url":"https://api.github.com/repos/softvar/json2html/branches{/branch}","tags_url":"https://api.github.com/repos/softvar/json2html/tags","blobs_url":"https://api.github.com/repos/softvar/json2html/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/softvar/json2html/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/softvar/json2html/git/refs{/sha}","trees_url":"https://api.github.com/repos/softvar/json2html/git/trees{/sha}","statuses_url":"https://api.github.com/repos/softvar/json2html/statuses/{sha}","languages_url":"https://api.github.com/repos/softvar/json2html/languages","stargazers_url":"https://api.github.com/repos/softvar/json2html/stargazers","contributors_url":"https://api.github.com/repos/softvar/json2html/contributors","subscribers_url":"https://api.github.com/repos/softvar/json2html/subscribers","subscription_url":"https://api.github.com/repos/softvar/json2html/subscription","commits_url":"https://api.github.com/repos/softvar/json2html/commits{/sha}","git_commits_url":"https://api.github.com/repos/softvar/json2html/git/commits{/sha}","comments_url":"https://api.github.com/repos/softvar/json2html/comments{/number}","issue_comment_url":"https://api.github.com/repos/softvar/json2html/issues/comments{/number}","contents_url":"https://api.github.com/repos/softvar/json2html/contents/{+path}","compare_url":"https://api.github.com/repos/softvar/json2html/compare/{base}...{head}","merges_url":"https://api.github.com/repos/softvar/json2html/merges","archive_url":"https://api.github.com/repos/softvar/json2html/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/softvar/json2html/downloads","issues_url":"https://api.github.com/repos/softvar/json2html/issues{/number}","pulls_url":"https://api.github.com/repos/softvar/json2html/pulls{/number}","milestones_url":"https://api.github.com/repos/softvar/json2html/milestones{/number}","notifications_url":"https://api.github.com/repos/softvar/json2html/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/softvar/json2html/labels{/name}","releases_url":"https://api.github.com/repos/softvar/json2html/releases{/id}","deployments_url":"https://api.github.com/repos/softvar/json2html/deployments","created_at":"2013-10-08T19:52:30Z","updated_at":"2016-05-23T09:20:25Z","pushed_at":"2016-05-26T08:40:18Z","git_url":"git://github.com/softvar/json2html.git","ssh_url":"git@github.com:softvar/json2html.git","clone_url":"https://github.com/softvar/json2html.git","svn_url":"https://github.com/softvar/json2html","homepage":"https://pypi.python.org/pypi/json2html","size":32,"stargazers_count":22,"watchers_count":22,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":7,"forks":22,"open_issues":7,"watchers":22,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/softvar/json2html/pulls/17"},"html":{"href":"https://github.com/softvar/json2html/pull/17"},"issue":{"href":"https://api.github.com/repos/softvar/json2html/issues/17"},"comments":{"href":"https://api.github.com/repos/softvar/json2html/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/softvar/json2html/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/softvar/json2html/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/softvar/json2html/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/softvar/json2html/statuses/b2657ac935f84b79a605b21500b59c770a364ec2"}}}}
{"actor":{"display_login":"muellermichel"}}