{"action":"created","comment":{"url":"https://api.github.com/repos/Connexions/cnx-epub/pulls/comments/64615832","id":64615832,"diff_hunk":"@@ -5,31 +5,51 @@\n # Public License version 3 (AGPLv3).\n # See LICENCE.txt for details.\n # ###\n-\"\"\"\\\n-Processes a collated book's single-html representation for validation\n-and parser of specific elements.\n+\"\"\"Processes a collated book's single-html representation for validation.\n \n+Ensures safe parsing for specific elements.\n \"\"\"\n import argparse\n-import os\n+import logging\n import sys\n from pprint import pprint\n-\n+from lxml import etree\n import cnxepub\n \n+logger = logging.getLogger('cnxepub')\n+\n+formatter = logging.Formatter('%(name)s %(levelname)s %(message)s')\n+handler = logging.StreamHandler(sys.stderr)\n+handler.setFormatter(formatter)\n+logger.addHandler(handler)\n+\n \n def main(argv=None):\n+    \"\"\"Parse passed in cooked single HTML.\"\"\"\n     parser = argparse.ArgumentParser(description=__doc__)\n     parser.add_argument('collated_html', type=argparse.FileType('r'),\n-                        help='Path to the collated html file (use - for stdin)')\n+                        help='Path to the collated html'\n+                             ' file (use - for stdin)')\n+    parser.add_argument('-d', '--dump-tree', action='store_true',\n+                        help='Print out parsed model tree.')\n+\n     args = parser.parse_args(argv)\n \n-    binder = cnxepub.adapt_single_html(args.collated_html.read())\n-    pprint(cnxepub.model_to_tree(binder))\n+    html = args.collated_html.read()\n+    try:\n+        htree = etree.fromstring(html)\n+    except etree.XMLSyntaxError:\n+        htree = etree.HTML(html)","path":"cnxepub/scripts/collated_single_html/main.py","position":42,"original_position":46,"commit_id":"6574ad7f1f269ca94426e694fcc0cd10b157ae4e","original_commit_id":"6574ad7f1f269ca94426e694fcc0cd10b157ae4e","user":{"login":"karenc","id":153353,"avatar_url":"https://avatars.githubusercontent.com/u/153353?v=3","gravatar_id":"","url":"https://api.github.com/users/karenc","html_url":"https://github.com/karenc","followers_url":"https://api.github.com/users/karenc/followers","following_url":"https://api.github.com/users/karenc/following{/other_user}","gists_url":"https://api.github.com/users/karenc/gists{/gist_id}","starred_url":"https://api.github.com/users/karenc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karenc/subscriptions","organizations_url":"https://api.github.com/users/karenc/orgs","repos_url":"https://api.github.com/users/karenc/repos","events_url":"https://api.github.com/users/karenc/events{/privacy}","received_events_url":"https://api.github.com/users/karenc/received_events","type":"User","site_admin":false},"body":"IMO there's no point in doing this in the validator script and then failing when we actually reconstitute.","created_at":"2016-05-25T17:27:32Z","updated_at":"2016-05-25T17:27:32Z","html_url":"https://github.com/Connexions/cnx-epub/pull/74#discussion_r64615832","pull_request_url":"https://api.github.com/repos/Connexions/cnx-epub/pulls/74","_links":{"self":{"href":"https://api.github.com/repos/Connexions/cnx-epub/pulls/comments/64615832"},"html":{"href":"https://github.com/Connexions/cnx-epub/pull/74#discussion_r64615832"},"pull_request":{"href":"https://api.github.com/repos/Connexions/cnx-epub/pulls/74"}}},"pull_request":{"url":"https://api.github.com/repos/Connexions/cnx-epub/pulls/74","id":71425646,"html_url":"https://github.com/Connexions/cnx-epub/pull/74","diff_url":"https://github.com/Connexions/cnx-epub/pull/74.diff","patch_url":"https://github.com/Connexions/cnx-epub/pull/74.patch","issue_url":"https://api.github.com/repos/Connexions/cnx-epub/issues/74","number":74,"state":"open","locked":false,"title":"Add a script for validating collated single-html files","user":{"login":"pumazi","id":168470,"avatar_url":"https://avatars.githubusercontent.com/u/168470?v=3","gravatar_id":"","url":"https://api.github.com/users/pumazi","html_url":"https://github.com/pumazi","followers_url":"https://api.github.com/users/pumazi/followers","following_url":"https://api.github.com/users/pumazi/following{/other_user}","gists_url":"https://api.github.com/users/pumazi/gists{/gist_id}","starred_url":"https://api.github.com/users/pumazi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pumazi/subscriptions","organizations_url":"https://api.github.com/users/pumazi/orgs","repos_url":"https://api.github.com/users/pumazi/repos","events_url":"https://api.github.com/users/pumazi/events{/privacy}","received_events_url":"https://api.github.com/users/pumazi/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-25T16:48:51Z","updated_at":"2016-05-25T17:27:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0ac87f08edddb7d3bfd635d73d867ebfcbad7632","assignee":{"login":"karenc","id":153353,"avatar_url":"https://avatars.githubusercontent.com/u/153353?v=3","gravatar_id":"","url":"https://api.github.com/users/karenc","html_url":"https://github.com/karenc","followers_url":"https://api.github.com/users/karenc/followers","following_url":"https://api.github.com/users/karenc/following{/other_user}","gists_url":"https://api.github.com/users/karenc/gists{/gist_id}","starred_url":"https://api.github.com/users/karenc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karenc/subscriptions","organizations_url":"https://api.github.com/users/karenc/orgs","repos_url":"https://api.github.com/users/karenc/repos","events_url":"https://api.github.com/users/karenc/events{/privacy}","received_events_url":"https://api.github.com/users/karenc/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Connexions/cnx-epub/pulls/74/commits","review_comments_url":"https://api.github.com/repos/Connexions/cnx-epub/pulls/74/comments","review_comment_url":"https://api.github.com/repos/Connexions/cnx-epub/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Connexions/cnx-epub/issues/74/comments","statuses_url":"https://api.github.com/repos/Connexions/cnx-epub/statuses/6574ad7f1f269ca94426e694fcc0cd10b157ae4e","head":{"label":"Connexions:validate-script","ref":"validate-script","sha":"6574ad7f1f269ca94426e694fcc0cd10b157ae4e","user":{"login":"Connexions","id":772455,"avatar_url":"https://avatars.githubusercontent.com/u/772455?v=3","gravatar_id":"","url":"https://api.github.com/users/Connexions","html_url":"https://github.com/Connexions","followers_url":"https://api.github.com/users/Connexions/followers","following_url":"https://api.github.com/users/Connexions/following{/other_user}","gists_url":"https://api.github.com/users/Connexions/gists{/gist_id}","starred_url":"https://api.github.com/users/Connexions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Connexions/subscriptions","organizations_url":"https://api.github.com/users/Connexions/orgs","repos_url":"https://api.github.com/users/Connexions/repos","events_url":"https://api.github.com/users/Connexions/events{/privacy}","received_events_url":"https://api.github.com/users/Connexions/received_events","type":"Organization","site_admin":false},"repo":{"id":16184890,"name":"cnx-epub","full_name":"Connexions/cnx-epub","owner":{"login":"Connexions","id":772455,"avatar_url":"https://avatars.githubusercontent.com/u/772455?v=3","gravatar_id":"","url":"https://api.github.com/users/Connexions","html_url":"https://github.com/Connexions","followers_url":"https://api.github.com/users/Connexions/followers","following_url":"https://api.github.com/users/Connexions/following{/other_user}","gists_url":"https://api.github.com/users/Connexions/gists{/gist_id}","starred_url":"https://api.github.com/users/Connexions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Connexions/subscriptions","organizations_url":"https://api.github.com/users/Connexions/orgs","repos_url":"https://api.github.com/users/Connexions/repos","events_url":"https://api.github.com/users/Connexions/events{/privacy}","received_events_url":"https://api.github.com/users/Connexions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Connexions/cnx-epub","description":"","fork":false,"url":"https://api.github.com/repos/Connexions/cnx-epub","forks_url":"https://api.github.com/repos/Connexions/cnx-epub/forks","keys_url":"https://api.github.com/repos/Connexions/cnx-epub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Connexions/cnx-epub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Connexions/cnx-epub/teams","hooks_url":"https://api.github.com/repos/Connexions/cnx-epub/hooks","issue_events_url":"https://api.github.com/repos/Connexions/cnx-epub/issues/events{/number}","events_url":"https://api.github.com/repos/Connexions/cnx-epub/events","assignees_url":"https://api.github.com/repos/Connexions/cnx-epub/assignees{/user}","branches_url":"https://api.github.com/repos/Connexions/cnx-epub/branches{/branch}","tags_url":"https://api.github.com/repos/Connexions/cnx-epub/tags","blobs_url":"https://api.github.com/repos/Connexions/cnx-epub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Connexions/cnx-epub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Connexions/cnx-epub/git/refs{/sha}","trees_url":"https://api.github.com/repos/Connexions/cnx-epub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Connexions/cnx-epub/statuses/{sha}","languages_url":"https://api.github.com/repos/Connexions/cnx-epub/languages","stargazers_url":"https://api.github.com/repos/Connexions/cnx-epub/stargazers","contributors_url":"https://api.github.com/repos/Connexions/cnx-epub/contributors","subscribers_url":"https://api.github.com/repos/Connexions/cnx-epub/subscribers","subscription_url":"https://api.github.com/repos/Connexions/cnx-epub/subscription","commits_url":"https://api.github.com/repos/Connexions/cnx-epub/commits{/sha}","git_commits_url":"https://api.github.com/repos/Connexions/cnx-epub/git/commits{/sha}","comments_url":"https://api.github.com/repos/Connexions/cnx-epub/comments{/number}","issue_comment_url":"https://api.github.com/repos/Connexions/cnx-epub/issues/comments{/number}","contents_url":"https://api.github.com/repos/Connexions/cnx-epub/contents/{+path}","compare_url":"https://api.github.com/repos/Connexions/cnx-epub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Connexions/cnx-epub/merges","archive_url":"https://api.github.com/repos/Connexions/cnx-epub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Connexions/cnx-epub/downloads","issues_url":"https://api.github.com/repos/Connexions/cnx-epub/issues{/number}","pulls_url":"https://api.github.com/repos/Connexions/cnx-epub/pulls{/number}","milestones_url":"https://api.github.com/repos/Connexions/cnx-epub/milestones{/number}","notifications_url":"https://api.github.com/repos/Connexions/cnx-epub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Connexions/cnx-epub/labels{/name}","releases_url":"https://api.github.com/repos/Connexions/cnx-epub/releases{/id}","deployments_url":"https://api.github.com/repos/Connexions/cnx-epub/deployments","created_at":"2014-01-23T20:37:49Z","updated_at":"2016-04-09T11:20:18Z","pushed_at":"2016-05-25T17:07:47Z","git_url":"git://github.com/Connexions/cnx-epub.git","ssh_url":"git@github.com:Connexions/cnx-epub.git","clone_url":"https://github.com/Connexions/cnx-epub.git","svn_url":"https://github.com/Connexions/cnx-epub","homepage":"","size":990,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":7,"forks":1,"open_issues":7,"watchers":1,"default_branch":"master"}},"base":{"label":"Connexions:master","ref":"master","sha":"28eae55df53dcc1b65236ae8021ee668fe285463","user":{"login":"Connexions","id":772455,"avatar_url":"https://avatars.githubusercontent.com/u/772455?v=3","gravatar_id":"","url":"https://api.github.com/users/Connexions","html_url":"https://github.com/Connexions","followers_url":"https://api.github.com/users/Connexions/followers","following_url":"https://api.github.com/users/Connexions/following{/other_user}","gists_url":"https://api.github.com/users/Connexions/gists{/gist_id}","starred_url":"https://api.github.com/users/Connexions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Connexions/subscriptions","organizations_url":"https://api.github.com/users/Connexions/orgs","repos_url":"https://api.github.com/users/Connexions/repos","events_url":"https://api.github.com/users/Connexions/events{/privacy}","received_events_url":"https://api.github.com/users/Connexions/received_events","type":"Organization","site_admin":false},"repo":{"id":16184890,"name":"cnx-epub","full_name":"Connexions/cnx-epub","owner":{"login":"Connexions","id":772455,"avatar_url":"https://avatars.githubusercontent.com/u/772455?v=3","gravatar_id":"","url":"https://api.github.com/users/Connexions","html_url":"https://github.com/Connexions","followers_url":"https://api.github.com/users/Connexions/followers","following_url":"https://api.github.com/users/Connexions/following{/other_user}","gists_url":"https://api.github.com/users/Connexions/gists{/gist_id}","starred_url":"https://api.github.com/users/Connexions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Connexions/subscriptions","organizations_url":"https://api.github.com/users/Connexions/orgs","repos_url":"https://api.github.com/users/Connexions/repos","events_url":"https://api.github.com/users/Connexions/events{/privacy}","received_events_url":"https://api.github.com/users/Connexions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Connexions/cnx-epub","description":"","fork":false,"url":"https://api.github.com/repos/Connexions/cnx-epub","forks_url":"https://api.github.com/repos/Connexions/cnx-epub/forks","keys_url":"https://api.github.com/repos/Connexions/cnx-epub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Connexions/cnx-epub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Connexions/cnx-epub/teams","hooks_url":"https://api.github.com/repos/Connexions/cnx-epub/hooks","issue_events_url":"https://api.github.com/repos/Connexions/cnx-epub/issues/events{/number}","events_url":"https://api.github.com/repos/Connexions/cnx-epub/events","assignees_url":"https://api.github.com/repos/Connexions/cnx-epub/assignees{/user}","branches_url":"https://api.github.com/repos/Connexions/cnx-epub/branches{/branch}","tags_url":"https://api.github.com/repos/Connexions/cnx-epub/tags","blobs_url":"https://api.github.com/repos/Connexions/cnx-epub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Connexions/cnx-epub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Connexions/cnx-epub/git/refs{/sha}","trees_url":"https://api.github.com/repos/Connexions/cnx-epub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Connexions/cnx-epub/statuses/{sha}","languages_url":"https://api.github.com/repos/Connexions/cnx-epub/languages","stargazers_url":"https://api.github.com/repos/Connexions/cnx-epub/stargazers","contributors_url":"https://api.github.com/repos/Connexions/cnx-epub/contributors","subscribers_url":"https://api.github.com/repos/Connexions/cnx-epub/subscribers","subscription_url":"https://api.github.com/repos/Connexions/cnx-epub/subscription","commits_url":"https://api.github.com/repos/Connexions/cnx-epub/commits{/sha}","git_commits_url":"https://api.github.com/repos/Connexions/cnx-epub/git/commits{/sha}","comments_url":"https://api.github.com/repos/Connexions/cnx-epub/comments{/number}","issue_comment_url":"https://api.github.com/repos/Connexions/cnx-epub/issues/comments{/number}","contents_url":"https://api.github.com/repos/Connexions/cnx-epub/contents/{+path}","compare_url":"https://api.github.com/repos/Connexions/cnx-epub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Connexions/cnx-epub/merges","archive_url":"https://api.github.com/repos/Connexions/cnx-epub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Connexions/cnx-epub/downloads","issues_url":"https://api.github.com/repos/Connexions/cnx-epub/issues{/number}","pulls_url":"https://api.github.com/repos/Connexions/cnx-epub/pulls{/number}","milestones_url":"https://api.github.com/repos/Connexions/cnx-epub/milestones{/number}","notifications_url":"https://api.github.com/repos/Connexions/cnx-epub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Connexions/cnx-epub/labels{/name}","releases_url":"https://api.github.com/repos/Connexions/cnx-epub/releases{/id}","deployments_url":"https://api.github.com/repos/Connexions/cnx-epub/deployments","created_at":"2014-01-23T20:37:49Z","updated_at":"2016-04-09T11:20:18Z","pushed_at":"2016-05-25T17:07:47Z","git_url":"git://github.com/Connexions/cnx-epub.git","ssh_url":"git@github.com:Connexions/cnx-epub.git","clone_url":"https://github.com/Connexions/cnx-epub.git","svn_url":"https://github.com/Connexions/cnx-epub","homepage":"","size":990,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":7,"forks":1,"open_issues":7,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Connexions/cnx-epub/pulls/74"},"html":{"href":"https://github.com/Connexions/cnx-epub/pull/74"},"issue":{"href":"https://api.github.com/repos/Connexions/cnx-epub/issues/74"},"comments":{"href":"https://api.github.com/repos/Connexions/cnx-epub/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/Connexions/cnx-epub/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/Connexions/cnx-epub/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Connexions/cnx-epub/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/Connexions/cnx-epub/statuses/6574ad7f1f269ca94426e694fcc0cd10b157ae4e"}}}}
{"actor":{"display_login":"karenc"}}