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
1=== modified file 'checkbox-touch/Makefile'
2--- checkbox-touch/Makefile 2016-07-01 10:05:57 +0000
3+++ checkbox-touch/Makefile 2016-07-11 06:51:05 +0000
4@@ -40,12 +40,20 @@
5 /usr/bin/qmlscene $@ checkbox-touch.qml
6
7 build-translations: $(MO_FILES)
8- echo $(MO_FILES)
9+ @echo "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
10+ @echo "Use of this Makefile for i18n tasks is deprecated"
11+ @echo "./build-me will build translations for you automatically"
12+ @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
13+ @echo $(MO_FILES)
14
15 po:
16 mkdir -p $(CURDIR)/po
17
18 po/checkbox-touch.pot: $(QMLJS_FILES) $(PY_FILES) | po
19+ @echo "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
20+ @echo "Use of this Makefile for i18n tasks is deprecated"
21+ @echo "Use ./build-me --update-potfile instead"
22+ @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
23 xgettext -o po/checkbox-touch.pot --qt --c++ --add-comments=TRANSLATORS --keyword=tr --keyword=tr:1,2 $(QMLJS_FILES) --from-code=UTF-8
24 xgettext -o po/checkbox-touch.pot --join-existing --language=python --add-comments=TRANSLATORS --keyword=_ --keyword=N_ $(PY_FILES)
25
26
27=== modified file 'checkbox-touch/build-me'
28--- checkbox-touch/build-me 2016-06-15 22:31:58 +0000
29+++ checkbox-touch/build-me 2016-07-11 06:51:05 +0000
30@@ -16,6 +16,7 @@
31 from utils import get_package_from_url_and_extract
32 from utils import prepare_uris
33 from utils import rsync_tree
34+from utils import find
35
36 from confinement.generate import generate_confinement
37 sys.path.append('./py')
38@@ -143,7 +144,12 @@
39 parser.add_argument("--forced-resume", action='store_true',
40 help=("Force checkbox to always resume session (and "
41 "rerun the last test)."))
42+ parser.add_argument("--update-potfile", action='store_true',
43+ help=("Updates the potfile and quits"))
44 args = parser.parse_args()
45+ if args.update_potfile:
46+ update_pot()
47+ return
48 if args.port and not args.ssh:
49 parser.error("--port without --ssh doesn't make sense!")
50 return 1
51@@ -278,10 +284,37 @@
52 if os.path.exists(catalog):
53 _update_catalogs(os.path.join('po', lang + '.po'), catalog)
54 # build .mo files
55+ for po in find(top='./po', include=['*.po']):
56+ lang = os.path.splitext(os.path.basename(po))[0]
57+ target_dir = 'share/locale/{}/LC_MESSAGES/'.format(lang)
58+ target_file = os.path.join(target_dir, 'com.ubuntu.checkbox.mo')
59+ if not os.path.exists(target_dir):
60+ os.makedirs(target_dir)
61+ try:
62+ subprocess.check_output(['msgfmt', '-o', target_file, po])
63+ except subprocess.CalledProcessError as exc:
64+ sys.exit('Error encountered while creating %s translations. %s' % (
65+ target_file, exc))
66+
67+
68+def update_pot():
69+ potfile = 'po/checkbox-touch.pot'
70+ print("Updating {}".format(potfile))
71+ py_files = find(top='./py', include=['*.py'])
72+ py_files += ['build-me', 'get-libs']
73+ qmljs_files = find(include=['*.qml', '*.js'], exclude=['./tests/*'])
74 try:
75- subprocess.check_output(['make', 'build-translations'])
76+ subprocess.check_output(
77+ ['xgettext', '-o', potfile, '--qt', '--c++',
78+ '--add-comments=TRANSLATORS', '--keyword=tr', '--keyword=tr:1,2',
79+ '--from-code=UTF-8'] + qmljs_files)
80+ subprocess.check_output(
81+ ['xgettext', '-o', potfile, '--join-existing',
82+ '--add-comments=TRANSLATORS', '--language=python', '--keyword=_',
83+ '--keyword=N_'] + py_files)
84 except subprocess.CalledProcessError as exc:
85- sys.exit('Error encountered while building translations. %s' % exc)
86+ sys.exit('Error encountered while updating po/checkbox-touch.pot %s' %
87+ exc)
88
89
90 def _update_catalogs(dest, src):
91
92=== modified file 'checkbox-touch/utils.py'
93--- checkbox-touch/utils.py 2016-05-31 09:13:09 +0000
94+++ checkbox-touch/utils.py 2016-07-11 06:51:05 +0000
95@@ -24,6 +24,7 @@
96 import apt_pkg
97 import collections
98 import contextlib
99+from fnmatch import fnmatch
100 import os
101 import shutil
102 import subprocess
103@@ -97,3 +98,14 @@
104 yield
105 shutil.rmtree(path)
106 shutil.copytree(target, path)
107+
108+
109+def find(top='.', include=['*'], exclude=[]):
110+ """Poor man's python simplified imitation of GNU find."""
111+ results = []
112+ for dirpath, dirnames, filenames in os.walk(top):
113+ for f in [os.path.join(dirpath, f) for f in filenames]:
114+ if (any(fnmatch(f, i) for i in include) and
115+ not any(fnmatch(f, e) for e in exclude)):
116+ results.append(f)
117+ return results

Subscribers

People subscribed via source and target branches