Merge lp:~jtv/launchpad/pre-export-cleanup into lp:launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Leonard Richardson
Approved revision: no longer in the source branch.
Merged at revision: 11180
Proposed branch: lp:~jtv/launchpad/pre-export-cleanup
Merge into: lp:launchpad
Diff against target: 141 lines (+15/-17)
2 files modified
lib/lp/translations/model/pofile.py (+13/-14)
lib/lp/translations/model/potemplate.py (+2/-3)
To merge this branch: bzr merge lp:~jtv/launchpad/pre-export-cleanup
Reviewer Review Type Date Requested Status
Leonard Richardson (community) code Approve
Review via email: mp+30445@code.launchpad.net

Commit message

POFile/POTemplate lint cleanup.

Description of the change

Just cleaning up a bit of lint so it doesn't pollute a more serious branch I have in progress. No tests affected etc.

Jeroen

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

+1

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/translations/model/pofile.py'
--- lib/lp/translations/model/pofile.py 2010-04-23 14:46:43 +0000
+++ lib/lp/translations/model/pofile.py 2010-07-20 18:22:42 +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=E0611,W0212,W02314# pylint: disable-msg=E0611,W0212,W0231
@@ -17,8 +17,7 @@
17import datetime17import datetime
18import pytz18import pytz
19from sqlobject import (19from sqlobject import (
20 ForeignKey, IntCol, StringCol, BoolCol, SQLMultipleJoin20 ForeignKey, IntCol, StringCol, BoolCol, SQLMultipleJoin)
21 )
22from zope.interface import implements21from zope.interface import implements
23from zope.component import getAdapter, getUtility22from zope.component import getAdapter, getUtility
24from zope.security.proxy import removeSecurityProxy23from zope.security.proxy import removeSecurityProxy
@@ -132,6 +131,7 @@
132 else:131 else:
133 return False132 return False
134133
134
135def _can_edit_translations(pofile, person):135def _can_edit_translations(pofile, person):
136 """Say if a person is able to edit existing translations.136 """Say if a person is able to edit existing translations.
137137
@@ -182,6 +182,7 @@
182 translators,182 translators,
183 person) or person.inTeam(pofile.owner)183 person) or person.inTeam(pofile.owner)
184184
185
185def _can_add_suggestions(pofile, person):186def _can_add_suggestions(pofile, person):
186 """Whether a person is able to add suggestions.187 """Whether a person is able to add suggestions.
187188
@@ -316,7 +317,6 @@
316 text=quote_like(text))317 text=quote_like(text))
317 return translation_match318 return translation_match
318319
319
320 def _getTemplateSearchQuery(self, text):320 def _getTemplateSearchQuery(self, text):
321 """Query for finding `text` in msgids of this POFile.321 """Query for finding `text` in msgids of this POFile.
322 """322 """
@@ -570,7 +570,7 @@
570 return u','.join(emails)570 return u','.join(emails)
571 elif credits_type == TranslationCreditsType.KDE_NAMES:571 elif credits_type == TranslationCreditsType.KDE_NAMES:
572 names = []572 names = []
573 573
574 if text is not None:574 if text is not None:
575 if text == u'':575 if text == u'':
576 text = SPACE576 text = SPACE
@@ -593,7 +593,7 @@
593 text = text[:header_index]593 text = text[:header_index]
594 else:594 else:
595 text += u'\n\n'595 text += u'\n\n'
596 596
597 text += LP_CREDIT_HEADER597 text += LP_CREDIT_HEADER
598 for contributor in self.contributors:598 for contributor in self.contributors:
599 text += ("\n %s %s" %599 text += ("\n %s %s" %
@@ -711,7 +711,6 @@
711 clause_tables.insert(0, POTMsgSet)711 clause_tables.insert(0, POTMsgSet)
712 return self._getOrderedPOTMsgSets(clause_tables, query)712 return self._getOrderedPOTMsgSets(clause_tables, query)
713713
714
715 def getPOTMsgSetUntranslated(self):714 def getPOTMsgSetUntranslated(self):
716 """See `IPOFile`."""715 """See `IPOFile`."""
717 # We get all POTMsgSet.ids with translations, and later716 # We get all POTMsgSet.ids with translations, and later
@@ -747,12 +746,12 @@
747 def getPOTMsgSetWithNewSuggestions(self):746 def getPOTMsgSetWithNewSuggestions(self):
748 """See `IPOFile`."""747 """See `IPOFile`."""
749 clauses = self._getClausesForPOFileMessages()748 clauses = self._getClausesForPOFileMessages()
750 msgstr_clause = make_plurals_sql_fragment(749 msgstr_clause = make_plurals_sql_fragment(
751 "TranslationMessage.msgstr%(form)d IS NOT NULL", "OR")750 "TranslationMessage.msgstr%(form)d IS NOT NULL", "OR")
752 clauses.extend([751 clauses.extend([
753 'TranslationTemplateItem.potmsgset = POTMsgSet.id',752 'TranslationTemplateItem.potmsgset = POTMsgSet.id',
754 'TranslationMessage.is_current IS NOT TRUE',753 'TranslationMessage.is_current IS NOT TRUE',
755 "(%s)" % msgstr_clause754 "(%s)" % msgstr_clause,
756 ])755 ])
757756
758 variant_clause = self._getLanguageVariantClause(table='diverged')757 variant_clause = self._getLanguageVariantClause(table='diverged')
@@ -908,12 +907,12 @@
908 conditions.907 conditions.
909 """908 """
910 query.append('%(table_name)s.msgstr0 IS NOT NULL' % {909 query.append('%(table_name)s.msgstr0 IS NOT NULL' % {
911 'table_name' : table_name})910 'table_name': table_name})
912 if self.language.pluralforms > 1:911 if self.language.pluralforms > 1:
913 plurals_query = ' AND '.join(912 plurals_query = ' AND '.join(
914 '%(table_name)s.msgstr%(plural_form)d IS NOT NULL' % {913 '%(table_name)s.msgstr%(plural_form)d IS NOT NULL' % {
915 'plural_form' : plural_form,914 'plural_form': plural_form,
916 'table_name' : table_name915 'table_name': table_name,
917 } for plural_form in range(1, self.plural_forms))916 } for plural_form in range(1, self.plural_forms))
918 query.append(917 query.append(
919 '(POTMsgSet.msgid_plural IS NULL OR (%s))' % plurals_query)918 '(POTMsgSet.msgid_plural IS NULL OR (%s))' % plurals_query)
@@ -1329,7 +1328,7 @@
1329 self.fuzzyheader = False1328 self.fuzzyheader = False
1330 self.lasttranslator = None1329 self.lasttranslator = None
1331 UTC = pytz.timezone('UTC')1330 UTC = pytz.timezone('UTC')
1332 self.date_changed = None1331 self.date_changed = None
1333 self.lastparsed = None1332 self.lastparsed = None
1334 self.owner = getUtility(ILaunchpadCelebrities).rosetta_experts1333 self.owner = getUtility(ILaunchpadCelebrities).rosetta_experts
13351334
@@ -1663,7 +1662,7 @@
1663 And(MatchingPOT.productseriesID is not None,1662 And(MatchingPOT.productseriesID is not None,
1664 OtherPOT.productseriesID is not None,1663 OtherPOT.productseriesID is not None,
1665 (MatchingProductSeries.productID ==1664 (MatchingProductSeries.productID ==
1666 OtherProductSeries.productID)) )))1665 OtherProductSeries.productID)))))
1667 results.config(distinct=True)1666 results.config(distinct=True)
1668 return results1667 return results
16691668
16701669
=== modified file 'lib/lp/translations/model/potemplate.py'
--- lib/lp/translations/model/potemplate.py 2010-07-20 12:33:43 +0000
+++ lib/lp/translations/model/potemplate.py 2010-07-20 18:22:42 +0000
@@ -461,8 +461,7 @@
461 "POFile.potemplate = %d AND "461 "POFile.potemplate = %d AND "
462 "POFile.variant IS NULL" % self.id,462 "POFile.variant IS NULL" % self.id,
463 clauseTables=['POFile', 'Language'],463 clauseTables=['POFile', 'Language'],
464 distinct=True,464 distinct=True)
465 )
466465
467 def getPOFileByPath(self, path):466 def getPOFileByPath(self, path):
468 """See `IPOTemplate`."""467 """See `IPOTemplate`."""
@@ -573,7 +572,7 @@
573 product = self.productseries.product572 product = self.productseries.product
574 clauses.extend([573 clauses.extend([
575 'POTemplate.productseries=ProductSeries.id',574 'POTemplate.productseries=ProductSeries.id',
576 'ProductSeries.product %s' % self._null_quote(product)575 'ProductSeries.product %s' % self._null_quote(product),
577 ])576 ])
578 clause_tables.append('ProductSeries')577 clause_tables.append('ProductSeries')
579 elif self.distroseries is not None:578 elif self.distroseries is not None: