~al-maisan/launchpad/ejdt-484819

« back to all changes in this revision

Viewing changes to lib/lp/translations/model/pofile.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2009-12-09 10:35:54 UTC
  • mfrom: (10005.1.3 bug-494106)
  • Revision ID: launchpad@pqm.canonical.com-20091209103554-wka7qhp6tzftjtzt
[r=bac][ui=none][bug=494106] Improve behaviour of
        fix_translation_credits script when killing and restarting so
        it works faster and picks up where it left off.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
from lp.translations.utilities.translation_common_format import (
71
71
    TranslationMessageData)
72
72
 
73
 
from storm.expr import And, In, Join, LeftJoin, Or, SQL
 
73
from storm.expr import And, Exists, In, Join, LeftJoin, Not, Or, Select, SQL
74
74
from storm.info import ClassAlias
75
75
from storm.store import Store
76
76
 
1576
1576
        return POFile.select(
1577
1577
            "id >= %s" % quote(starting_id), orderBy="id", limit=batch_size)
1578
1578
 
1579
 
    def getPOFilesWithTranslationCredits(self):
 
1579
    def getPOFilesWithTranslationCredits(self, untranslated=False):
1580
1580
        """See `IPOFileSet`."""
1581
1581
        store = getUtility(IStoreSelector).get(MAIN_STORE, MASTER_FLAVOR)
1582
 
        result = store.find(
1583
 
                (POFile, POTMsgSet),
1584
 
                TranslationTemplateItem.potemplateID == POFile.potemplateID,
1585
 
                POTMsgSet.id == TranslationTemplateItem.potmsgsetID,
1586
 
                POTMsgSet.msgid_singular == POMsgID.id,
1587
 
                In(POMsgID.msgid, POTMsgSet.credits_message_ids))
 
1582
        clauses = [
 
1583
            TranslationTemplateItem.potemplateID == POFile.potemplateID,
 
1584
            POTMsgSet.id == TranslationTemplateItem.potmsgsetID,
 
1585
            POTMsgSet.msgid_singular == POMsgID.id,
 
1586
            In(POMsgID.msgid, POTMsgSet.credits_message_ids)]
 
1587
        if untranslated:
 
1588
            message_select = Select(
 
1589
                True,
 
1590
                And(
 
1591
                    TranslationMessage.potmsgsetID == POTMsgSet.id,
 
1592
                    TranslationMessage.potemplate == None,
 
1593
                    POFile.languageID == TranslationMessage.languageID,
 
1594
                    Or(And(
 
1595
                        POFile.variant == None,
 
1596
                        TranslationMessage.variant == None),
 
1597
                       POFile.variant == TranslationMessage.variant),
 
1598
                    TranslationMessage.is_current == True),
 
1599
                (TranslationMessage))
 
1600
            clauses.append(Not(Exists(message_select)))
 
1601
        result = store.find((POFile, POTMsgSet), clauses)
1588
1602
        return result.order_by('POFile.id')
1589
1603
 
1590
1604
    def getPOFilesTouchedSince(self, date):