Merge lp:~kissiel/checkbox/migrate-from-make into lp:checkbox

Proposed by Maciej Kisielewski
Status: Merged
Approved by: Maciej Kisielewski
Approved revision: 4429
Merged at revision: 4426
Proposed branch: lp:~kissiel/checkbox/migrate-from-make
Merge into: lp:checkbox
Diff against target: 117 lines (+56/-3)
3 files modified
checkbox-touch/Makefile (+9/-1)
checkbox-touch/build-me (+35/-2)
checkbox-touch/utils.py (+12/-0)
To merge this branch: bzr merge lp:~kissiel/checkbox/migrate-from-make
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Needs Fixing
Review via email: mp+299415@code.launchpad.net

Description of the change

This MR adds Checkbox-Converged i18n-related task to build-me.

Main rationale behind it is lack makes inability to handle colons in filenames, and we use (and even require colons to be present in the provider name, which is usually used as the directory name for that provider. In turn those provider are then searched for translatable strings - making Make fail.

e3f8da1 converged:utils: add poor man's find
afe9242 converged: add building of .mo files to build-me
eece2fa converged: add --update-potfile to build-me
d9c42f7 converged: add deprecation warning to i18n-related task in makefile

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

just one typo, otherwise +1

review: Needs Fixing
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

> just one typo, otherwise +1

Fixed, rebased, repushed.

self-landing

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Attempt to merge into lp:checkbox failed due to conflicts:

duplicate in plainbox/plainbox/impl/providers/exporters/data/global.txt.moved

4425. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

4426. By Maciej Kisielewski

converged:utils: add poor man's find

Signed-off-by: Maciej Kisielewski <email address hidden>

4427. By Maciej Kisielewski

converged: add building of .mo files to build-me

Signed-off-by: Maciej Kisielewski <email address hidden>

4428. By Maciej Kisielewski

converged: add --update-potfile to build-me

Signed-off-by: Maciej Kisielewski <email address hidden>

4429. By Maciej Kisielewski

converged: add deprecation warning to i18n-related task in makefile

Signed-off-by: Maciej Kisielewski <email address hidden>

Revision history for this message
Maciej Kisielewski (kissiel) wrote :

> Attempt to merge into lp:checkbox failed due to conflicts:
>
> duplicate in plainbox/plainbox/impl/providers/exporters/data/global.txt.moved

Weird. Rebased on current trunk.
Trying to land...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'checkbox-touch/Makefile'
--- checkbox-touch/Makefile 2016-07-01 10:05:57 +0000
+++ checkbox-touch/Makefile 2016-07-11 06:51:05 +0000
@@ -40,12 +40,20 @@
40 /usr/bin/qmlscene $@ checkbox-touch.qml40 /usr/bin/qmlscene $@ checkbox-touch.qml
4141
42build-translations: $(MO_FILES)42build-translations: $(MO_FILES)
43 echo $(MO_FILES)43 @echo "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
44 @echo "Use of this Makefile for i18n tasks is deprecated"
45 @echo "./build-me will build translations for you automatically"
46 @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
47 @echo $(MO_FILES)
4448
45po:49po:
46 mkdir -p $(CURDIR)/po50 mkdir -p $(CURDIR)/po
4751
48po/checkbox-touch.pot: $(QMLJS_FILES) $(PY_FILES) | po52po/checkbox-touch.pot: $(QMLJS_FILES) $(PY_FILES) | po
53 @echo "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
54 @echo "Use of this Makefile for i18n tasks is deprecated"
55 @echo "Use ./build-me --update-potfile instead"
56 @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
49 xgettext -o po/checkbox-touch.pot --qt --c++ --add-comments=TRANSLATORS --keyword=tr --keyword=tr:1,2 $(QMLJS_FILES) --from-code=UTF-857 xgettext -o po/checkbox-touch.pot --qt --c++ --add-comments=TRANSLATORS --keyword=tr --keyword=tr:1,2 $(QMLJS_FILES) --from-code=UTF-8
50 xgettext -o po/checkbox-touch.pot --join-existing --language=python --add-comments=TRANSLATORS --keyword=_ --keyword=N_ $(PY_FILES)58 xgettext -o po/checkbox-touch.pot --join-existing --language=python --add-comments=TRANSLATORS --keyword=_ --keyword=N_ $(PY_FILES)
5159
5260
=== modified file 'checkbox-touch/build-me'
--- checkbox-touch/build-me 2016-06-15 22:31:58 +0000
+++ checkbox-touch/build-me 2016-07-11 06:51:05 +0000
@@ -16,6 +16,7 @@
16from utils import get_package_from_url_and_extract16from utils import get_package_from_url_and_extract
17from utils import prepare_uris17from utils import prepare_uris
18from utils import rsync_tree18from utils import rsync_tree
19from utils import find
1920
20from confinement.generate import generate_confinement21from confinement.generate import generate_confinement
21sys.path.append('./py')22sys.path.append('./py')
@@ -143,7 +144,12 @@
143 parser.add_argument("--forced-resume", action='store_true',144 parser.add_argument("--forced-resume", action='store_true',
144 help=("Force checkbox to always resume session (and "145 help=("Force checkbox to always resume session (and "
145 "rerun the last test)."))146 "rerun the last test)."))
147 parser.add_argument("--update-potfile", action='store_true',
148 help=("Updates the potfile and quits"))
146 args = parser.parse_args()149 args = parser.parse_args()
150 if args.update_potfile:
151 update_pot()
152 return
147 if args.port and not args.ssh:153 if args.port and not args.ssh:
148 parser.error("--port without --ssh doesn't make sense!")154 parser.error("--port without --ssh doesn't make sense!")
149 return 1155 return 1
@@ -278,10 +284,37 @@
278 if os.path.exists(catalog):284 if os.path.exists(catalog):
279 _update_catalogs(os.path.join('po', lang + '.po'), catalog)285 _update_catalogs(os.path.join('po', lang + '.po'), catalog)
280 # build .mo files286 # build .mo files
287 for po in find(top='./po', include=['*.po']):
288 lang = os.path.splitext(os.path.basename(po))[0]
289 target_dir = 'share/locale/{}/LC_MESSAGES/'.format(lang)
290 target_file = os.path.join(target_dir, 'com.ubuntu.checkbox.mo')
291 if not os.path.exists(target_dir):
292 os.makedirs(target_dir)
293 try:
294 subprocess.check_output(['msgfmt', '-o', target_file, po])
295 except subprocess.CalledProcessError as exc:
296 sys.exit('Error encountered while creating %s translations. %s' % (
297 target_file, exc))
298
299
300def update_pot():
301 potfile = 'po/checkbox-touch.pot'
302 print("Updating {}".format(potfile))
303 py_files = find(top='./py', include=['*.py'])
304 py_files += ['build-me', 'get-libs']
305 qmljs_files = find(include=['*.qml', '*.js'], exclude=['./tests/*'])
281 try:306 try:
282 subprocess.check_output(['make', 'build-translations'])307 subprocess.check_output(
308 ['xgettext', '-o', potfile, '--qt', '--c++',
309 '--add-comments=TRANSLATORS', '--keyword=tr', '--keyword=tr:1,2',
310 '--from-code=UTF-8'] + qmljs_files)
311 subprocess.check_output(
312 ['xgettext', '-o', potfile, '--join-existing',
313 '--add-comments=TRANSLATORS', '--language=python', '--keyword=_',
314 '--keyword=N_'] + py_files)
283 except subprocess.CalledProcessError as exc:315 except subprocess.CalledProcessError as exc:
284 sys.exit('Error encountered while building translations. %s' % exc)316 sys.exit('Error encountered while updating po/checkbox-touch.pot %s' %
317 exc)
285318
286319
287def _update_catalogs(dest, src):320def _update_catalogs(dest, src):
288321
=== modified file 'checkbox-touch/utils.py'
--- checkbox-touch/utils.py 2016-05-31 09:13:09 +0000
+++ checkbox-touch/utils.py 2016-07-11 06:51:05 +0000
@@ -24,6 +24,7 @@
24import apt_pkg24import apt_pkg
25import collections25import collections
26import contextlib26import contextlib
27from fnmatch import fnmatch
27import os28import os
28import shutil29import shutil
29import subprocess30import subprocess
@@ -97,3 +98,14 @@
97 yield98 yield
98 shutil.rmtree(path)99 shutil.rmtree(path)
99 shutil.copytree(target, path)100 shutil.copytree(target, path)
101
102
103def find(top='.', include=['*'], exclude=[]):
104 """Poor man's python simplified imitation of GNU find."""
105 results = []
106 for dirpath, dirnames, filenames in os.walk(top):
107 for f in [os.path.join(dirpath, f) for f in filenames]:
108 if (any(fnmatch(f, i) for i in include) and
109 not any(fnmatch(f, e) for e in exclude)):
110 results.append(f)
111 return results

Subscribers

People subscribed via source and target branches