~ubuntu-branches/debian/squeeze/python-distutils-extra/squeeze

« back to all changes in this revision

Viewing changes to DistUtilsExtra/command/clean_i18n.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2008-03-18 21:59:43 UTC
  • mfrom: (1.1.7 hardy)
  • Revision ID: james.westby@ubuntu.com-20080318215943-5a7lc4qa90f1m21t
Tags: 1.91.2
* DistUtilsExtra/command/build_i18n.py: Do not merge PO files by default,
  since it is not related to building the package, should be done manually
  rather, and creates noise in revision control. Introduce a new option
  -m/--merge-po instead. Adapt doc/FAQ accordingly.
* debian/control: Update Vcs-*: fields.
* debian/copyright: Fix copyright statement and upstream URL.
* debian/changelog: Fix invalid email address to make lintian happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""distutils_extra.command.clean_i18n
 
2
 
 
3
Implements the Distutils 'clean_i18n' command."""
 
4
 
 
5
import os.path, os
 
6
from distutils.dir_util import remove_tree
 
7
import distutils.command.clean
 
8
 
 
9
class clean_i18n(distutils.command.clean.clean):
 
10
 
 
11
    description = "clean up files generated by build_i18n"
 
12
 
 
13
    def run(self):
 
14
        # clean build/mo
 
15
        mo_dir =  os.path.join("build", "mo")
 
16
        if os.path.isdir(mo_dir):
 
17
            remove_tree('build/mo')
 
18
 
 
19
        # clean built i18n files
 
20
        for setname in ('xml_files', 'desktop_files', 'schemas_files',
 
21
            'rfc822deb_files', 'ba_files', 'key_files'):
 
22
            file_set = eval(self.distribution.get_option_dict('build_i18n').get(setname, (None, '[]'))[1])
 
23
            for (target, files) in file_set:
 
24
                build_target = os.path.join("build", target)
 
25
                for file in files:
 
26
                    if file.endswith(".in"):
 
27
                        file_merged = os.path.basename(file[:-3])
 
28
                    else:
 
29
                        file_merged = os.path.basename(file)
 
30
                    file_merged = os.path.join(build_target, file_merged)
 
31
                    if os.path.exists(file_merged):
 
32
                        os.unlink(file_merged)
 
33
                if os.path.exists(build_target):
 
34
                    os.removedirs(build_target)
 
35
 
 
36
        distutils.command.clean.clean.run(self)