{"action":"created","comment":{"url":"https://api.github.com/repos/learningequality/ricecooker/pulls/comments/91115001","pull_request_review_id":11622610,"id":91115001,"diff_hunk":"@@ -159,6 +169,87 @@ def validate(self):\n         except AssertionError as ae:\n             raise InvalidQuestionException(\"Invalid question: {0}\".format(self.__dict__))\n \n+    def process_question(self, downloader):\n+        \"\"\" process_question: Parse data that needs to have image strings processed\n+            Args:\n+                downloader (DownloadManager): download manager to download images\n+            Returns: list of all downloaded files\n+        \"\"\"\n+        image_files=[]\n+        image_data = json.loads(self.raw_data)\n+\n+        # Process question\n+        if 'question' in image_data and 'images' in image_data['question']:\n+            image_data['question']['images'], qfiles = self.process_image_field(image_data['question'], downloader)\n+            image_files += qfiles\n+\n+        # Process hints\n+        if 'hints' in image_data:\n+            for hint in image_data['hints']:\n+                if 'images' in hint:\n+                    hint['images'], hfiles = self.process_image_field(hint, downloader)\n+                    image_files += hfiles\n+\n+        # Process answers\n+        if 'answers' in image_data:\n+            for answer in image_data['answers']:\n+                if 'images' in answer:\n+                    answer['images'], afiles = self.process_image_field(answer, downloader)\n+                    image_files += afiles\n+\n+        # Process raw data\n+        self.raw_data = json.dumps(image_data, ensure_ascii=False)\n+        self.raw_data, data_files = super(PerseusQuestion, self).set_images(self.raw_data, downloader)\n+\n+        # Return all files\n+        return image_files + data_files\n+\n+    def process_image_field(self, data, downloader):\n+        \"\"\" process_image_field: Specifically process perseus question image field\n+            Args:\n+                data (dict): data that contains 'images' field\n+                downloader (DownloadManager): download manager to download images\n+            Returns: list of all downloaded files\n+        \"\"\"\n+        files = []\n+\n+        new_data = copy.deepcopy(data['images'])\n+        for k, v in data['images'].items():\n+            new_key, fs = self.set_image(k, downloader)\n+            files += fs\n+            new_data[new_key] = new_data.pop(k)\n+        return new_data, files\n+\n+    def set_image(self, text, downloader):\n+        \"\"\" set_images: Replace image strings with downloaded image checksums\n+            Args:\n+                text (str): text to parse for image strings\n+                downloader (DownloadManager): download manager to download images\n+            Returns:string with checksums in place of image strings and\n+                list of files that were downloaded from string\n+        \"\"\"\n+        # Set up return values and regex\n+        file_list = []\n+        graphie_reg = re.compile(WEB_GRAPHIE_URL_REGEX, flags=re.IGNORECASE)\n+        graphie_match = graphie_reg.match(text)\n+        # If it is a web+graphie, download svg and json files,\n+        # Otherwise, download like other files\n+        if graphie_match is not None:","path":"ricecooker/classes/questions.py","position":132,"original_position":132,"commit_id":"601d896374b190871ae5428d300748054863a029","original_commit_id":"601d896374b190871ae5428d300748054863a029","user":{"login":"aronasorman","id":191955,"avatar_url":"https://avatars.githubusercontent.com/u/191955?v=3","gravatar_id":"","url":"https://api.github.com/users/aronasorman","html_url":"https://github.com/aronasorman","followers_url":"https://api.github.com/users/aronasorman/followers","following_url":"https://api.github.com/users/aronasorman/following{/other_user}","gists_url":"https://api.github.com/users/aronasorman/gists{/gist_id}","starred_url":"https://api.github.com/users/aronasorman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aronasorman/subscriptions","organizations_url":"https://api.github.com/users/aronasorman/orgs","repos_url":"https://api.github.com/users/aronasorman/repos","events_url":"https://api.github.com/users/aronasorman/events{/privacy}","received_events_url":"https://api.github.com/users/aronasorman/received_events","type":"User","site_admin":false},"body":"Can be simplified to `if graphie_match:`","created_at":"2016-12-06T16:28:21Z","updated_at":"2016-12-06T16:31:54Z","html_url":"https://github.com/learningequality/ricecooker/pull/30#discussion_r91115001","pull_request_url":"https://api.github.com/repos/learningequality/ricecooker/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/learningequality/ricecooker/pulls/comments/91115001"},"html":{"href":"https://github.com/learningequality/ricecooker/pull/30#discussion_r91115001"},"pull_request":{"href":"https://api.github.com/repos/learningequality/ricecooker/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/learningequality/ricecooker/pulls/30","id":96645909,"html_url":"https://github.com/learningequality/ricecooker/pull/30","diff_url":"https://github.com/learningequality/ricecooker/pull/30.diff","patch_url":"https://github.com/learningequality/ricecooker/pull/30.patch","issue_url":"https://api.github.com/repos/learningequality/ricecooker/issues/30","number":30,"state":"open","locked":false,"title":"Staging support","user":{"login":"jayoshih","id":7447496,"avatar_url":"https://avatars.githubusercontent.com/u/7447496?v=3","gravatar_id":"","url":"https://api.github.com/users/jayoshih","html_url":"https://github.com/jayoshih","followers_url":"https://api.github.com/users/jayoshih/followers","following_url":"https://api.github.com/users/jayoshih/following{/other_user}","gists_url":"https://api.github.com/users/jayoshih/gists{/gist_id}","starred_url":"https://api.github.com/users/jayoshih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayoshih/subscriptions","organizations_url":"https://api.github.com/users/jayoshih/orgs","repos_url":"https://api.github.com/users/jayoshih/repos","events_url":"https://api.github.com/users/jayoshih/events{/privacy}","received_events_url":"https://api.github.com/users/jayoshih/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-06T01:46:55Z","updated_at":"2016-12-06T16:31:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5bbb07efcfffe8c6315e7aa6e0c8c393dbe9f099","assignee":{"login":"aronasorman","id":191955,"avatar_url":"https://avatars.githubusercontent.com/u/191955?v=3","gravatar_id":"","url":"https://api.github.com/users/aronasorman","html_url":"https://github.com/aronasorman","followers_url":"https://api.github.com/users/aronasorman/followers","following_url":"https://api.github.com/users/aronasorman/following{/other_user}","gists_url":"https://api.github.com/users/aronasorman/gists{/gist_id}","starred_url":"https://api.github.com/users/aronasorman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aronasorman/subscriptions","organizations_url":"https://api.github.com/users/aronasorman/orgs","repos_url":"https://api.github.com/users/aronasorman/repos","events_url":"https://api.github.com/users/aronasorman/events{/privacy}","received_events_url":"https://api.github.com/users/aronasorman/received_events","type":"User","site_admin":false},"assignees":[{"login":"aronasorman","id":191955,"avatar_url":"https://avatars.githubusercontent.com/u/191955?v=3","gravatar_id":"","url":"https://api.github.com/users/aronasorman","html_url":"https://github.com/aronasorman","followers_url":"https://api.github.com/users/aronasorman/followers","following_url":"https://api.github.com/users/aronasorman/following{/other_user}","gists_url":"https://api.github.com/users/aronasorman/gists{/gist_id}","starred_url":"https://api.github.com/users/aronasorman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aronasorman/subscriptions","organizations_url":"https://api.github.com/users/aronasorman/orgs","repos_url":"https://api.github.com/users/aronasorman/repos","events_url":"https://api.github.com/users/aronasorman/events{/privacy}","received_events_url":"https://api.github.com/users/aronasorman/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/learningequality/ricecooker/pulls/30/commits","review_comments_url":"https://api.github.com/repos/learningequality/ricecooker/pulls/30/comments","review_comment_url":"https://api.github.com/repos/learningequality/ricecooker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/learningequality/ricecooker/issues/30/comments","statuses_url":"https://api.github.com/repos/learningequality/ricecooker/statuses/601d896374b190871ae5428d300748054863a029","head":{"label":"jayoshih:staging-support","ref":"staging-support","sha":"601d896374b190871ae5428d300748054863a029","user":{"login":"jayoshih","id":7447496,"avatar_url":"https://avatars.githubusercontent.com/u/7447496?v=3","gravatar_id":"","url":"https://api.github.com/users/jayoshih","html_url":"https://github.com/jayoshih","followers_url":"https://api.github.com/users/jayoshih/followers","following_url":"https://api.github.com/users/jayoshih/following{/other_user}","gists_url":"https://api.github.com/users/jayoshih/gists{/gist_id}","starred_url":"https://api.github.com/users/jayoshih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayoshih/subscriptions","organizations_url":"https://api.github.com/users/jayoshih/orgs","repos_url":"https://api.github.com/users/jayoshih/repos","events_url":"https://api.github.com/users/jayoshih/events{/privacy}","received_events_url":"https://api.github.com/users/jayoshih/received_events","type":"User","site_admin":false},"repo":{"id":67824958,"name":"ricecooker","full_name":"jayoshih/ricecooker","owner":{"login":"jayoshih","id":7447496,"avatar_url":"https://avatars.githubusercontent.com/u/7447496?v=3","gravatar_id":"","url":"https://api.github.com/users/jayoshih","html_url":"https://github.com/jayoshih","followers_url":"https://api.github.com/users/jayoshih/followers","following_url":"https://api.github.com/users/jayoshih/following{/other_user}","gists_url":"https://api.github.com/users/jayoshih/gists{/gist_id}","starred_url":"https://api.github.com/users/jayoshih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayoshih/subscriptions","organizations_url":"https://api.github.com/users/jayoshih/orgs","repos_url":"https://api.github.com/users/jayoshih/repos","events_url":"https://api.github.com/users/jayoshih/events{/privacy}","received_events_url":"https://api.github.com/users/jayoshih/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jayoshih/ricecooker","description":"The library for uploading channels to Kolibri!","fork":true,"url":"https://api.github.com/repos/jayoshih/ricecooker","forks_url":"https://api.github.com/repos/jayoshih/ricecooker/forks","keys_url":"https://api.github.com/repos/jayoshih/ricecooker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jayoshih/ricecooker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jayoshih/ricecooker/teams","hooks_url":"https://api.github.com/repos/jayoshih/ricecooker/hooks","issue_events_url":"https://api.github.com/repos/jayoshih/ricecooker/issues/events{/number}","events_url":"https://api.github.com/repos/jayoshih/ricecooker/events","assignees_url":"https://api.github.com/repos/jayoshih/ricecooker/assignees{/user}","branches_url":"https://api.github.com/repos/jayoshih/ricecooker/branches{/branch}","tags_url":"https://api.github.com/repos/jayoshih/ricecooker/tags","blobs_url":"https://api.github.com/repos/jayoshih/ricecooker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jayoshih/ricecooker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jayoshih/ricecooker/git/refs{/sha}","trees_url":"https://api.github.com/repos/jayoshih/ricecooker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jayoshih/ricecooker/statuses/{sha}","languages_url":"https://api.github.com/repos/jayoshih/ricecooker/languages","stargazers_url":"https://api.github.com/repos/jayoshih/ricecooker/stargazers","contributors_url":"https://api.github.com/repos/jayoshih/ricecooker/contributors","subscribers_url":"https://api.github.com/repos/jayoshih/ricecooker/subscribers","subscription_url":"https://api.github.com/repos/jayoshih/ricecooker/subscription","commits_url":"https://api.github.com/repos/jayoshih/ricecooker/commits{/sha}","git_commits_url":"https://api.github.com/repos/jayoshih/ricecooker/git/commits{/sha}","comments_url":"https://api.github.com/repos/jayoshih/ricecooker/comments{/number}","issue_comment_url":"https://api.github.com/repos/jayoshih/ricecooker/issues/comments{/number}","contents_url":"https://api.github.com/repos/jayoshih/ricecooker/contents/{+path}","compare_url":"https://api.github.com/repos/jayoshih/ricecooker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jayoshih/ricecooker/merges","archive_url":"https://api.github.com/repos/jayoshih/ricecooker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jayoshih/ricecooker/downloads","issues_url":"https://api.github.com/repos/jayoshih/ricecooker/issues{/number}","pulls_url":"https://api.github.com/repos/jayoshih/ricecooker/pulls{/number}","milestones_url":"https://api.github.com/repos/jayoshih/ricecooker/milestones{/number}","notifications_url":"https://api.github.com/repos/jayoshih/ricecooker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jayoshih/ricecooker/labels{/name}","releases_url":"https://api.github.com/repos/jayoshih/ricecooker/releases{/id}","deployments_url":"https://api.github.com/repos/jayoshih/ricecooker/deployments","created_at":"2016-09-09T19:04:00Z","updated_at":"2016-09-09T20:10:25Z","pushed_at":"2016-12-06T01:55:34Z","git_url":"git://github.com/jayoshih/ricecooker.git","ssh_url":"git@github.com:jayoshih/ricecooker.git","clone_url":"https://github.com/jayoshih/ricecooker.git","svn_url":"https://github.com/jayoshih/ricecooker","homepage":null,"size":211,"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":"learningequality:master","ref":"master","sha":"126ea561d174728d1057351898b218697c83891f","user":{"login":"learningequality","id":3926525,"avatar_url":"https://avatars.githubusercontent.com/u/3926525?v=3","gravatar_id":"","url":"https://api.github.com/users/learningequality","html_url":"https://github.com/learningequality","followers_url":"https://api.github.com/users/learningequality/followers","following_url":"https://api.github.com/users/learningequality/following{/other_user}","gists_url":"https://api.github.com/users/learningequality/gists{/gist_id}","starred_url":"https://api.github.com/users/learningequality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/learningequality/subscriptions","organizations_url":"https://api.github.com/users/learningequality/orgs","repos_url":"https://api.github.com/users/learningequality/repos","events_url":"https://api.github.com/users/learningequality/events{/privacy}","received_events_url":"https://api.github.com/users/learningequality/received_events","type":"Organization","site_admin":false},"repo":{"id":66887069,"name":"ricecooker","full_name":"learningequality/ricecooker","owner":{"login":"learningequality","id":3926525,"avatar_url":"https://avatars.githubusercontent.com/u/3926525?v=3","gravatar_id":"","url":"https://api.github.com/users/learningequality","html_url":"https://github.com/learningequality","followers_url":"https://api.github.com/users/learningequality/followers","following_url":"https://api.github.com/users/learningequality/following{/other_user}","gists_url":"https://api.github.com/users/learningequality/gists{/gist_id}","starred_url":"https://api.github.com/users/learningequality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/learningequality/subscriptions","organizations_url":"https://api.github.com/users/learningequality/orgs","repos_url":"https://api.github.com/users/learningequality/repos","events_url":"https://api.github.com/users/learningequality/events{/privacy}","received_events_url":"https://api.github.com/users/learningequality/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/learningequality/ricecooker","description":"The library for uploading channels to Kolibri!","fork":false,"url":"https://api.github.com/repos/learningequality/ricecooker","forks_url":"https://api.github.com/repos/learningequality/ricecooker/forks","keys_url":"https://api.github.com/repos/learningequality/ricecooker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/learningequality/ricecooker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/learningequality/ricecooker/teams","hooks_url":"https://api.github.com/repos/learningequality/ricecooker/hooks","issue_events_url":"https://api.github.com/repos/learningequality/ricecooker/issues/events{/number}","events_url":"https://api.github.com/repos/learningequality/ricecooker/events","assignees_url":"https://api.github.com/repos/learningequality/ricecooker/assignees{/user}","branches_url":"https://api.github.com/repos/learningequality/ricecooker/branches{/branch}","tags_url":"https://api.github.com/repos/learningequality/ricecooker/tags","blobs_url":"https://api.github.com/repos/learningequality/ricecooker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/learningequality/ricecooker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/learningequality/ricecooker/git/refs{/sha}","trees_url":"https://api.github.com/repos/learningequality/ricecooker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/learningequality/ricecooker/statuses/{sha}","languages_url":"https://api.github.com/repos/learningequality/ricecooker/languages","stargazers_url":"https://api.github.com/repos/learningequality/ricecooker/stargazers","contributors_url":"https://api.github.com/repos/learningequality/ricecooker/contributors","subscribers_url":"https://api.github.com/repos/learningequality/ricecooker/subscribers","subscription_url":"https://api.github.com/repos/learningequality/ricecooker/subscription","commits_url":"https://api.github.com/repos/learningequality/ricecooker/commits{/sha}","git_commits_url":"https://api.github.com/repos/learningequality/ricecooker/git/commits{/sha}","comments_url":"https://api.github.com/repos/learningequality/ricecooker/comments{/number}","issue_comment_url":"https://api.github.com/repos/learningequality/ricecooker/issues/comments{/number}","contents_url":"https://api.github.com/repos/learningequality/ricecooker/contents/{+path}","compare_url":"https://api.github.com/repos/learningequality/ricecooker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/learningequality/ricecooker/merges","archive_url":"https://api.github.com/repos/learningequality/ricecooker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/learningequality/ricecooker/downloads","issues_url":"https://api.github.com/repos/learningequality/ricecooker/issues{/number}","pulls_url":"https://api.github.com/repos/learningequality/ricecooker/pulls{/number}","milestones_url":"https://api.github.com/repos/learningequality/ricecooker/milestones{/number}","notifications_url":"https://api.github.com/repos/learningequality/ricecooker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/learningequality/ricecooker/labels{/name}","releases_url":"https://api.github.com/repos/learningequality/ricecooker/releases{/id}","deployments_url":"https://api.github.com/repos/learningequality/ricecooker/deployments","created_at":"2016-08-29T23:02:41Z","updated_at":"2016-09-22T01:41:56Z","pushed_at":"2016-12-06T01:55:34Z","git_url":"git://github.com/learningequality/ricecooker.git","ssh_url":"git@github.com:learningequality/ricecooker.git","clone_url":"https://github.com/learningequality/ricecooker.git","svn_url":"https://github.com/learningequality/ricecooker","homepage":null,"size":136,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":16,"forks":6,"open_issues":16,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/learningequality/ricecooker/pulls/30"},"html":{"href":"https://github.com/learningequality/ricecooker/pull/30"},"issue":{"href":"https://api.github.com/repos/learningequality/ricecooker/issues/30"},"comments":{"href":"https://api.github.com/repos/learningequality/ricecooker/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/learningequality/ricecooker/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/learningequality/ricecooker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/learningequality/ricecooker/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/learningequality/ricecooker/statuses/601d896374b190871ae5428d300748054863a029"}}}}
{"actor":{"display_login":"aronasorman"}}