{"action":"created","comment":{"url":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/comments/48100270","id":48100270,"diff_hunk":"@@ -0,0 +1,76 @@\n+# -*- coding: utf-8 -*-\n+\n+import logging, urllib2, re, os\n+\n+from cStringIO import StringIO\n+from django.conf import settings\n+from simple.management.utils import antiword\n+from pyth.plugins.rtf15.reader import Rtf15Reader\n+\n+logger = logging.getLogger(\"open-knesset.syncdata\")\n+\n+DATA_ROOT = getattr(settings, 'DATA_ROOT',\n+                    os.path.join(settings.PROJECT_ROOT, os.path.pardir, os.path.pardir, 'data'))\n+\n+ENCODING = 'utf8'\n+\n+\n+class CommitteProtocolImporter:\n+\n+    _file = StringIO()\n+    _directory = os.path.join(DATA_ROOT, 'comm_p')\n+    _retry_times = 10\n+\n+    def __init__(self, url):\n+        self._url = url\n+        if not os.path.exists(self._directory):\n+            os.makedirs(self._directory)\n+        self._file_name = os.path.join(self._directory, 'comm_p.doc')\n+\n+    def get_text(self):\n+        logger.debug('get_committee_protocol_text. url=%s' % self._url)\n+        if self._url.find('html') >= 0:\n+            self._url = self._url.replace('html','rtf')\n+        count = 0\n+        flag = True\n+        while count < self._retry_times and flag:\n+            try:\n+                self._file.write(urllib2.urlopen(self._url).read())\n+                flag = False\n+            except Exception:\n+                count += 1\n+        if flag:\n+            logger.error(\"can't open url %s. tried %d times\" % (self._url, count))\n+\n+        if self._url.find(\".rtf\") >= 0:\n+            return self.handle_rtf_protocol()\n+        if self._url.find(\".doc\") >= 0:\n+            return self.handle_doc_protocol()\n+\n+    def handle_doc_protocol(self):\n+        directory = os.path.join(DATA_ROOT, 'comm_p')","path":"simple/management/committee_protocol.py","position":51,"original_position":51,"commit_id":"9a46bbd4c10d20afd174dc16aba7254782c24c9a","original_commit_id":"9a46bbd4c10d20afd174dc16aba7254782c24c9a","user":{"login":"OriHoch","id":1198854,"avatar_url":"https://avatars.githubusercontent.com/u/1198854?v=3","gravatar_id":"","url":"https://api.github.com/users/OriHoch","html_url":"https://github.com/OriHoch","followers_url":"https://api.github.com/users/OriHoch/followers","following_url":"https://api.github.com/users/OriHoch/following{/other_user}","gists_url":"https://api.github.com/users/OriHoch/gists{/gist_id}","starred_url":"https://api.github.com/users/OriHoch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OriHoch/subscriptions","organizations_url":"https://api.github.com/users/OriHoch/orgs","repos_url":"https://api.github.com/users/OriHoch/repos","events_url":"https://api.github.com/users/OriHoch/events{/privacy}","received_events_url":"https://api.github.com/users/OriHoch/received_events","type":"User","site_admin":false},"body":"this line can be removed","created_at":"2015-12-20T06:23:22Z","updated_at":"2015-12-20T06:23:22Z","html_url":"https://github.com/hasadna/Open-Knesset/pull/450#discussion_r48100270","pull_request_url":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/450","_links":{"self":{"href":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/comments/48100270"},"html":{"href":"https://github.com/hasadna/Open-Knesset/pull/450#discussion_r48100270"},"pull_request":{"href":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/450"}}},"pull_request":{"url":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/450","id":53618629,"html_url":"https://github.com/hasadna/Open-Knesset/pull/450","diff_url":"https://github.com/hasadna/Open-Knesset/pull/450.diff","patch_url":"https://github.com/hasadna/Open-Knesset/pull/450.patch","issue_url":"https://api.github.com/repos/hasadna/Open-Knesset/issues/450","number":450,"state":"open","locked":false,"title":"[WIP] issue-432 committee protocol invided section is confusing","user":{"login":"wasymur","id":3462607,"avatar_url":"https://avatars.githubusercontent.com/u/3462607?v=3","gravatar_id":"","url":"https://api.github.com/users/wasymur","html_url":"https://github.com/wasymur","followers_url":"https://api.github.com/users/wasymur/followers","following_url":"https://api.github.com/users/wasymur/following{/other_user}","gists_url":"https://api.github.com/users/wasymur/gists{/gist_id}","starred_url":"https://api.github.com/users/wasymur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wasymur/subscriptions","organizations_url":"https://api.github.com/users/wasymur/orgs","repos_url":"https://api.github.com/users/wasymur/repos","events_url":"https://api.github.com/users/wasymur/events{/privacy}","received_events_url":"https://api.github.com/users/wasymur/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-14T20:40:13Z","updated_at":"2015-12-20T06:23:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4833a92fc34f580d778f139fa4059dc1a06fea04","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/450/commits","review_comments_url":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/450/comments","review_comment_url":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hasadna/Open-Knesset/issues/450/comments","statuses_url":"https://api.github.com/repos/hasadna/Open-Knesset/statuses/9a46bbd4c10d20afd174dc16aba7254782c24c9a","head":{"label":"wasymur:issue-432-committee-protocol-invited-section-is-confusing","ref":"issue-432-committee-protocol-invited-section-is-confusing","sha":"9a46bbd4c10d20afd174dc16aba7254782c24c9a","user":{"login":"wasymur","id":3462607,"avatar_url":"https://avatars.githubusercontent.com/u/3462607?v=3","gravatar_id":"","url":"https://api.github.com/users/wasymur","html_url":"https://github.com/wasymur","followers_url":"https://api.github.com/users/wasymur/followers","following_url":"https://api.github.com/users/wasymur/following{/other_user}","gists_url":"https://api.github.com/users/wasymur/gists{/gist_id}","starred_url":"https://api.github.com/users/wasymur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wasymur/subscriptions","organizations_url":"https://api.github.com/users/wasymur/orgs","repos_url":"https://api.github.com/users/wasymur/repos","events_url":"https://api.github.com/users/wasymur/events{/privacy}","received_events_url":"https://api.github.com/users/wasymur/received_events","type":"User","site_admin":false},"repo":{"id":47104231,"name":"Open-Knesset","full_name":"wasymur/Open-Knesset","owner":{"login":"wasymur","id":3462607,"avatar_url":"https://avatars.githubusercontent.com/u/3462607?v=3","gravatar_id":"","url":"https://api.github.com/users/wasymur","html_url":"https://github.com/wasymur","followers_url":"https://api.github.com/users/wasymur/followers","following_url":"https://api.github.com/users/wasymur/following{/other_user}","gists_url":"https://api.github.com/users/wasymur/gists{/gist_id}","starred_url":"https://api.github.com/users/wasymur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wasymur/subscriptions","organizations_url":"https://api.github.com/users/wasymur/orgs","repos_url":"https://api.github.com/users/wasymur/repos","events_url":"https://api.github.com/users/wasymur/events{/privacy}","received_events_url":"https://api.github.com/users/wasymur/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wasymur/Open-Knesset","description":"A project aimed at making the Israeli Knesset more transparent. Python and Django based","fork":true,"url":"https://api.github.com/repos/wasymur/Open-Knesset","forks_url":"https://api.github.com/repos/wasymur/Open-Knesset/forks","keys_url":"https://api.github.com/repos/wasymur/Open-Knesset/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wasymur/Open-Knesset/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wasymur/Open-Knesset/teams","hooks_url":"https://api.github.com/repos/wasymur/Open-Knesset/hooks","issue_events_url":"https://api.github.com/repos/wasymur/Open-Knesset/issues/events{/number}","events_url":"https://api.github.com/repos/wasymur/Open-Knesset/events","assignees_url":"https://api.github.com/repos/wasymur/Open-Knesset/assignees{/user}","branches_url":"https://api.github.com/repos/wasymur/Open-Knesset/branches{/branch}","tags_url":"https://api.github.com/repos/wasymur/Open-Knesset/tags","blobs_url":"https://api.github.com/repos/wasymur/Open-Knesset/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wasymur/Open-Knesset/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wasymur/Open-Knesset/git/refs{/sha}","trees_url":"https://api.github.com/repos/wasymur/Open-Knesset/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wasymur/Open-Knesset/statuses/{sha}","languages_url":"https://api.github.com/repos/wasymur/Open-Knesset/languages","stargazers_url":"https://api.github.com/repos/wasymur/Open-Knesset/stargazers","contributors_url":"https://api.github.com/repos/wasymur/Open-Knesset/contributors","subscribers_url":"https://api.github.com/repos/wasymur/Open-Knesset/subscribers","subscription_url":"https://api.github.com/repos/wasymur/Open-Knesset/subscription","commits_url":"https://api.github.com/repos/wasymur/Open-Knesset/commits{/sha}","git_commits_url":"https://api.github.com/repos/wasymur/Open-Knesset/git/commits{/sha}","comments_url":"https://api.github.com/repos/wasymur/Open-Knesset/comments{/number}","issue_comment_url":"https://api.github.com/repos/wasymur/Open-Knesset/issues/comments{/number}","contents_url":"https://api.github.com/repos/wasymur/Open-Knesset/contents/{+path}","compare_url":"https://api.github.com/repos/wasymur/Open-Knesset/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wasymur/Open-Knesset/merges","archive_url":"https://api.github.com/repos/wasymur/Open-Knesset/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wasymur/Open-Knesset/downloads","issues_url":"https://api.github.com/repos/wasymur/Open-Knesset/issues{/number}","pulls_url":"https://api.github.com/repos/wasymur/Open-Knesset/pulls{/number}","milestones_url":"https://api.github.com/repos/wasymur/Open-Knesset/milestones{/number}","notifications_url":"https://api.github.com/repos/wasymur/Open-Knesset/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wasymur/Open-Knesset/labels{/name}","releases_url":"https://api.github.com/repos/wasymur/Open-Knesset/releases{/id}","created_at":"2015-11-30T08:10:39Z","updated_at":"2015-11-30T08:10:44Z","pushed_at":"2015-12-14T20:38:44Z","git_url":"git://github.com/wasymur/Open-Knesset.git","ssh_url":"git@github.com:wasymur/Open-Knesset.git","clone_url":"https://github.com/wasymur/Open-Knesset.git","svn_url":"https://github.com/wasymur/Open-Knesset","homepage":"http://oknesset.org/","size":28126,"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":"hasadna:master","ref":"master","sha":"e965c114f9cfe621a81977ae815960996736b688","user":{"login":"hasadna","id":503639,"avatar_url":"https://avatars.githubusercontent.com/u/503639?v=3","gravatar_id":"","url":"https://api.github.com/users/hasadna","html_url":"https://github.com/hasadna","followers_url":"https://api.github.com/users/hasadna/followers","following_url":"https://api.github.com/users/hasadna/following{/other_user}","gists_url":"https://api.github.com/users/hasadna/gists{/gist_id}","starred_url":"https://api.github.com/users/hasadna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasadna/subscriptions","organizations_url":"https://api.github.com/users/hasadna/orgs","repos_url":"https://api.github.com/users/hasadna/repos","events_url":"https://api.github.com/users/hasadna/events{/privacy}","received_events_url":"https://api.github.com/users/hasadna/received_events","type":"Organization","site_admin":false},"repo":{"id":1125942,"name":"Open-Knesset","full_name":"hasadna/Open-Knesset","owner":{"login":"hasadna","id":503639,"avatar_url":"https://avatars.githubusercontent.com/u/503639?v=3","gravatar_id":"","url":"https://api.github.com/users/hasadna","html_url":"https://github.com/hasadna","followers_url":"https://api.github.com/users/hasadna/followers","following_url":"https://api.github.com/users/hasadna/following{/other_user}","gists_url":"https://api.github.com/users/hasadna/gists{/gist_id}","starred_url":"https://api.github.com/users/hasadna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasadna/subscriptions","organizations_url":"https://api.github.com/users/hasadna/orgs","repos_url":"https://api.github.com/users/hasadna/repos","events_url":"https://api.github.com/users/hasadna/events{/privacy}","received_events_url":"https://api.github.com/users/hasadna/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hasadna/Open-Knesset","description":"A project aimed at making the Israeli Knesset more transparent. Python and Django based","fork":true,"url":"https://api.github.com/repos/hasadna/Open-Knesset","forks_url":"https://api.github.com/repos/hasadna/Open-Knesset/forks","keys_url":"https://api.github.com/repos/hasadna/Open-Knesset/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hasadna/Open-Knesset/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hasadna/Open-Knesset/teams","hooks_url":"https://api.github.com/repos/hasadna/Open-Knesset/hooks","issue_events_url":"https://api.github.com/repos/hasadna/Open-Knesset/issues/events{/number}","events_url":"https://api.github.com/repos/hasadna/Open-Knesset/events","assignees_url":"https://api.github.com/repos/hasadna/Open-Knesset/assignees{/user}","branches_url":"https://api.github.com/repos/hasadna/Open-Knesset/branches{/branch}","tags_url":"https://api.github.com/repos/hasadna/Open-Knesset/tags","blobs_url":"https://api.github.com/repos/hasadna/Open-Knesset/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hasadna/Open-Knesset/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hasadna/Open-Knesset/git/refs{/sha}","trees_url":"https://api.github.com/repos/hasadna/Open-Knesset/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hasadna/Open-Knesset/statuses/{sha}","languages_url":"https://api.github.com/repos/hasadna/Open-Knesset/languages","stargazers_url":"https://api.github.com/repos/hasadna/Open-Knesset/stargazers","contributors_url":"https://api.github.com/repos/hasadna/Open-Knesset/contributors","subscribers_url":"https://api.github.com/repos/hasadna/Open-Knesset/subscribers","subscription_url":"https://api.github.com/repos/hasadna/Open-Knesset/subscription","commits_url":"https://api.github.com/repos/hasadna/Open-Knesset/commits{/sha}","git_commits_url":"https://api.github.com/repos/hasadna/Open-Knesset/git/commits{/sha}","comments_url":"https://api.github.com/repos/hasadna/Open-Knesset/comments{/number}","issue_comment_url":"https://api.github.com/repos/hasadna/Open-Knesset/issues/comments{/number}","contents_url":"https://api.github.com/repos/hasadna/Open-Knesset/contents/{+path}","compare_url":"https://api.github.com/repos/hasadna/Open-Knesset/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hasadna/Open-Knesset/merges","archive_url":"https://api.github.com/repos/hasadna/Open-Knesset/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hasadna/Open-Knesset/downloads","issues_url":"https://api.github.com/repos/hasadna/Open-Knesset/issues{/number}","pulls_url":"https://api.github.com/repos/hasadna/Open-Knesset/pulls{/number}","milestones_url":"https://api.github.com/repos/hasadna/Open-Knesset/milestones{/number}","notifications_url":"https://api.github.com/repos/hasadna/Open-Knesset/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hasadna/Open-Knesset/labels{/name}","releases_url":"https://api.github.com/repos/hasadna/Open-Knesset/releases{/id}","created_at":"2010-11-30T16:49:48Z","updated_at":"2015-11-30T21:48:00Z","pushed_at":"2015-12-15T07:11:08Z","git_url":"git://github.com/hasadna/Open-Knesset.git","ssh_url":"git@github.com:hasadna/Open-Knesset.git","clone_url":"https://github.com/hasadna/Open-Knesset.git","svn_url":"https://github.com/hasadna/Open-Knesset","homepage":"http://oknesset.org/","size":56747,"stargazers_count":64,"watchers_count":64,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":183,"mirror_url":null,"open_issues_count":101,"forks":183,"open_issues":101,"watchers":64,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/450"},"html":{"href":"https://github.com/hasadna/Open-Knesset/pull/450"},"issue":{"href":"https://api.github.com/repos/hasadna/Open-Knesset/issues/450"},"comments":{"href":"https://api.github.com/repos/hasadna/Open-Knesset/issues/450/comments"},"review_comments":{"href":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/450/comments"},"review_comment":{"href":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hasadna/Open-Knesset/pulls/450/commits"},"statuses":{"href":"https://api.github.com/repos/hasadna/Open-Knesset/statuses/9a46bbd4c10d20afd174dc16aba7254782c24c9a"}}}}