~barry/ubuntu/natty/python-distutils-extra/670188-ftbfs

« back to all changes in this revision

Viewing changes to DistUtilsExtra/command/build_i18n.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-01 16:39:54 UTC
  • mfrom: (1.1.13 karmic)
  • Revision ID: james.westby@ubuntu.com-20090701163954-3ewvhmu8l9oci2w9
Tags: 2.3
* auto.py: Fix recognition of GtkBuilder *.ui files as glade-3 writes them.
* auto.py: Add automatic calculation of "requires" unless explicitly given.
* auto.py: Add automatic calculation of "provides" unless explicitly given.
* Drop test/testBzrBuild.py, it's specific to Sebastian's computer.
* setup.py: Drop nose.collector, we don't use it.
* Add debian/local/python-mkdebian: Create/update debian packaging
  (debian/*) from python egg-info data. Not terribly pretty, but working and
  reasonably policy compliant.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        Update the language files, generate mo files and add them
57
57
        to the to be installed files
58
58
        """
 
59
        if not os.path.isdir(self.po_dir):
 
60
            return
 
61
 
59
62
        data_files = self.distribution.data_files
60
63
 
61
64
        if self.bug_contact is not None:
78
81
        os.chdir(self.po_dir)
79
82
        self.spawn(cmd)
80
83
        os.chdir(wd)
81
 
 
 
84
        max_po_mtime = 0
82
85
        for po_file in glob.glob("%s/*.po" % self.po_dir):
83
86
            lang = os.path.basename(po_file[:-3])
84
87
            mo_dir =  os.path.join("build", "mo", lang, "LC_MESSAGES")
86
89
            if not os.path.exists(mo_dir):
87
90
                os.makedirs(mo_dir)
88
91
            cmd = ["msgfmt", po_file, "-o", mo_file]
89
 
            self.spawn(cmd)
 
92
            po_mtime = os.path.getmtime(po_file)
 
93
            mo_mtime = os.path.exists(mo_file) and os.path.getmtime(mo_file) or 0
 
94
            if po_mtime > max_po_mtime:
 
95
                max_po_mtime = po_mtime
 
96
            if po_mtime > mo_mtime:
 
97
                self.spawn(cmd)
90
98
 
91
99
            targetpath = os.path.join("share/locale", lang, "LC_MESSAGES")
92
100
            data_files.append((targetpath, (mo_file,)))
115
123
                    file_merged = os.path.join(build_target, file_merged)
116
124
                    cmd = ["intltool-merge", switch, self.po_dir, file, 
117
125
                           file_merged]
118
 
                    self.spawn(cmd)
 
126
                    mtime_merged = os.path.exists(file_merged) and \
 
127
                                   os.path.getmtime(file_merged) or 0
 
128
                    mtime_file = os.path.getmtime(file)
 
129
                    if mtime_merged < max_po_mtime or mtime_merged < mtime_file:
 
130
                        # Only build if output is older than input (.po,.in) 
 
131
                        self.spawn(cmd)
119
132
                    files_merged.append(file_merged)
120
133
                data_files.append((target, files_merged))
121
134