File: build_icons.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 (43 lines) | stat: -rw-r--r-- 1,224 bytes parent folder | download | duplicates (6)
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
"""distutils_extra.command.build_icons

Implement DistutilsExtra's 'build_icons' command.
"""

# Created by Sebastian Heinlein 

__revision__ = "$Id$"

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

class build_icons(distutils.cmd.Command):

    description = "select all icons for installation"

    user_options= [('icon-dir=', 'i', 'icon directory of the source tree')]

    def initialize_options(self):
        self.icon_dir = None

    def finalize_options(self):
        if self.icon_dir is None:
            self.icon_dir = os.path.join("data","icons")

    def run(self):
        data_files = self.distribution.data_files

        for size in glob.glob(os.path.join(self.icon_dir, "*")):
            for category in glob.glob(os.path.join(size, "*")):
                icons = []
                for icon in glob.glob(os.path.join(category,"*")):
                    icons.append(icon)
                    data_files.append(("share/icons/hicolor/%s/%s" % \
                                       (os.path.basename(size), \
                                        os.path.basename(category)), \
                                        icons))
# class build