{"action":"opened","number":41,"pull_request":{"url":"https://api.github.com/repos/tmbdev/hocr-tools/pulls/41","id":83192761,"html_url":"https://github.com/tmbdev/hocr-tools/pull/41","diff_url":"https://github.com/tmbdev/hocr-tools/pull/41.diff","patch_url":"https://github.com/tmbdev/hocr-tools/pull/41.patch","issue_url":"https://api.github.com/repos/tmbdev/hocr-tools/issues/41","number":41,"state":"open","locked":false,"title":"Python3 ready","user":{"login":"kba","id":273367,"avatar_url":"https://avatars.githubusercontent.com/u/273367?v=3","gravatar_id":"","url":"https://api.github.com/users/kba","html_url":"https://github.com/kba","followers_url":"https://api.github.com/users/kba/followers","following_url":"https://api.github.com/users/kba/following{/other_user}","gists_url":"https://api.github.com/users/kba/gists{/gist_id}","starred_url":"https://api.github.com/users/kba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kba/subscriptions","organizations_url":"https://api.github.com/users/kba/orgs","repos_url":"https://api.github.com/users/kba/repos","events_url":"https://api.github.com/users/kba/events{/privacy}","received_events_url":"https://api.github.com/users/kba/received_events","type":"User","site_admin":false},"body":"These changes will make hocr-tools ready for Python 3.4, as outlined in https://github.com/tmbdev/hocr-tools/issues/37\r\n\r\nNote that the code is **not** fully compatible with Python 3.4, since this would require correcting all the `print` calls and I wanted to keep the source as close to its current state as possible. The `2to3` tool bundled with Python can fix the source code automatically however and the converted source runs fine in 2.7 and 3.4 (c.f. [travis.yml](https://github.com/kba/hocr-tools/blob/python3-ready/.travis.yml#L12)).\r\n\r\nMost important changes:\r\n* Don't use lxml's `fromstring`/`tostring` but let lxml handle the distinction of filename and `stdin`/`stdout`\r\n* Use `io.BytesIO` instead of `cStringIO` (which works in 2.7 because there is no distinction between strings and binary data, but is conceptually flawed)\r\n* Don't use `string.join(sep, list)` which is equivalent to `sep.join(list)` and has been since at least 2.5\r\n* Don't raise strings  but instances of real exceptions. It's pythonic and makes the code cleaner IMHO. Using exceptions for CLI argument errors seems overkill though, I replaced those with a helpful message and `sys.exit(1)`\r\n\r\nThe only hack-ish solution is a workaround for a bug in reportlab that will make `hocr-pdf` break in 3.x: The invisible font is loaded from a base64-encoded gzipped blob. reportlab does accept file-like objects for the filename argument to `TTFont` and loads the font properly. It will fail to decode it back to a `latin1` string when saving though. I've opened an [upstream PR for that](https://bitbucket.org/rptlab/reportlab/pull-requests/33/catch-pdfdata-being-byte/diff) but in the meantime, wrapping `sys.stdout` will work around this and not interfere with existing code.","created_at":"2016-08-30T00:59:14Z","updated_at":"2016-08-30T00:59:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tmbdev/hocr-tools/pulls/41/commits","review_comments_url":"https://api.github.com/repos/tmbdev/hocr-tools/pulls/41/comments","review_comment_url":"https://api.github.com/repos/tmbdev/hocr-tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tmbdev/hocr-tools/issues/41/comments","statuses_url":"https://api.github.com/repos/tmbdev/hocr-tools/statuses/a7ef300579716e33b046a9a174507e208cb2a849","head":{"label":"kba:python3-ready","ref":"python3-ready","sha":"a7ef300579716e33b046a9a174507e208cb2a849","user":{"login":"kba","id":273367,"avatar_url":"https://avatars.githubusercontent.com/u/273367?v=3","gravatar_id":"","url":"https://api.github.com/users/kba","html_url":"https://github.com/kba","followers_url":"https://api.github.com/users/kba/followers","following_url":"https://api.github.com/users/kba/following{/other_user}","gists_url":"https://api.github.com/users/kba/gists{/gist_id}","starred_url":"https://api.github.com/users/kba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kba/subscriptions","organizations_url":"https://api.github.com/users/kba/orgs","repos_url":"https://api.github.com/users/kba/repos","events_url":"https://api.github.com/users/kba/events{/privacy}","received_events_url":"https://api.github.com/users/kba/received_events","type":"User","site_admin":false},"repo":{"id":53011153,"name":"hocr-tools","full_name":"kba/hocr-tools","owner":{"login":"kba","id":273367,"avatar_url":"https://avatars.githubusercontent.com/u/273367?v=3","gravatar_id":"","url":"https://api.github.com/users/kba","html_url":"https://github.com/kba","followers_url":"https://api.github.com/users/kba/followers","following_url":"https://api.github.com/users/kba/following{/other_user}","gists_url":"https://api.github.com/users/kba/gists{/gist_id}","starred_url":"https://api.github.com/users/kba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kba/subscriptions","organizations_url":"https://api.github.com/users/kba/orgs","repos_url":"https://api.github.com/users/kba/repos","events_url":"https://api.github.com/users/kba/events{/privacy}","received_events_url":"https://api.github.com/users/kba/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kba/hocr-tools","description":"Tools for manipulating and evaluating the hOCR format for representing multi-lingual OCR results by embedding them into HTML.","fork":true,"url":"https://api.github.com/repos/kba/hocr-tools","forks_url":"https://api.github.com/repos/kba/hocr-tools/forks","keys_url":"https://api.github.com/repos/kba/hocr-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kba/hocr-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kba/hocr-tools/teams","hooks_url":"https://api.github.com/repos/kba/hocr-tools/hooks","issue_events_url":"https://api.github.com/repos/kba/hocr-tools/issues/events{/number}","events_url":"https://api.github.com/repos/kba/hocr-tools/events","assignees_url":"https://api.github.com/repos/kba/hocr-tools/assignees{/user}","branches_url":"https://api.github.com/repos/kba/hocr-tools/branches{/branch}","tags_url":"https://api.github.com/repos/kba/hocr-tools/tags","blobs_url":"https://api.github.com/repos/kba/hocr-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kba/hocr-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kba/hocr-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/kba/hocr-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kba/hocr-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/kba/hocr-tools/languages","stargazers_url":"https://api.github.com/repos/kba/hocr-tools/stargazers","contributors_url":"https://api.github.com/repos/kba/hocr-tools/contributors","subscribers_url":"https://api.github.com/repos/kba/hocr-tools/subscribers","subscription_url":"https://api.github.com/repos/kba/hocr-tools/subscription","commits_url":"https://api.github.com/repos/kba/hocr-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/kba/hocr-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/kba/hocr-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/kba/hocr-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/kba/hocr-tools/contents/{+path}","compare_url":"https://api.github.com/repos/kba/hocr-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kba/hocr-tools/merges","archive_url":"https://api.github.com/repos/kba/hocr-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kba/hocr-tools/downloads","issues_url":"https://api.github.com/repos/kba/hocr-tools/issues{/number}","pulls_url":"https://api.github.com/repos/kba/hocr-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/kba/hocr-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/kba/hocr-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kba/hocr-tools/labels{/name}","releases_url":"https://api.github.com/repos/kba/hocr-tools/releases{/id}","deployments_url":"https://api.github.com/repos/kba/hocr-tools/deployments","created_at":"2016-03-03T01:45:48Z","updated_at":"2016-03-03T01:45:51Z","pushed_at":"2016-08-30T00:45:01Z","git_url":"git://github.com/kba/hocr-tools.git","ssh_url":"git@github.com:kba/hocr-tools.git","clone_url":"https://github.com/kba/hocr-tools.git","svn_url":"https://github.com/kba/hocr-tools","homepage":null,"size":1173,"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":"tmbdev:master","ref":"master","sha":"76fe7679329776d325a1d22cf3b8aa2105141589","user":{"login":"tmbdev","id":333887,"avatar_url":"https://avatars.githubusercontent.com/u/333887?v=3","gravatar_id":"","url":"https://api.github.com/users/tmbdev","html_url":"https://github.com/tmbdev","followers_url":"https://api.github.com/users/tmbdev/followers","following_url":"https://api.github.com/users/tmbdev/following{/other_user}","gists_url":"https://api.github.com/users/tmbdev/gists{/gist_id}","starred_url":"https://api.github.com/users/tmbdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmbdev/subscriptions","organizations_url":"https://api.github.com/users/tmbdev/orgs","repos_url":"https://api.github.com/users/tmbdev/repos","events_url":"https://api.github.com/users/tmbdev/events{/privacy}","received_events_url":"https://api.github.com/users/tmbdev/received_events","type":"User","site_admin":false},"repo":{"id":25888229,"name":"hocr-tools","full_name":"tmbdev/hocr-tools","owner":{"login":"tmbdev","id":333887,"avatar_url":"https://avatars.githubusercontent.com/u/333887?v=3","gravatar_id":"","url":"https://api.github.com/users/tmbdev","html_url":"https://github.com/tmbdev","followers_url":"https://api.github.com/users/tmbdev/followers","following_url":"https://api.github.com/users/tmbdev/following{/other_user}","gists_url":"https://api.github.com/users/tmbdev/gists{/gist_id}","starred_url":"https://api.github.com/users/tmbdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmbdev/subscriptions","organizations_url":"https://api.github.com/users/tmbdev/orgs","repos_url":"https://api.github.com/users/tmbdev/repos","events_url":"https://api.github.com/users/tmbdev/events{/privacy}","received_events_url":"https://api.github.com/users/tmbdev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tmbdev/hocr-tools","description":"Tools for manipulating and evaluating the hOCR format for representing multi-lingual OCR results by embedding them into HTML.","fork":false,"url":"https://api.github.com/repos/tmbdev/hocr-tools","forks_url":"https://api.github.com/repos/tmbdev/hocr-tools/forks","keys_url":"https://api.github.com/repos/tmbdev/hocr-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tmbdev/hocr-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tmbdev/hocr-tools/teams","hooks_url":"https://api.github.com/repos/tmbdev/hocr-tools/hooks","issue_events_url":"https://api.github.com/repos/tmbdev/hocr-tools/issues/events{/number}","events_url":"https://api.github.com/repos/tmbdev/hocr-tools/events","assignees_url":"https://api.github.com/repos/tmbdev/hocr-tools/assignees{/user}","branches_url":"https://api.github.com/repos/tmbdev/hocr-tools/branches{/branch}","tags_url":"https://api.github.com/repos/tmbdev/hocr-tools/tags","blobs_url":"https://api.github.com/repos/tmbdev/hocr-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tmbdev/hocr-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tmbdev/hocr-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/tmbdev/hocr-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tmbdev/hocr-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/tmbdev/hocr-tools/languages","stargazers_url":"https://api.github.com/repos/tmbdev/hocr-tools/stargazers","contributors_url":"https://api.github.com/repos/tmbdev/hocr-tools/contributors","subscribers_url":"https://api.github.com/repos/tmbdev/hocr-tools/subscribers","subscription_url":"https://api.github.com/repos/tmbdev/hocr-tools/subscription","commits_url":"https://api.github.com/repos/tmbdev/hocr-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/tmbdev/hocr-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/tmbdev/hocr-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/tmbdev/hocr-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/tmbdev/hocr-tools/contents/{+path}","compare_url":"https://api.github.com/repos/tmbdev/hocr-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tmbdev/hocr-tools/merges","archive_url":"https://api.github.com/repos/tmbdev/hocr-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tmbdev/hocr-tools/downloads","issues_url":"https://api.github.com/repos/tmbdev/hocr-tools/issues{/number}","pulls_url":"https://api.github.com/repos/tmbdev/hocr-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/tmbdev/hocr-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/tmbdev/hocr-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tmbdev/hocr-tools/labels{/name}","releases_url":"https://api.github.com/repos/tmbdev/hocr-tools/releases{/id}","deployments_url":"https://api.github.com/repos/tmbdev/hocr-tools/deployments","created_at":"2014-10-28T20:16:28Z","updated_at":"2016-08-28T15:52:04Z","pushed_at":"2016-08-29T23:45:01Z","git_url":"git://github.com/tmbdev/hocr-tools.git","ssh_url":"git@github.com:tmbdev/hocr-tools.git","clone_url":"https://github.com/tmbdev/hocr-tools.git","svn_url":"https://github.com/tmbdev/hocr-tools","homepage":null,"size":1183,"stargazers_count":47,"watchers_count":47,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":13,"forks":21,"open_issues":13,"watchers":47,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tmbdev/hocr-tools/pulls/41"},"html":{"href":"https://github.com/tmbdev/hocr-tools/pull/41"},"issue":{"href":"https://api.github.com/repos/tmbdev/hocr-tools/issues/41"},"comments":{"href":"https://api.github.com/repos/tmbdev/hocr-tools/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/tmbdev/hocr-tools/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/tmbdev/hocr-tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tmbdev/hocr-tools/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/tmbdev/hocr-tools/statuses/a7ef300579716e33b046a9a174507e208cb2a849"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":7,"additions":97,"deletions":79,"changed_files":10}}
{"actor":{"display_login":"kba"}}