Merge lp:~jtv/launchpad/translations-lint into lp:launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 11206
Proposed branch: lp:~jtv/launchpad/translations-lint
Merge into: lp:launchpad
Diff against target: 278 lines (+42/-68)
8 files modified
lib/lp/translations/interfaces/pofile.py (+1/-11)
lib/lp/translations/interfaces/translationexporter.py (+1/-1)
lib/lp/translations/model/pofile.py (+4/-26)
lib/lp/translations/scripts/po_export_queue.py (+15/-17)
lib/lp/translations/utilities/doc/kde-po-file-format.txt (+8/-5)
lib/lp/translations/utilities/kde_po_exporter.py (+2/-2)
lib/lp/translations/utilities/tests/test_gettext_po_exporter.py (+9/-4)
lib/lp/translations/utilities/xpi_po_exporter.py (+2/-2)
To merge this branch: bzr merge lp:~jtv/launchpad/translations-lint
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) code Approve
Review via email: mp+30633@code.launchpad.net

Commit message

Translations lint.

Description of the change

= Translations lint =

Cleans up bits of lint and general non-prettiness that were in the way of another branch.

Jeroen

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve (code)
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Dankjewel. :-)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/interfaces/pofile.py'
2--- lib/lp/translations/interfaces/pofile.py 2010-05-27 14:38:56 +0000
3+++ lib/lp/translations/interfaces/pofile.py 2010-07-22 11:02:44 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 # pylint: disable-msg=E0211,E0213
10@@ -147,22 +147,12 @@
11 translations for.
12 """
13
14- def translated():
15- """
16- Return an iterator over translated message sets in this PO file.
17- """
18-
19 def untranslatedCount():
20 """
21 Return the number of messages which this PO file has no translation
22 for.
23 """
24
25- def untranslated():
26- """
27- Return an iterator over untranslated message sets in this PO file.
28- """
29-
30 def getHeader():
31 """Return an `ITranslationHeaderData` representing its header."""
32
33
34=== modified file 'lib/lp/translations/interfaces/translationexporter.py'
35--- lib/lp/translations/interfaces/translationexporter.py 2009-07-17 00:26:05 +0000
36+++ lib/lp/translations/interfaces/translationexporter.py 2010-07-22 11:02:44 +0000
37@@ -1,4 +1,4 @@
38-# Copyright 2009 Canonical Ltd. This software is licensed under the
39+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
40 # GNU Affero General Public License version 3 (see the file LICENSE).
41
42 # pylint: disable-msg=E0211,E0213
43
44=== modified file 'lib/lp/translations/model/pofile.py'
45--- lib/lp/translations/model/pofile.py 2010-07-20 18:10:08 +0000
46+++ lib/lp/translations/model/pofile.py 2010-07-22 11:02:44 +0000
47@@ -605,21 +605,6 @@
48 "Calling prepareTranslationCredits on a message with "
49 "unknown credits type '%s'." % credits_type.title)
50
51- def translated(self):
52- """See `IPOFile`."""
53- raise NotImplementedError
54- # return iter(TranslationMessage.select('''
55- # POMsgSet.pofile = %d AND
56- # POMsgSet.iscomplete=TRUE AND
57- # POMsgSet.potmsgset = POTMsgSet.id AND
58- # POTMsgSet.sequence > 0''' % self.id,
59- # clauseTables = ['POMsgSet']
60- # ))
61-
62- def untranslated(self):
63- """See `IPOFile`."""
64- raise NotImplementedError
65-
66 def _getLanguageVariantClause(self, table='TranslationMessage'):
67 if self.variant is None:
68 clause = '%(table)s.variant IS NULL' % dict(table=table)
69@@ -1460,14 +1445,6 @@
70 """See `IPOFile`."""
71 raise NotImplementedError
72
73- def translated(self):
74- """See `IPOFile`."""
75- raise NotImplementedError
76-
77- def untranslated(self):
78- """See `IPOFile`."""
79- raise NotImplementedError
80-
81 def getStatistics(self):
82 """See `IPOFile`."""
83 return (0, 0, 0, )
84@@ -1528,9 +1505,10 @@
85 assert productseries is None or distroseries is None, (
86 'productseries and sourcepackagename/distroseries cannot be used'
87 ' at the same time.')
88- assert ((sourcepackagename is None and distroseries is None) or
89- (sourcepackagename is not None and distroseries is not None)
90- ), ('sourcepackagename and distroseries must be None or not'
91+ assert (
92+ (sourcepackagename is None and distroseries is None) or
93+ (sourcepackagename is not None and distroseries is not None)), (
94+ 'sourcepackagename and distroseries must be None or not'
95 ' None at the same time.')
96
97 store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
98
99=== modified file 'lib/lp/translations/scripts/po_export_queue.py'
100--- lib/lp/translations/scripts/po_export_queue.py 2010-03-05 20:40:40 +0000
101+++ lib/lp/translations/scripts/po_export_queue.py 2010-07-22 11:02:44 +0000
102@@ -176,7 +176,6 @@
103
104 return export_requested_at
105
106-
107 def _getRequestedExportsNames(self):
108 """Return a list of display names for requested exports."""
109 requested_names = []
110@@ -194,8 +193,8 @@
111 template = helpers.get_email_template(
112 'poexport-failure.txt', 'translations')
113 return template % {
114- 'person' : self.person.displayname,
115- 'request_url' : self.request_url,
116+ 'person': self.person.displayname,
117+ 'request_url': self.request_url,
118 }
119
120 def _getFailedRequestsDescription(self):
121@@ -212,15 +211,14 @@
122 def _getAdminFailureNotificationEmailBody(self):
123 """Send an email notification about failed export to admins."""
124 template = helpers.get_email_template(
125- 'poexport-failure-admin-notification.txt',
126- 'translations')
127+ 'poexport-failure-admin-notification.txt', 'translations')
128 failed_requests = self._getFailedRequestsDescription()
129 return template % {
130- 'person' : self.person.displayname,
131- 'person_id' : self.person.name,
132- 'request_url' : self.request_url,
133- 'failure_message' : self.failure,
134- 'failed_requests' : failed_requests,
135+ 'person': self.person.displayname,
136+ 'person_id': self.person.name,
137+ 'request_url': self.request_url,
138+ 'failure_message': self.failure,
139+ 'failed_requests': failed_requests,
140 }
141
142 def _getUnicodeDecodeErrorEmailBody(self):
143@@ -230,10 +228,10 @@
144 'translations')
145 failed_requests = self._getFailedRequestsDescription()
146 return template % {
147- 'person' : self.person.displayname,
148- 'person_id' : self.person.name,
149- 'request_url' : self.request_url,
150- 'failed_requests' : failed_requests,
151+ 'person': self.person.displayname,
152+ 'person_id': self.person.name,
153+ 'request_url': self.request_url,
154+ 'failed_requests': failed_requests,
155 }
156
157 def _getSuccessEmailBody(self):
158@@ -241,9 +239,9 @@
159 template = helpers.get_email_template(
160 'poexport-success.txt', 'translations')
161 return template % {
162- 'person' : self.person.displayname,
163- 'download_url' : self.url,
164- 'request_url' : self.request_url,
165+ 'person': self.person.displayname,
166+ 'download_url': self.url,
167+ 'request_url': self.request_url,
168 }
169
170 def notify(self):
171
172=== modified file 'lib/lp/translations/utilities/doc/kde-po-file-format.txt'
173--- lib/lp/translations/utilities/doc/kde-po-file-format.txt 2009-07-02 17:16:50 +0000
174+++ lib/lp/translations/utilities/doc/kde-po-file-format.txt 2010-07-22 11:02:44 +0000
175@@ -127,7 +127,8 @@
176 Messages which are preceded with just '_n:' and no space after it are
177 not considered plural forms messages.
178
179- >>> potmsgset = firefox_potemplate.getPOTMsgSetByMsgIDText(u'_n:bar\nbars')
180+ >>> potmsgset = firefox_potemplate.getPOTMsgSetByMsgIDText(
181+ ... u'_n:bar\nbars')
182 >>> print potmsgset.singular_text
183 _n:bar
184 bars
185@@ -181,7 +182,8 @@
186 ... msgid "_n: %%d foo\n%%d foos"
187 ... msgstr "%%d translation\n%%d translationes\n%%d translations"
188 ...
189- ... # Legacy KDE PO files allow multiple messages with same singular msgid.
190+ ... # Legacy KDE PO files allow multiple messages with the same
191+ ... # singular msgid.
192 ... msgid "%%d foo"
193 ... msgstr "no-plural translation %%d"
194 ...
195@@ -193,8 +195,8 @@
196 ... ''' % ISO_FORMATTED_DATE
197
198 Importing this file succeeds, even if the number of %d printf specifications
199-doesn't match: this is because this is now specially handled with KDE PO format
200-support.
201+doesn't match: this is because this is now specially handled with KDE PO
202+format support.
203
204 >>> entry = import_pofile_or_potemplate(firefox_serbian_pofile_contents,
205 ... carlos,
206@@ -368,7 +370,8 @@
207 "%d translationes\n"
208 "%d translations"
209 <BLANKLINE>
210- # Legacy KDE PO files allow multiple messages with same singular msgid.
211+ # Legacy KDE PO files allow multiple messages with the same
212+ # singular msgid.
213 #, c-format
214 msgid "%d foo"
215 msgstr "no-plural translation %d"
216
217=== modified file 'lib/lp/translations/utilities/kde_po_exporter.py'
218--- lib/lp/translations/utilities/kde_po_exporter.py 2009-07-17 00:26:05 +0000
219+++ lib/lp/translations/utilities/kde_po_exporter.py 2010-07-22 11:02:44 +0000
220@@ -1,4 +1,4 @@
221-# Copyright 2009 Canonical Ltd. This software is licensed under the
222+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
223 # GNU Affero General Public License version 3 (see the file LICENSE).
224
225 """Export module for KDE legacy .po file format.
226@@ -14,7 +14,7 @@
227 __metaclass__ = type
228
229 __all__ = [
230- 'KdePOExporter'
231+ 'KdePOExporter',
232 ]
233
234 from zope.interface import implements
235
236=== modified file 'lib/lp/translations/utilities/tests/test_gettext_po_exporter.py'
237--- lib/lp/translations/utilities/tests/test_gettext_po_exporter.py 2010-07-21 15:43:25 +0000
238+++ lib/lp/translations/utilities/tests/test_gettext_po_exporter.py 2010-07-22 11:02:44 +0000
239@@ -45,11 +45,16 @@
240 if (not line.startswith('"X-Launchpad-Export-Date:') and
241 not line.startswith('"X-Generator: Launchpad'))]
242
243- for i in range(len(import_lines)):
244+ line_pairs = zip(export_lines, import_lines)
245+ debug_diff = test_diff(import_lines, export_lines)
246+ for export_line, import_line in line_pairs:
247 self.assertEqual(
248- export_lines[i], import_lines[i],
249- "Output doesn't match:\n\n %s" % test_diff(
250- import_lines, export_lines))
251+ export_line, import_line,
252+ "Output doesn't match:\n\n %s" % debug_diff)
253+
254+ self.assertEqual(
255+ len(export_lines), len(import_lines),
256+ "Output has excess lines:\n\n %s" % debug_diff)
257
258 def testInterface(self):
259 """Check whether the object follows the interface."""
260
261=== modified file 'lib/lp/translations/utilities/xpi_po_exporter.py'
262--- lib/lp/translations/utilities/xpi_po_exporter.py 2009-07-17 00:26:05 +0000
263+++ lib/lp/translations/utilities/xpi_po_exporter.py 2010-07-22 11:02:44 +0000
264@@ -1,4 +1,4 @@
265-# Copyright 2009 Canonical Ltd. This software is licensed under the
266+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
267 # GNU Affero General Public License version 3 (see the file LICENSE).
268
269 # pylint: disable-msg=W0231
270@@ -7,7 +7,7 @@
271 __metaclass__ = type
272
273 __all__ = [
274- 'XPIPOExporter'
275+ 'XPIPOExporter',
276 ]
277
278 from zope.interface import implements