~rmcbride/ubuntu/lucid/ubuntuone-client/fixucg

« back to all changes in this revision

Viewing changes to contrib/build_icons.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2009-07-16 17:00:00 UTC
  • mto: (17.1.1 ubuntuone-client)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20090716170000-tnnk149g57bxxo24
Tags: upstream-0.90.4
ImportĀ upstreamĀ versionĀ 0.90.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""distutils_extra.command.build_icons
2
 
 
3
 
Implement DistutilsExtra's 'build_icons' command.
4
 
"""
5
 
 
6
 
# Created by Sebastian Heinlein 
7
 
 
8
 
__revision__ = "$Id$"
9
 
 
10
 
import distutils
11
 
import glob
12
 
import os
13
 
import os.path
14
 
import re
15
 
import sys
16
 
import distutils.command.build
17
 
 
18
 
class build_icons(distutils.cmd.Command):
19
 
 
20
 
    description = "select all icons for installation"
21
 
 
22
 
    user_options= [('icon-dir=', 'i', 'icon directory of the source tree')]
23
 
 
24
 
    def initialize_options(self):
25
 
        self.icon_dir = None
26
 
 
27
 
    def finalize_options(self):
28
 
        if self.icon_dir is None:
29
 
            self.icon_dir = os.path.join("data", "icons")
30
 
 
31
 
    def run(self):
32
 
        data_files = self.distribution.data_files
33
 
 
34
 
        for size in glob.glob(os.path.join(self.icon_dir, "*")):
35
 
            for category in glob.glob(os.path.join(size, "*")):
36
 
                icons = []
37
 
                for icon in glob.glob(os.path.join(category,"*")):
38
 
                    icons.append(icon)
39
 
                    # Only install apps and emblems contexts to system theme
40
 
                    # everything else should go to the private hicolor theme
41
 
                    if category.endswith("apps") or \
42
 
                            category.endswith("emblems"):
43
 
                        data_files.append(("share/icons/hicolor/%s/%s" %
44
 
                                           (os.path.basename(size),
45
 
                                            os.path.basename(category)),
46
 
                                           icons))
47
 
                    else:
48
 
                        data_files.append(("share/%s/icons/hicolor/%s/%s" %
49
 
                                           (self.distribution.get_name(),
50
 
                                            os.path.basename(size),
51
 
                                            os.path.basename(category)),
52
 
                                           icons))
53
 
 
54
 
# class build