~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2012-01-05 15:19:43 UTC
  • mfrom: (14515.4.18 bug-903532)
  • Revision ID: launchpad@pqm.canonical.com-20120105151943-a27wnc0i6x8xv3ex
[r=benji][bug=903532] [r=benji] make POFile statistics update jobs
        also update the stats for related POFiles

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    MAIN_STORE,
35
35
    )
36
36
from lp.translations.interfaces.pofilestatsjob import IPOFileStatsJobSource
 
37
from lp.translations.interfaces.potemplate import IPOTemplateSet
37
38
from lp.translations.model.pofile import POFile
38
39
 
39
40
 
74
75
        logger.info('Updating statistics for %s' % self.pofile.title)
75
76
        self.pofile.updateStatistics()
76
77
 
 
78
        # Next we have to find any POFiles that share translations with the
 
79
        # above POFile so we can update their statistics too.  To do that we
 
80
        # first have to find the set of shared templates.
 
81
        subset = getUtility(IPOTemplateSet).getSharingSubset(
 
82
            product=self.pofile.potemplate.product,
 
83
            distribution=self.pofile.potemplate.distribution,
 
84
            sourcepackagename=self.pofile.potemplate.sourcepackagename)
 
85
        shared_templates = subset.getSharingPOTemplates(
 
86
            self.pofile.potemplate.name)
 
87
        # Now we have to find any POFiles that translate the shared templates
 
88
        # into the same language as the POFile this job is about.
 
89
        for template in shared_templates:
 
90
            pofile = template.getPOFileByLang(self.pofile.language.code)
 
91
            if pofile is None:
 
92
                continue
 
93
            pofile.updateStatistics()
 
94
 
77
95
    @staticmethod
78
96
    def iterReady():
79
97
        """See `IJobSource`."""