root/projects/handlers/types/intltool.py @ 528:25c1783c0111

Revision 528:25c1783c0111, 1.6 KB (checked in by Diego Búrigo Zacarão <diegobz@…>, 17 months ago)

Delete cache and POFiles entries when a file is deleted from upstream

Line 
1from django.conf import settings
2from projects.handlers.types import pot
3from txcommon.log import logger
4from notification import models as notification
5
6class IntltoolHandler(pot.POTHandler):
7    """
8    POTHandler abstraction layer, hense specific to the projects app.
9   
10    You can use this higher-level object to interact with a
11    component's statistics that use intltool instead of meddling with
12    the lower-level POTManager. Each Component object gets one of these
13    as ``component.trans``.
14   
15    """
16
17    def set_stats(self):
18        """
19        Calculate stats for all translations of the component after
20        these tranlations be merged with a new POT file extracted
21        using intltool-update.    .
22        """
23
24        logger.debug("Setting stats for %s" % self.component)
25
26        isIntltooled = self.tm.intltool_update()
27        if not isIntltooled:
28            logger.debug("intltool-update --pot has failed for %s" % 
29                         self.component)
30
31            if settings.ENABLE_NOTICES:
32                notification.send(self.component.project.maintainers.all(),
33                                  'project_component_potfile_error',
34                                  {'component': self.component})
35            is_msgmerged=False
36        else:
37            is_msgmerged=True
38
39        # Set the source file (pot) to the database
40        self.tm.set_source_stats(self.component, is_msgmerged)
41
42        for lang in self.tm.get_langs():
43            self.set_stats_for_lang(lang, is_msgmerged)
44
45        # Cleaning the repository after running intltool-update
46        self.component.unit.browser._clean_dir()
47
48        self.clear_old_stats()
Note: See TracBrowser for help on using the browser.