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
=== modified file 'lib/lp/translations/interfaces/pofile.py'
--- lib/lp/translations/interfaces/pofile.py 2010-05-27 14:38:56 +0000
+++ lib/lp/translations/interfaces/pofile.py 2010-07-22 11:02:44 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4# pylint: disable-msg=E0211,E02134# pylint: disable-msg=E0211,E0213
@@ -147,22 +147,12 @@
147 translations for.147 translations for.
148 """148 """
149149
150 def translated():
151 """
152 Return an iterator over translated message sets in this PO file.
153 """
154
155 def untranslatedCount():150 def untranslatedCount():
156 """151 """
157 Return the number of messages which this PO file has no translation152 Return the number of messages which this PO file has no translation
158 for.153 for.
159 """154 """
160155
161 def untranslated():
162 """
163 Return an iterator over untranslated message sets in this PO file.
164 """
165
166 def getHeader():156 def getHeader():
167 """Return an `ITranslationHeaderData` representing its header."""157 """Return an `ITranslationHeaderData` representing its header."""
168158
169159
=== modified file 'lib/lp/translations/interfaces/translationexporter.py'
--- lib/lp/translations/interfaces/translationexporter.py 2009-07-17 00:26:05 +0000
+++ lib/lp/translations/interfaces/translationexporter.py 2010-07-22 11:02:44 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4# pylint: disable-msg=E0211,E02134# pylint: disable-msg=E0211,E0213
55
=== modified file 'lib/lp/translations/model/pofile.py'
--- lib/lp/translations/model/pofile.py 2010-07-20 18:10:08 +0000
+++ lib/lp/translations/model/pofile.py 2010-07-22 11:02:44 +0000
@@ -605,21 +605,6 @@
605 "Calling prepareTranslationCredits on a message with "605 "Calling prepareTranslationCredits on a message with "
606 "unknown credits type '%s'." % credits_type.title)606 "unknown credits type '%s'." % credits_type.title)
607607
608 def translated(self):
609 """See `IPOFile`."""
610 raise NotImplementedError
611 # return iter(TranslationMessage.select('''
612 # POMsgSet.pofile = %d AND
613 # POMsgSet.iscomplete=TRUE AND
614 # POMsgSet.potmsgset = POTMsgSet.id AND
615 # POTMsgSet.sequence > 0''' % self.id,
616 # clauseTables = ['POMsgSet']
617 # ))
618
619 def untranslated(self):
620 """See `IPOFile`."""
621 raise NotImplementedError
622
623 def _getLanguageVariantClause(self, table='TranslationMessage'):608 def _getLanguageVariantClause(self, table='TranslationMessage'):
624 if self.variant is None:609 if self.variant is None:
625 clause = '%(table)s.variant IS NULL' % dict(table=table)610 clause = '%(table)s.variant IS NULL' % dict(table=table)
@@ -1460,14 +1445,6 @@
1460 """See `IPOFile`."""1445 """See `IPOFile`."""
1461 raise NotImplementedError1446 raise NotImplementedError
14621447
1463 def translated(self):
1464 """See `IPOFile`."""
1465 raise NotImplementedError
1466
1467 def untranslated(self):
1468 """See `IPOFile`."""
1469 raise NotImplementedError
1470
1471 def getStatistics(self):1448 def getStatistics(self):
1472 """See `IPOFile`."""1449 """See `IPOFile`."""
1473 return (0, 0, 0, )1450 return (0, 0, 0, )
@@ -1528,9 +1505,10 @@
1528 assert productseries is None or distroseries is None, (1505 assert productseries is None or distroseries is None, (
1529 'productseries and sourcepackagename/distroseries cannot be used'1506 'productseries and sourcepackagename/distroseries cannot be used'
1530 ' at the same time.')1507 ' at the same time.')
1531 assert ((sourcepackagename is None and distroseries is None) or1508 assert (
1532 (sourcepackagename is not None and distroseries is not None)1509 (sourcepackagename is None and distroseries is None) or
1533 ), ('sourcepackagename and distroseries must be None or not'1510 (sourcepackagename is not None and distroseries is not None)), (
1511 'sourcepackagename and distroseries must be None or not'
1534 ' None at the same time.')1512 ' None at the same time.')
15351513
1536 store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)1514 store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
15371515
=== modified file 'lib/lp/translations/scripts/po_export_queue.py'
--- lib/lp/translations/scripts/po_export_queue.py 2010-03-05 20:40:40 +0000
+++ lib/lp/translations/scripts/po_export_queue.py 2010-07-22 11:02:44 +0000
@@ -176,7 +176,6 @@
176176
177 return export_requested_at177 return export_requested_at
178178
179
180 def _getRequestedExportsNames(self):179 def _getRequestedExportsNames(self):
181 """Return a list of display names for requested exports."""180 """Return a list of display names for requested exports."""
182 requested_names = []181 requested_names = []
@@ -194,8 +193,8 @@
194 template = helpers.get_email_template(193 template = helpers.get_email_template(
195 'poexport-failure.txt', 'translations')194 'poexport-failure.txt', 'translations')
196 return template % {195 return template % {
197 'person' : self.person.displayname,196 'person': self.person.displayname,
198 'request_url' : self.request_url,197 'request_url': self.request_url,
199 }198 }
200199
201 def _getFailedRequestsDescription(self):200 def _getFailedRequestsDescription(self):
@@ -212,15 +211,14 @@
212 def _getAdminFailureNotificationEmailBody(self):211 def _getAdminFailureNotificationEmailBody(self):
213 """Send an email notification about failed export to admins."""212 """Send an email notification about failed export to admins."""
214 template = helpers.get_email_template(213 template = helpers.get_email_template(
215 'poexport-failure-admin-notification.txt',214 'poexport-failure-admin-notification.txt', 'translations')
216 'translations')
217 failed_requests = self._getFailedRequestsDescription()215 failed_requests = self._getFailedRequestsDescription()
218 return template % {216 return template % {
219 'person' : self.person.displayname,217 'person': self.person.displayname,
220 'person_id' : self.person.name,218 'person_id': self.person.name,
221 'request_url' : self.request_url,219 'request_url': self.request_url,
222 'failure_message' : self.failure,220 'failure_message': self.failure,
223 'failed_requests' : failed_requests,221 'failed_requests': failed_requests,
224 }222 }
225223
226 def _getUnicodeDecodeErrorEmailBody(self):224 def _getUnicodeDecodeErrorEmailBody(self):
@@ -230,10 +228,10 @@
230 'translations')228 'translations')
231 failed_requests = self._getFailedRequestsDescription()229 failed_requests = self._getFailedRequestsDescription()
232 return template % {230 return template % {
233 'person' : self.person.displayname,231 'person': self.person.displayname,
234 'person_id' : self.person.name,232 'person_id': self.person.name,
235 'request_url' : self.request_url,233 'request_url': self.request_url,
236 'failed_requests' : failed_requests,234 'failed_requests': failed_requests,
237 }235 }
238236
239 def _getSuccessEmailBody(self):237 def _getSuccessEmailBody(self):
@@ -241,9 +239,9 @@
241 template = helpers.get_email_template(239 template = helpers.get_email_template(
242 'poexport-success.txt', 'translations')240 'poexport-success.txt', 'translations')
243 return template % {241 return template % {
244 'person' : self.person.displayname,242 'person': self.person.displayname,
245 'download_url' : self.url,243 'download_url': self.url,
246 'request_url' : self.request_url,244 'request_url': self.request_url,
247 }245 }
248246
249 def notify(self):247 def notify(self):
250248
=== modified file 'lib/lp/translations/utilities/doc/kde-po-file-format.txt'
--- lib/lp/translations/utilities/doc/kde-po-file-format.txt 2009-07-02 17:16:50 +0000
+++ lib/lp/translations/utilities/doc/kde-po-file-format.txt 2010-07-22 11:02:44 +0000
@@ -127,7 +127,8 @@
127Messages which are preceded with just '_n:' and no space after it are127Messages which are preceded with just '_n:' and no space after it are
128not considered plural forms messages.128not considered plural forms messages.
129129
130 >>> potmsgset = firefox_potemplate.getPOTMsgSetByMsgIDText(u'_n:bar\nbars')130 >>> potmsgset = firefox_potemplate.getPOTMsgSetByMsgIDText(
131 ... u'_n:bar\nbars')
131 >>> print potmsgset.singular_text132 >>> print potmsgset.singular_text
132 _n:bar133 _n:bar
133 bars134 bars
@@ -181,7 +182,8 @@
181 ... msgid "_n: %%d foo\n%%d foos"182 ... msgid "_n: %%d foo\n%%d foos"
182 ... msgstr "%%d translation\n%%d translationes\n%%d translations"183 ... msgstr "%%d translation\n%%d translationes\n%%d translations"
183 ...184 ...
184 ... # Legacy KDE PO files allow multiple messages with same singular msgid.185 ... # Legacy KDE PO files allow multiple messages with the same
186 ... # singular msgid.
185 ... msgid "%%d foo"187 ... msgid "%%d foo"
186 ... msgstr "no-plural translation %%d"188 ... msgstr "no-plural translation %%d"
187 ...189 ...
@@ -193,8 +195,8 @@
193 ... ''' % ISO_FORMATTED_DATE195 ... ''' % ISO_FORMATTED_DATE
194196
195Importing this file succeeds, even if the number of %d printf specifications197Importing this file succeeds, even if the number of %d printf specifications
196doesn't match: this is because this is now specially handled with KDE PO format198doesn't match: this is because this is now specially handled with KDE PO
197support.199format support.
198200
199 >>> entry = import_pofile_or_potemplate(firefox_serbian_pofile_contents,201 >>> entry = import_pofile_or_potemplate(firefox_serbian_pofile_contents,
200 ... carlos,202 ... carlos,
@@ -368,7 +370,8 @@
368 "%d translationes\n"370 "%d translationes\n"
369 "%d translations"371 "%d translations"
370 <BLANKLINE>372 <BLANKLINE>
371 # Legacy KDE PO files allow multiple messages with same singular msgid.373 # Legacy KDE PO files allow multiple messages with the same
374 # singular msgid.
372 #, c-format375 #, c-format
373 msgid "%d foo"376 msgid "%d foo"
374 msgstr "no-plural translation %d"377 msgstr "no-plural translation %d"
375378
=== modified file 'lib/lp/translations/utilities/kde_po_exporter.py'
--- lib/lp/translations/utilities/kde_po_exporter.py 2009-07-17 00:26:05 +0000
+++ lib/lp/translations/utilities/kde_po_exporter.py 2010-07-22 11:02:44 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Export module for KDE legacy .po file format.4"""Export module for KDE legacy .po file format.
@@ -14,7 +14,7 @@
14__metaclass__ = type14__metaclass__ = type
1515
16__all__ = [16__all__ = [
17 'KdePOExporter'17 'KdePOExporter',
18 ]18 ]
1919
20from zope.interface import implements20from zope.interface import implements
2121
=== modified file 'lib/lp/translations/utilities/tests/test_gettext_po_exporter.py'
--- lib/lp/translations/utilities/tests/test_gettext_po_exporter.py 2010-07-21 15:43:25 +0000
+++ lib/lp/translations/utilities/tests/test_gettext_po_exporter.py 2010-07-22 11:02:44 +0000
@@ -45,11 +45,16 @@
45 if (not line.startswith('"X-Launchpad-Export-Date:') and45 if (not line.startswith('"X-Launchpad-Export-Date:') and
46 not line.startswith('"X-Generator: Launchpad'))]46 not line.startswith('"X-Generator: Launchpad'))]
4747
48 for i in range(len(import_lines)):48 line_pairs = zip(export_lines, import_lines)
49 debug_diff = test_diff(import_lines, export_lines)
50 for export_line, import_line in line_pairs:
49 self.assertEqual(51 self.assertEqual(
50 export_lines[i], import_lines[i],52 export_line, import_line,
51 "Output doesn't match:\n\n %s" % test_diff(53 "Output doesn't match:\n\n %s" % debug_diff)
52 import_lines, export_lines))54
55 self.assertEqual(
56 len(export_lines), len(import_lines),
57 "Output has excess lines:\n\n %s" % debug_diff)
5358
54 def testInterface(self):59 def testInterface(self):
55 """Check whether the object follows the interface."""60 """Check whether the object follows the interface."""
5661
=== modified file 'lib/lp/translations/utilities/xpi_po_exporter.py'
--- lib/lp/translations/utilities/xpi_po_exporter.py 2009-07-17 00:26:05 +0000
+++ lib/lp/translations/utilities/xpi_po_exporter.py 2010-07-22 11:02:44 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4# pylint: disable-msg=W02314# pylint: disable-msg=W0231
@@ -7,7 +7,7 @@
7__metaclass__ = type7__metaclass__ = type
88
9__all__ = [9__all__ = [
10 'XPIPOExporter'10 'XPIPOExporter',
11 ]11 ]
1212
13from zope.interface import implements13from zope.interface import implements