Merge lp:~vorlon/apt-ddtp-tools/trunk into lp:apt-ddtp-tools

Proposed by Steve Langasek
Status: Needs review
Proposed branch: lp:~vorlon/apt-ddtp-tools/trunk
Merge into: lp:apt-ddtp-tools
Diff against target: 286 lines (+45/-53)
8 files modified
UbuntuChecklist (+11/-9)
po2translation.py (+14/-14)
potmodify.py (+1/-1)
series.sh (+1/-3)
translation2po.py (+8/-8)
ubuntu/packages/ddtp-upload/debian/changelog (+6/-0)
ubuntu/verify-translation-file.py (+3/-3)
utils.py (+1/-15)
To merge this branch: bzr merge lp:~vorlon/apt-ddtp-tools/trunk
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Review via email: mp+441028@code.launchpad.net
To post a comment you must log in.
lp:~vorlon/apt-ddtp-tools/trunk updated
109. By Steve Langasek

Update release codenames to something recent ('lunar' instead of 'lucid'). Point to the option to do a one-time translation import instead of telling people to prod the LP devs.

Unmerged revisions

109. By Steve Langasek

Update release codenames to something recent ('lunar' instead of 'lucid'). Point to the option to do a one-time translation import instead of telling people to prod the LP devs.

108. By Steve Langasek

update for lunar

107. By Steve Langasek

python2->python3

106. By Steve Langasek

apt_pkg: bytes not string

105. By Steve Langasek

python2->python3

104. By Steve Langasek

Spelling

103. By Steve Langasek

bytes vs str vs unicode, python2 vs python3

102. By Steve Langasek

It *says* it only understands strings and files, but it actually only understands bytes

101. By Steve Langasek

python3 whitespace

100. By Steve Langasek

More python2->python3

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UbuntuChecklist'
2--- UbuntuChecklist 2020-04-16 12:01:22 +0000
3+++ UbuntuChecklist 2023-04-14 03:34:28 +0000
4@@ -18,30 +18,32 @@
5 Most data is imported and exported via bzr now, you need the
6 dirs:
7
8-ubuntu/bzr-po-exports/bzr-ddtp-ubuntu-lucid that links to
9-lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-lucid for the exported po files
10+ubuntu/bzr-po-exports/bzr-ddtp-ubuntu-lunar that points to
11+lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-lunar for the exported po files
12
13-ubuntu/bzr-pot-imports/bzr-ddtp-pot-lucid that links to
14-lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-pot-lucid for the pot files that LP
15+ubuntu/bzr-pot-imports/bzr-ddtp-pot-lunar that points to
16+lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-pot-lunar for the pot files that LP
17 will import from you
18
19
20 == Opening a new series (for a new ubuntu release) ==
21
22 Go to https://launchpad.net/ddtp-ubuntu/+addseries and add something
23-like: "natty", "The translations for Ubuntu 11.04 'natty'".
24+like: "lunar", "The translations for Ubuntu 23.04 'lunar'".
25
26 Go to
27-https://translations.launchpad.net/ddtp-ubuntu/natty/+translations-settings
28-and select target branch like "lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-natty" and
29+https://translations.launchpad.net/ddtp-ubuntu/lunar/+translations-settings
30+and select target branch like "lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-lunar" and
31 make sure to set the syncronisation settings to import "pot and
32 translations".
33
34-Upload pot files and wait/prod LP devs to import them.
35+Push your branch containing the pot files and then request a one-time
36+translation import at
37+https://translations.launchpad.net/ddtp-ubuntu/lunar/+request-bzr-import
38
39 == Support for alternative series ==
40
41-If a update is needed for a alternative series (like "lucid"),
42+If an update is needed for an alternative series (like "kinetic"),
43 you need to alter the file "series.sh". Then everything should
44 work magically.
45
46
47=== modified file 'po2translation.py'
48--- po2translation.py 2020-04-16 12:01:22 +0000
49+++ po2translation.py 2023-04-14 03:34:28 +0000
50@@ -1,4 +1,4 @@
51-#!/usr/bin/python2
52+#!/usr/bin/python3
53
54 import apt_pkg
55 import gettext
56@@ -29,13 +29,13 @@
57 have_translation=False
58 try:
59 (short_descr, long_descr_chunks) = parse_descr(descr)
60- except UnicodeDecodeError, e:
61+ except UnicodeDecodeError as e:
62 logging.warn("decoding of '%s' failed, ignoring (not utf8?)" % descr)
63 return ""
64
65 # we need it as a unicode type so that twrap later works correctly
66 # FIXME: use ugettext() instead
67- short_descr_trans = utf8_str_to_unicode_type(translation.gettext(short_descr))
68+ short_descr_trans = translation.gettext(short_descr)
69 if short_descr_trans is None:
70 logging.debug("Found empty translation chunk for '%s'" % pkg)
71 # we have no translation for this chunk
72@@ -50,12 +50,12 @@
73 if chunk == "":
74 chunk_translated = ""
75 else:
76- chunk_translated = utf8_str_to_unicode_type(translation.gettext(chunk))
77+ chunk_translated = translation.gettext(chunk)
78 # *sigh* more hacks, the theory is that a test
79 # like if chunk.count("\n") > 1 means we need
80 # to strip away the final newline
81 if not chunk_translated:
82- chunk_translated = utf8_str_to_unicode_type(translation.gettext(chunk[:-1]))
83+ chunk_translated = translation.gettext(chunk[:-1])
84
85 # check if we only do full translation records
86 if not chunk_translated:
87@@ -77,7 +77,7 @@
88 # build a Translation package record
89 res = ""
90 res = "Package: %s\n" % pkg
91- res += "Description-md5: %s\n" % str(apt_pkg.md5sum(descr+"\n"))
92+ res += "Description-md5: %s\n" % str(apt_pkg.md5sum(descr.encode()+b"\n"))
93 res += "Description-%s: %s\n" % (lang, short_descr_trans)
94 long_descr_str = ""
95 for chunk in long_descr_chunks_trans:
96@@ -102,7 +102,7 @@
97 long_descr_str += "\n .\n%s" % chunk
98 res += "%s\n\n" % long_descr_str
99 # convert back to a utf8 encoded string
100- return unicode_type_to_utf8_str(res)
101+ return res
102
103 def po2translation(inf, out, pofile, lang, fulltrans=False):
104 if not os.path.exists("mo/%s/LC_MESSAGES" % lang):
105@@ -112,7 +112,7 @@
106 localedir= os.getcwd()+"/mo"
107 translation = gettext.translation('packages', localedir, [lang])
108 if not translation:
109- print "Error creating translation object"
110+ print("Error creating translation object")
111 sys.exit(1)
112 translation.add_fallback(NoneTranslationFallback())
113
114@@ -132,13 +132,13 @@
115
116
117 if __name__ == "__main__":
118- logging.basicConfig(level=logging.INFO,
119- format="%(asctime)s %(message)s")
120+ logging.basicConfig(level=logging.INFO,
121+ format="%(asctime)s %(message)s")
122
123 if len(sys.argv) < 4:
124- print "need a Packages file a po file and a language as argument"
125- print "it will search for the mo file in "
126- print "mo/$lang/LC_MESSAGES/packages.mo"
127+ print("need a Packages file a po file and a language as argument")
128+ print("it will search for the mo file in ")
129+ print("mo/$lang/LC_MESSAGES/packages.mo")
130 sys.exit(1)
131
132 inf = open(sys.argv[1])
133@@ -154,5 +154,5 @@
134 logging.error("Can't find '%s', exiting" % pofile)
135 sys.exit(1)
136
137- logging.debug("working on %s" % pofile)
138+ logging.debug("working on %s" % pofile)
139 po2translation(inf, out, pofile, lang, fulltrans)
140
141=== modified file 'potmodify.py'
142--- potmodify.py 2020-04-16 12:01:22 +0000
143+++ potmodify.py 2023-04-14 03:34:28 +0000
144@@ -1,4 +1,4 @@
145-#! /usr/bin/python2
146+#! /usr/bin/python3
147 # -*- coding: utf-8 -*-
148 #
149 # Copyright (C) 2008 István Nyitrai <sianis@gmail.com>
150
151=== modified file 'series.sh'
152--- series.sh 2020-04-16 12:01:22 +0000
153+++ series.sh 2023-04-14 03:34:28 +0000
154@@ -1,7 +1,5 @@
155
156 # the series to use (default auto-detect)
157-#SERIES=$(lsb_release -s -c)
158-SERIES="focal"
159+SERIES="$(distro-info -d)"
160
161 DIST="$SERIES"
162-
163
164=== modified file 'translation2po.py'
165--- translation2po.py 2020-04-16 12:01:22 +0000
166+++ translation2po.py 2023-04-14 03:34:28 +0000
167@@ -1,4 +1,4 @@
168-#!/usr/bin/python2
169+#!/usr/bin/python3
170
171 import string
172 import apt_pkg
173@@ -110,7 +110,7 @@
174 "Content-Transfer-Encoding: 8bit\\n"
175 \n
176 """)
177- all_chunks = set()
178+ all_chunks = set()
179 parser = apt_pkg.TagFile(inf)
180 parser_trans = apt_pkg.TagFile(open(transf))
181 while parser.step():
182@@ -122,13 +122,13 @@
183 # we have a descr for that pkg
184 if descr != None and descr_trans != None:
185 md5_trans = parser_trans.section.get("Description-md5")
186- md5 = str(apt_pkg.md5sum(descr+"\n"))
187+ md5 = str(apt_pkg.md5sum(descr.encode()+b"\n"))
188 #print "'%s'" % descr
189 #print "'%s'" % descr_trans
190 #print "md5: %s -> trans: %s " % (md5, md5_trans)
191 if md5 == md5_trans:
192 res = descr_to_po(pkg, descr, descr_trans, all_chunks)
193- out.write(res.encode('utf-8'))
194+ out.write(res)
195
196
197 if __name__ == "__main__":
198@@ -136,10 +136,10 @@
199 #sys.exit(1)
200
201 if len(sys.argv) < 4:
202- print "%s Packages Translation lang" % sys.argv[0]
203- print "need a Packages file and a Translation-$LANG file "
204- print "and a lang (e.g. Packages Translation-de de) "
205- print " it will generate a po file from that"
206+ print("%s Packages Translation lang" % sys.argv[0])
207+ print("need a Packages file and a Translation-$LANG file ")
208+ print("and a lang (e.g. Packages Translation-de de) ")
209+ print(" it will generate a po file from that")
210 sys.exit(1)
211
212 inf = open(sys.argv[1])
213
214=== modified file 'ubuntu/packages/ddtp-upload/debian/changelog'
215--- ubuntu/packages/ddtp-upload/debian/changelog 2020-04-16 12:01:22 +0000
216+++ ubuntu/packages/ddtp-upload/debian/changelog 2023-04-14 03:34:28 +0000
217@@ -1,3 +1,9 @@
218+ddtp-translations (20230413.1) lunar; urgency=medium
219+
220+ * new translations update
221+
222+ -- Steve Langasek <steve.langasek@ubuntu.com> Thu, 13 Apr 2023 19:13:28 -0700
223+
224 ddtp-translations (20200110.1) focal; urgency=medium
225
226 * new translations update
227
228=== modified file 'ubuntu/verify-translation-file.py'
229--- ubuntu/verify-translation-file.py 2020-04-16 12:01:22 +0000
230+++ ubuntu/verify-translation-file.py 2023-04-14 03:34:28 +0000
231@@ -1,4 +1,4 @@
232-#!/usr/bin/python2
233+#!/usr/bin/python3
234
235 import apt_pkg
236 import sys
237@@ -13,8 +13,8 @@
238 tf.section.get("Package") and
239 tf.section.get("Description-md5") and
240 tf.section.get("Description-%s" % locale)):
241- print "Invalid: '%s'" % tf.section
242- print
243+ print("Invalid: '%s'" % tf.section)
244+ print()
245 bad = True
246 break
247
248
249=== modified file 'utils.py'
250--- utils.py 2020-04-16 12:01:22 +0000
251+++ utils.py 2023-04-14 03:34:28 +0000
252@@ -8,18 +8,6 @@
253 return string.encode('utf-8')
254 return unicode(string, 'latin1').encode('utf-8')
255
256-def utf8_str_to_unicode_type(s):
257- """ take a utf8 encoded str and return a unicode object """
258- if not s:
259- return s
260- return s.decode('utf-8')
261-
262-def unicode_type_to_utf8_str(u):
263- """ take a unicode object and return a utf8 encoded str object """
264- if not u:
265- return u
266- return u.encode('utf-8')
267-
268 def parse_descr(descr):
269 """ input. debian description (str)
270 output (short_descr: (str), long_descr_chunks: (list of str)
271@@ -34,7 +22,6 @@
272 short_descr = raw.strip()
273 # new chunk
274 elif raw.strip() == ".":
275- current = utf8_str_to_unicode_type(current)
276 long_descr_chunks.append(current)
277 current = ""
278 # two spaces is handled differently (as a raw format, see debian policy)
279@@ -57,9 +44,8 @@
280 else:
281 current = raw.strip()
282 # add last chunk
283- current = utf8_str_to_unicode_type(current)
284 long_descr_chunks.append(current)
285- return (utf8_str_to_unicode_type(short_descr), long_descr_chunks)
286+ return (short_descr, long_descr_chunks)
287
288
289

Subscribers

People subscribed via source and target branches

to all changes: