{"action":"created","comment":{"url":"https://api.github.com/repos/translate/pootle/pulls/comments/41208195","id":41208195,"diff_hunk":"@@ -0,0 +1,151 @@\n+#!/usr/bin/env python\n+# -*- coding: utf-8 -*-\n+#\n+# Copyright (C) Pootle contributors.\n+#\n+# This file is a part of the Pootle project. It is distributed under the GPL3\n+# or later license. See the LICENSE file for a copy of the license and the\n+# AUTHORS file for copyright and authorship information.\n+\n+from hashlib import md5\n+from optparse import make_option\n+import os\n+import sys\n+\n+from elasticsearch import helpers, Elasticsearch\n+from translate.storage import factory\n+\n+# This must be run before importing Django.\n+os.environ['DJANGO_SETTINGS_MODULE'] = 'pootle.settings'\n+\n+from django.conf import settings\n+from django.core.management.base import BaseCommand, CommandError\n+\n+\n+BULK_CHUNK_SIZE = 5000\n+\n+\n+class Command(BaseCommand):\n+    help = \"Add external translations to Local Translation Memory\"\n+    option_list = BaseCommand.option_list + (\n+        make_option('--rebuild',\n+                    action=\"store_true\",\n+                    dest='rebuild',\n+                    default=False,\n+                    help='Drop the entire TM on start and update everything '\n+                         'from scratch'),\n+        make_option('--dry-run',\n+                    action=\"store_true\",\n+                    dest='dry_run',\n+                    default=False,\n+                    help='Report the number of translations to index and quit'),\n+        make_option('--tm',\n+                    action='store',\n+                    dest='tm_server',\n+                    help=\"TM to use. TM must exist on settings. TM will be \"\n+                         \"created on the server if it doesn't exist\"),\n+        make_option('--target-language',\n+                    action='store',\n+                    dest='target_language',\n+                    help=\"Target language to fallback to use in case it can't \"\n+                         \"be guessed for any of the input files.\"),\n+    )\n+\n+    def _parse_translations(self, *args, **options):\n+        units = []\n+\n+        for filename in args:\n+            store = factory.getobject(filename)\n+            if (not store.gettargetlanguage() and\n+                not self.target_language and\n+                not options['dry_run']):\n+\n+                raise CommandError(\"Unable to get target language for '%s'. \"","path":"pootle/apps/pootle_app/management/commands/update_external_tmserver.py","position":63,"original_position":63,"commit_id":"df40bd2a01e552fb5ce682826f300b6d5ec20ce5","original_commit_id":"df40bd2a01e552fb5ce682826f300b6d5ec20ce5","user":{"login":"dwaynebailey","id":647438,"avatar_url":"https://avatars.githubusercontent.com/u/647438?v=3","gravatar_id":"","url":"https://api.github.com/users/dwaynebailey","html_url":"https://github.com/dwaynebailey","followers_url":"https://api.github.com/users/dwaynebailey/followers","following_url":"https://api.github.com/users/dwaynebailey/following{/other_user}","gists_url":"https://api.github.com/users/dwaynebailey/gists{/gist_id}","starred_url":"https://api.github.com/users/dwaynebailey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwaynebailey/subscriptions","organizations_url":"https://api.github.com/users/dwaynebailey/orgs","repos_url":"https://api.github.com/users/dwaynebailey/repos","events_url":"https://api.github.com/users/dwaynebailey/events{/privacy}","received_events_url":"https://api.github.com/users/dwaynebailey/received_events","type":"User","site_admin":false},"body":"s/get/determine","created_at":"2015-10-05T22:53:17Z","updated_at":"2015-10-05T22:53:17Z","html_url":"https://github.com/translate/pootle/pull/4128#discussion_r41208195","pull_request_url":"https://api.github.com/repos/translate/pootle/pulls/4128","_links":{"self":{"href":"https://api.github.com/repos/translate/pootle/pulls/comments/41208195"},"html":{"href":"https://github.com/translate/pootle/pull/4128#discussion_r41208195"},"pull_request":{"href":"https://api.github.com/repos/translate/pootle/pulls/4128"}}},"pull_request":{"url":"https://api.github.com/repos/translate/pootle/pulls/4128","id":46800024,"html_url":"https://github.com/translate/pootle/pull/4128","diff_url":"https://github.com/translate/pootle/pull/4128.diff","patch_url":"https://github.com/translate/pootle/pull/4128.patch","issue_url":"https://api.github.com/repos/translate/pootle/issues/4128","number":4128,"state":"open","locked":false,"title":"Use additional local (external) TMs","user":{"login":"unho","id":939880,"avatar_url":"https://avatars.githubusercontent.com/u/939880?v=3","gravatar_id":"","url":"https://api.github.com/users/unho","html_url":"https://github.com/unho","followers_url":"https://api.github.com/users/unho/followers","following_url":"https://api.github.com/users/unho/following{/other_user}","gists_url":"https://api.github.com/users/unho/gists{/gist_id}","starred_url":"https://api.github.com/users/unho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unho/subscriptions","organizations_url":"https://api.github.com/users/unho/orgs","repos_url":"https://api.github.com/users/unho/repos","events_url":"https://api.github.com/users/unho/events{/privacy}","received_events_url":"https://api.github.com/users/unho/received_events","type":"User","site_admin":false},"body":"This adds the ability to create additional translation memories, and use\r\nthem on the editor. Results are now pondered using the result score\r\nand a weighting factor specific to each TM server (between 0 and 1).\r\n\r\nFixes #4102.","created_at":"2015-10-05T16:04:35Z","updated_at":"2015-10-05T22:53:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c08a09ed158a44493de45fb47d9de1a88445751","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/translate/pootle/pulls/4128/commits","review_comments_url":"https://api.github.com/repos/translate/pootle/pulls/4128/comments","review_comment_url":"https://api.github.com/repos/translate/pootle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/translate/pootle/issues/4128/comments","statuses_url":"https://api.github.com/repos/translate/pootle/statuses/df40bd2a01e552fb5ce682826f300b6d5ec20ce5","head":{"label":"unho:localtm","ref":"localtm","sha":"df40bd2a01e552fb5ce682826f300b6d5ec20ce5","user":{"login":"unho","id":939880,"avatar_url":"https://avatars.githubusercontent.com/u/939880?v=3","gravatar_id":"","url":"https://api.github.com/users/unho","html_url":"https://github.com/unho","followers_url":"https://api.github.com/users/unho/followers","following_url":"https://api.github.com/users/unho/following{/other_user}","gists_url":"https://api.github.com/users/unho/gists{/gist_id}","starred_url":"https://api.github.com/users/unho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unho/subscriptions","organizations_url":"https://api.github.com/users/unho/orgs","repos_url":"https://api.github.com/users/unho/repos","events_url":"https://api.github.com/users/unho/events{/privacy}","received_events_url":"https://api.github.com/users/unho/received_events","type":"User","site_admin":false},"repo":{"id":8295531,"name":"pootle","full_name":"unho/pootle","owner":{"login":"unho","id":939880,"avatar_url":"https://avatars.githubusercontent.com/u/939880?v=3","gravatar_id":"","url":"https://api.github.com/users/unho","html_url":"https://github.com/unho","followers_url":"https://api.github.com/users/unho/followers","following_url":"https://api.github.com/users/unho/following{/other_user}","gists_url":"https://api.github.com/users/unho/gists{/gist_id}","starred_url":"https://api.github.com/users/unho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unho/subscriptions","organizations_url":"https://api.github.com/users/unho/orgs","repos_url":"https://api.github.com/users/unho/repos","events_url":"https://api.github.com/users/unho/events{/privacy}","received_events_url":"https://api.github.com/users/unho/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/unho/pootle","description":"Online translation tool","fork":true,"url":"https://api.github.com/repos/unho/pootle","forks_url":"https://api.github.com/repos/unho/pootle/forks","keys_url":"https://api.github.com/repos/unho/pootle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/unho/pootle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/unho/pootle/teams","hooks_url":"https://api.github.com/repos/unho/pootle/hooks","issue_events_url":"https://api.github.com/repos/unho/pootle/issues/events{/number}","events_url":"https://api.github.com/repos/unho/pootle/events","assignees_url":"https://api.github.com/repos/unho/pootle/assignees{/user}","branches_url":"https://api.github.com/repos/unho/pootle/branches{/branch}","tags_url":"https://api.github.com/repos/unho/pootle/tags","blobs_url":"https://api.github.com/repos/unho/pootle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/unho/pootle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/unho/pootle/git/refs{/sha}","trees_url":"https://api.github.com/repos/unho/pootle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/unho/pootle/statuses/{sha}","languages_url":"https://api.github.com/repos/unho/pootle/languages","stargazers_url":"https://api.github.com/repos/unho/pootle/stargazers","contributors_url":"https://api.github.com/repos/unho/pootle/contributors","subscribers_url":"https://api.github.com/repos/unho/pootle/subscribers","subscription_url":"https://api.github.com/repos/unho/pootle/subscription","commits_url":"https://api.github.com/repos/unho/pootle/commits{/sha}","git_commits_url":"https://api.github.com/repos/unho/pootle/git/commits{/sha}","comments_url":"https://api.github.com/repos/unho/pootle/comments{/number}","issue_comment_url":"https://api.github.com/repos/unho/pootle/issues/comments{/number}","contents_url":"https://api.github.com/repos/unho/pootle/contents/{+path}","compare_url":"https://api.github.com/repos/unho/pootle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/unho/pootle/merges","archive_url":"https://api.github.com/repos/unho/pootle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/unho/pootle/downloads","issues_url":"https://api.github.com/repos/unho/pootle/issues{/number}","pulls_url":"https://api.github.com/repos/unho/pootle/pulls{/number}","milestones_url":"https://api.github.com/repos/unho/pootle/milestones{/number}","notifications_url":"https://api.github.com/repos/unho/pootle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/unho/pootle/labels{/name}","releases_url":"https://api.github.com/repos/unho/pootle/releases{/id}","created_at":"2013-02-19T17:34:16Z","updated_at":"2015-05-07T09:02:57Z","pushed_at":"2015-10-05T21:17:01Z","git_url":"git://github.com/unho/pootle.git","ssh_url":"git@github.com:unho/pootle.git","clone_url":"https://github.com/unho/pootle.git","svn_url":"https://github.com/unho/pootle","homepage":"http://pootle.translatehouse.org","size":83654,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"translate:master","ref":"master","sha":"97487324be8ef45499ff6d806f62ef2502fc4eb8","user":{"login":"translate","id":1538178,"avatar_url":"https://avatars.githubusercontent.com/u/1538178?v=3","gravatar_id":"","url":"https://api.github.com/users/translate","html_url":"https://github.com/translate","followers_url":"https://api.github.com/users/translate/followers","following_url":"https://api.github.com/users/translate/following{/other_user}","gists_url":"https://api.github.com/users/translate/gists{/gist_id}","starred_url":"https://api.github.com/users/translate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/translate/subscriptions","organizations_url":"https://api.github.com/users/translate/orgs","repos_url":"https://api.github.com/users/translate/repos","events_url":"https://api.github.com/users/translate/events{/privacy}","received_events_url":"https://api.github.com/users/translate/received_events","type":"Organization","site_admin":false},"repo":{"id":3769702,"name":"pootle","full_name":"translate/pootle","owner":{"login":"translate","id":1538178,"avatar_url":"https://avatars.githubusercontent.com/u/1538178?v=3","gravatar_id":"","url":"https://api.github.com/users/translate","html_url":"https://github.com/translate","followers_url":"https://api.github.com/users/translate/followers","following_url":"https://api.github.com/users/translate/following{/other_user}","gists_url":"https://api.github.com/users/translate/gists{/gist_id}","starred_url":"https://api.github.com/users/translate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/translate/subscriptions","organizations_url":"https://api.github.com/users/translate/orgs","repos_url":"https://api.github.com/users/translate/repos","events_url":"https://api.github.com/users/translate/events{/privacy}","received_events_url":"https://api.github.com/users/translate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/translate/pootle","description":"Online translation tool","fork":false,"url":"https://api.github.com/repos/translate/pootle","forks_url":"https://api.github.com/repos/translate/pootle/forks","keys_url":"https://api.github.com/repos/translate/pootle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/translate/pootle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/translate/pootle/teams","hooks_url":"https://api.github.com/repos/translate/pootle/hooks","issue_events_url":"https://api.github.com/repos/translate/pootle/issues/events{/number}","events_url":"https://api.github.com/repos/translate/pootle/events","assignees_url":"https://api.github.com/repos/translate/pootle/assignees{/user}","branches_url":"https://api.github.com/repos/translate/pootle/branches{/branch}","tags_url":"https://api.github.com/repos/translate/pootle/tags","blobs_url":"https://api.github.com/repos/translate/pootle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/translate/pootle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/translate/pootle/git/refs{/sha}","trees_url":"https://api.github.com/repos/translate/pootle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/translate/pootle/statuses/{sha}","languages_url":"https://api.github.com/repos/translate/pootle/languages","stargazers_url":"https://api.github.com/repos/translate/pootle/stargazers","contributors_url":"https://api.github.com/repos/translate/pootle/contributors","subscribers_url":"https://api.github.com/repos/translate/pootle/subscribers","subscription_url":"https://api.github.com/repos/translate/pootle/subscription","commits_url":"https://api.github.com/repos/translate/pootle/commits{/sha}","git_commits_url":"https://api.github.com/repos/translate/pootle/git/commits{/sha}","comments_url":"https://api.github.com/repos/translate/pootle/comments{/number}","issue_comment_url":"https://api.github.com/repos/translate/pootle/issues/comments{/number}","contents_url":"https://api.github.com/repos/translate/pootle/contents/{+path}","compare_url":"https://api.github.com/repos/translate/pootle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/translate/pootle/merges","archive_url":"https://api.github.com/repos/translate/pootle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/translate/pootle/downloads","issues_url":"https://api.github.com/repos/translate/pootle/issues{/number}","pulls_url":"https://api.github.com/repos/translate/pootle/pulls{/number}","milestones_url":"https://api.github.com/repos/translate/pootle/milestones{/number}","notifications_url":"https://api.github.com/repos/translate/pootle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/translate/pootle/labels{/name}","releases_url":"https://api.github.com/repos/translate/pootle/releases{/id}","created_at":"2012-03-19T23:06:03Z","updated_at":"2015-10-01T15:46:59Z","pushed_at":"2015-10-05T21:17:01Z","git_url":"git://github.com/translate/pootle.git","ssh_url":"git@github.com:translate/pootle.git","clone_url":"https://github.com/translate/pootle.git","svn_url":"https://github.com/translate/pootle","homepage":"http://pootle.translatehouse.org","size":90537,"stargazers_count":517,"watchers_count":517,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":158,"mirror_url":null,"open_issues_count":244,"forks":158,"open_issues":244,"watchers":517,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/translate/pootle/pulls/4128"},"html":{"href":"https://github.com/translate/pootle/pull/4128"},"issue":{"href":"https://api.github.com/repos/translate/pootle/issues/4128"},"comments":{"href":"https://api.github.com/repos/translate/pootle/issues/4128/comments"},"review_comments":{"href":"https://api.github.com/repos/translate/pootle/pulls/4128/comments"},"review_comment":{"href":"https://api.github.com/repos/translate/pootle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/translate/pootle/pulls/4128/commits"},"statuses":{"href":"https://api.github.com/repos/translate/pootle/statuses/df40bd2a01e552fb5ce682826f300b6d5ec20ce5"}}}}