{"action":"created","comment":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/214710389","pull_request_review_id":151813858,"id":214710389,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNDcxMDM4OQ==","diff_hunk":"@@ -101,11 +101,11 @@ def _generate_translations_for_po(self, worksheet):\n     def _generate_po_file(self, worksheet):\n         \"\"\"\n         extract translations from worksheet and converts to a po file\n-        :return: PoFileGenerator object\n+        :return: list of files generated\n         \"\"\"\n         translations = self._generate_translations_for_po(worksheet)\n-        po_file_generator = PoFileGenerator(translations, {})\n-        return po_file_generator\n+        with PoFileGenerator(translations, {}) as po_file_generator:\n+            return po_file_generator.generated_files[0][1]","path":"corehq/apps/translations/views.py","position":11,"original_position":11,"commit_id":"7d42f35fb4d4305ec1c75131f6808639cb74b1ef","original_commit_id":"7d42f35fb4d4305ec1c75131f6808639cb74b1ef","user":{"login":"millerdev","id":464726,"node_id":"MDQ6VXNlcjQ2NDcyNg==","avatar_url":"https://avatars0.githubusercontent.com/u/464726?v=4","gravatar_id":"","url":"https://api.github.com/users/millerdev","html_url":"https://github.com/millerdev","followers_url":"https://api.github.com/users/millerdev/followers","following_url":"https://api.github.com/users/millerdev/following{/other_user}","gists_url":"https://api.github.com/users/millerdev/gists{/gist_id}","starred_url":"https://api.github.com/users/millerdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/millerdev/subscriptions","organizations_url":"https://api.github.com/users/millerdev/orgs","repos_url":"https://api.github.com/users/millerdev/repos","events_url":"https://api.github.com/users/millerdev/events{/privacy}","received_events_url":"https://api.github.com/users/millerdev/received_events","type":"User","site_admin":false},"body":"Unrelated question: use of index constants in `.generated_files[0][1]` is a bit magic-y. Why only process the first file? If there is only ever one, could `.generated_files` be refactored to be `.generated_file`?\r\n\r\nFinally, named tuple would be nice for readability here, making it `.generated_files[0].path` with the named tuple defined as\r\n```py\r\nfrom collections import namedtuple\r\n\r\nPoFileInfo = namedtuple(\"PoFileInfo\", \"name path\")\r\n```\r\nand\r\n\r\nhttps://github.com/dimagi/commcare-hq/blob/7d42f35fb4d4305ec1c75131f6808639cb74b1ef/corehq/apps/app_manager/app_translations/generators.py#L228\r\n\r\nwould change to\r\n```py\r\nself.generated_files.append(PoFileInfo(file_name, temp_file.name))\r\n```","created_at":"2018-09-03T14:42:26Z","updated_at":"2018-09-03T14:44:37Z","html_url":"https://github.com/dimagi/commcare-hq/pull/21723#discussion_r214710389","pull_request_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21723","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/214710389"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/21723#discussion_r214710389"},"pull_request":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21723"}}},"pull_request":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21723","id":212733789,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyNzMzNzg5","html_url":"https://github.com/dimagi/commcare-hq/pull/21723","diff_url":"https://github.com/dimagi/commcare-hq/pull/21723.diff","patch_url":"https://github.com/dimagi/commcare-hq/pull/21723.patch","issue_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/21723","number":21723,"state":"open","locked":false,"title":"strucutre improvement","user":{"login":"mkangia","id":3864163,"node_id":"MDQ6VXNlcjM4NjQxNjM=","avatar_url":"https://avatars3.githubusercontent.com/u/3864163?v=4","gravatar_id":"","url":"https://api.github.com/users/mkangia","html_url":"https://github.com/mkangia","followers_url":"https://api.github.com/users/mkangia/followers","following_url":"https://api.github.com/users/mkangia/following{/other_user}","gists_url":"https://api.github.com/users/mkangia/gists{/gist_id}","starred_url":"https://api.github.com/users/mkangia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkangia/subscriptions","organizations_url":"https://api.github.com/users/mkangia/orgs","repos_url":"https://api.github.com/users/mkangia/repos","events_url":"https://api.github.com/users/mkangia/events{/privacy}","received_events_url":"https://api.github.com/users/mkangia/received_events","type":"User","site_admin":false},"body":"Follow up on https://github.com/dimagi/commcare-hq/pull/21516\r\n\r\nBasically picked from these two feedbacks\r\nhttps://github.com/dimagi/commcare-hq/pull/21516#pullrequestreview-149742103 by Daniel\r\nhttps://github.com/dimagi/commcare-hq/pull/21516#discussion_r213485235 by Ethan\r\n\r\nChanges made, also in the commit message\r\n- make PoFileGenerator behave as a context manager\r\n- revert TransifexPoFileGenerator to have a method that does the major task[was not needed and was removed eventually]\r\n- rename TransifexPoFileGenerator to AppTranslationsGenerator\r\n\r\nWhy?\r\nContext manager was definitely the way to go. Got all clean up code at one place.\r\nI reverted the change i made earlier for TransfiexPoFileGenerator, specifically [here](https://github.com/dimagi/commcare-hq/pull/21723/files#diff-389860842dade5566b99beb0b7021f2eR192) and thought of bringing all its operations in a single method as suggested by Ethan.\r\nAfter the changes the functionality broke. so then i made `Transifex` co-ordinate directly with `PoFileGenerator` and renamed `TransfiexPoFileGenerator` as `AppTranslationsGenerator` as it was now just generating the content for the translations files.\r\n\r\nThanks for suggesting this.","created_at":"2018-09-03T12:28:49Z","updated_at":"2018-09-03T14:44:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"55367e28e35d2492634ffdb024c51e4dccd662d7","assignee":null,"assignees":[],"requested_reviewers":[{"login":"esoergel","id":2367539,"node_id":"MDQ6VXNlcjIzNjc1Mzk=","avatar_url":"https://avatars2.githubusercontent.com/u/2367539?v=4","gravatar_id":"","url":"https://api.github.com/users/esoergel","html_url":"https://github.com/esoergel","followers_url":"https://api.github.com/users/esoergel/followers","following_url":"https://api.github.com/users/esoergel/following{/other_user}","gists_url":"https://api.github.com/users/esoergel/gists{/gist_id}","starred_url":"https://api.github.com/users/esoergel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/esoergel/subscriptions","organizations_url":"https://api.github.com/users/esoergel/orgs","repos_url":"https://api.github.com/users/esoergel/repos","events_url":"https://api.github.com/users/esoergel/events{/privacy}","received_events_url":"https://api.github.com/users/esoergel/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":724785251,"node_id":"MDU6TGFiZWw3MjQ3ODUyNTE=","url":"https://api.github.com/repos/dimagi/commcare-hq/labels/product/custom","name":"product/custom","color":"71239b","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21723/commits","review_comments_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21723/comments","review_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/21723/comments","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/7d42f35fb4d4305ec1c75131f6808639cb74b1ef","head":{"label":"dimagi:mk-21516-feedback","ref":"mk-21516-feedback","sha":"7d42f35fb4d4305ec1c75131f6808639cb74b1ef","user":{"login":"dimagi","id":94514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTE0","avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":247278,"node_id":"MDEwOlJlcG9zaXRvcnkyNDcyNzg=","name":"commcare-hq","full_name":"dimagi/commcare-hq","owner":{"login":"dimagi","id":94514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTE0","avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-hq","description":"A server-side tool to help manage community health workers, written in Django","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-hq","forks_url":"https://api.github.com/repos/dimagi/commcare-hq/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-hq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-hq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-hq/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-hq/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-hq/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-hq/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-hq/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-hq/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-hq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-hq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-hq/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-hq/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-hq/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-hq/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-hq/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-hq/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-hq/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-hq/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-hq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-hq/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-hq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-hq/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-hq/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-hq/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-hq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-hq/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-hq/releases{/id}","deployments_url":"https://api.github.com/repos/dimagi/commcare-hq/deployments","created_at":"2009-07-09T17:00:07Z","updated_at":"2018-09-03T06:02:12Z","pushed_at":"2018-09-03T13:47:45Z","git_url":"git://github.com/dimagi/commcare-hq.git","ssh_url":"git@github.com:dimagi/commcare-hq.git","clone_url":"https://github.com/dimagi/commcare-hq.git","svn_url":"https://github.com/dimagi/commcare-hq","homepage":"https://www.commcarehq.org","size":459161,"stargazers_count":304,"watchers_count":304,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":120,"mirror_url":null,"archived":false,"open_issues_count":87,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":120,"open_issues":87,"watchers":304,"default_branch":"master"}},"base":{"label":"dimagi:master","ref":"master","sha":"d32641130815ef16d44e693715d205f1b26028ec","user":{"login":"dimagi","id":94514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTE0","avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":247278,"node_id":"MDEwOlJlcG9zaXRvcnkyNDcyNzg=","name":"commcare-hq","full_name":"dimagi/commcare-hq","owner":{"login":"dimagi","id":94514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTE0","avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-hq","description":"A server-side tool to help manage community health workers, written in Django","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-hq","forks_url":"https://api.github.com/repos/dimagi/commcare-hq/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-hq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-hq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-hq/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-hq/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-hq/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-hq/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-hq/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-hq/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-hq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-hq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-hq/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-hq/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-hq/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-hq/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-hq/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-hq/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-hq/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-hq/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-hq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-hq/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-hq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-hq/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-hq/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-hq/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-hq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-hq/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-hq/releases{/id}","deployments_url":"https://api.github.com/repos/dimagi/commcare-hq/deployments","created_at":"2009-07-09T17:00:07Z","updated_at":"2018-09-03T06:02:12Z","pushed_at":"2018-09-03T13:47:45Z","git_url":"git://github.com/dimagi/commcare-hq.git","ssh_url":"git@github.com:dimagi/commcare-hq.git","clone_url":"https://github.com/dimagi/commcare-hq.git","svn_url":"https://github.com/dimagi/commcare-hq","homepage":"https://www.commcarehq.org","size":459161,"stargazers_count":304,"watchers_count":304,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":120,"mirror_url":null,"archived":false,"open_issues_count":87,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":120,"open_issues":87,"watchers":304,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21723"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/21723"},"issue":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/21723"},"comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/21723/comments"},"review_comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21723/comments"},"review_comment":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/21723/commits"},"statuses":{"href":"https://api.github.com/repos/dimagi/commcare-hq/statuses/7d42f35fb4d4305ec1c75131f6808639cb74b1ef"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"millerdev"}}