~verterok/ubuntuone-client/fix-435137

« back to all changes in this revision

Viewing changes to contrib/build_icons.py

  • Committer: Rodney Dawes
  • Date: 2009-05-12 13:36:05 UTC
  • Revision ID: rodney.dawes@canonical.com-20090512133605-6aqs6e8xnnmp5u1p
        Import the code
        Hook up lint/trial tests in setup.py
        Use icontool now instead of including the render script
        Add missing python-gnome2-desktop to package dependencies
        Update debian/rules to fix the icon cache issue

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