|
Lines 1-4
Link Here
|
| 1 |
#!/usr/bin/env python |
1 |
#!/usr/bin/env python |
|
|
2 |
from distutils.file_util import copy_file |
| 2 |
from hashlib import md5 |
3 |
from hashlib import md5 |
| 3 |
import logging |
4 |
import logging |
| 4 |
import os |
5 |
import os |
|
Lines 45-51
def _change_entry_in_source_file(module_path, po_entry):
Link Here
|
| 45 |
line = line.replace(po_entry.msgid, 'TEST! {}'.format(po_entry.msgid)) |
46 |
line = line.replace(po_entry.msgid, 'TEST! {}'.format(po_entry.msgid)) |
| 46 |
changed_js.write(line) |
47 |
changed_js.write(line) |
| 47 |
|
48 |
|
| 48 |
|
49 |
SVN = 'SVN_TEST0' |
| 49 |
TRANSLATION_PKG_NAME = 'univention-ucs-translation-XX' |
50 |
TRANSLATION_PKG_NAME = 'univention-ucs-translation-XX' |
| 50 |
# TODO: get latest public branch |
51 |
# TODO: get latest public branch |
| 51 |
if __name__ == '__main__': |
52 |
if __name__ == '__main__': |
|
Lines 57-79
if __name__ == '__main__':
Link Here
|
| 57 |
pass |
58 |
pass |
| 58 |
|
59 |
|
| 59 |
try: |
60 |
try: |
| 60 |
tools.call('svn', 'checkout', 'http://forge.univention.org/svn/dev/branches/ucs-4.1/ucs-4.1-1/management/univention-management-console-module-passwordchange/', 'svn_repo/management/univention-management-console-module-passwordchange') |
61 |
tools.call('svn', 'checkout', 'http://forge.univention.org/svn/dev/branches/ucs-4.1/ucs-4.1-1', SVN) |
| 61 |
tools.call('univention-ucs-translation-build-package', '--source=svn_repo', '--languagecode=XX', '--locale=fr_FR.UTF-8:UTF-8', '--languagename=TEST0') |
62 |
tools.call('univention-ucs-translation-build-package', '--source={}'.format(SVN), '--languagecode=XX', '--locale=fr_FR.UTF-8:UTF-8', '--languagename=TEST0') |
| 62 |
tools.call('univention-ucs-translation-fakemessage', TRANSLATION_PKG_NAME) |
63 |
tools.call('univention-ucs-translation-fakemessage', TRANSLATION_PKG_NAME) |
| 63 |
except InvalidCommandError: |
64 |
except InvalidCommandError: |
| 64 |
print('Error: Tried to launch invalid command. Exiting.') |
65 |
print('Error: Tried to launch invalid command. Exiting.') |
| 65 |
sys.exit(1) |
66 |
sys.exit(1) |
| 66 |
|
67 |
|
| 67 |
# Choose js files to manipulate |
68 |
# Choose js files to manipulate |
| 68 |
js_po_files = tools.get_matching_file_paths(TRANSLATION_PKG_NAME, '*umc*js*.po') |
69 |
changes = list() |
| 69 |
choosen_po_path = random.choice(js_po_files) |
70 |
for file_path_pattern in ('*umc*js*.po', '*umc*python*.po'): |
| 70 |
choosen_po_pre_changes_path = '{}.pre-change'.format(choosen_po_path) |
71 |
po_paths = tools.get_matching_file_paths(TRANSLATION_PKG_NAME, '*umc*js*.po') |
| 71 |
shutil.copy(choosen_po_path, choosen_po_pre_changes_path) |
72 |
|
| 72 |
module_path = '/'.join(choosen_po_path.split('/')[2:4]) |
73 |
# po_path, module_path, random_entry |
| 73 |
choosen_po = polib.pofile(choosen_po_path) |
74 |
for i in range(3): |
| 74 |
random_entry = random.choice(choosen_po) |
75 |
random_po_path = po_paths.pop(random.choice(po_paths)) |
| 75 |
|
76 |
# random_po_paths.append(random_po_path) |
| 76 |
_change_entry_in_source_file(module_path, random_entry) |
77 |
copy_file(random_po_path, '{}.pre_change'.format(random_po_path)) |
|
|
78 |
module_path = '/'.join(random_po_path.split('/')[2:4]) |
| 79 |
random_po = polib.pofile(random_po_path) |
| 80 |
random_entry = random.choice(random_po) |
| 81 |
_change_entry_in_source_file(module_path, random_entry) |
| 82 |
|
| 77 |
tools.call('univention-ucs-translation-merge', 'XX', 'svn_repo', TRANSLATION_PKG_NAME) |
83 |
tools.call('univention-ucs-translation-merge', 'XX', 'svn_repo', TRANSLATION_PKG_NAME) |
| 78 |
|
84 |
|
| 79 |
if not _entry_is_fuzzy(random_entry, choosen_po_path): |
85 |
if not _entry_is_fuzzy(random_entry, choosen_po_path): |