File: build_extra.py

package info (click to toggle)
hotwire 0.721-2
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 1,440 kB
  • ctags: 2,331
  • sloc: python: 15,555; makefile: 14
file content (57 lines) | stat: -rw-r--r-- 2,245 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python

import distutils
import glob
import os
import os.path
import re
import sys
import distutils.command.build

class build_extra(distutils.command.build.build):
    """Adds the extra commands to the build target. This class should be used
       with the core distutils"""
    def __init__(self, dist):
        distutils.command.build.build.__init__(self, dist)

        self.user_options.extend([("i18n", None, "use the localsation"),
                                  ("icons", None, "use icons"),
                                  ("help", None, "use help system")])
    def initialize_options(self):
        distutils.command.build.build.initialize_options(self)
        self.i18n = False
        self.icons = False
        self.help = False

    def finalize_options(self):
        def has_help(command):
            return self.help == "True" or \
                   (self.distribution.cmdclass.has_key("build_help") and not \
                    self.help == "False")
        def has_icons(command):
            return self.icons == "True" or \
                   (self.distribution.cmdclass.has_key("build_icons") and not \
                    self.help == "False")
        def has_i18n(command):
            return self.i18n == "True" or \
                   (self.distribution.cmdclass.has_key("build_i18n") and not \
                    self.i18n == "False")
        distutils.command.build.build.finalize_options(self)
        self.sub_commands.append(("build_i18n", has_i18n))
        self.sub_commands.append(("build_icons", has_icons))
        self.sub_commands.append(("build_help", has_help))

class build(build_extra):
    """Adds the extra commands to the build target. This class should be
       used with setuptools."""
    def finalize_options(self):
        def has_help(command):
            return self.help == "True"
        def has_icons(command):
            return self.icons == "True"
        def has_i18n(command):
            return self.i18n == "True"
        distutils.command.build.build.finalize_options(self)
        self.sub_commands.append(("build_i18n", has_i18n))
        self.sub_commands.append(("build_icons", has_icons))
        self.sub_commands.append(("build_help", has_help))