Mercurial > hg > PaInt
comparison paint/info.py @ 54:a8236b97abd3
separate methods for gathering package information
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 23 Jan 2013 15:12:37 -0800 |
parents | |
children | 042a1b2a3e8a |
comparison
equal
deleted
inserted
replaced
53:c588375a7ce4 | 54:a8236b97abd3 |
---|---|
1 """ | |
2 interfaces to get information from a package | |
3 """ | |
4 | |
5 import os | |
6 import sys | |
7 | |
8 class PackageInfo(object): | |
9 """abstract base class of package info""" | |
10 def __init__(self, path): | |
11 """ | |
12 - path : path to setup.py or its directory | |
13 """ | |
14 if os.path.isdir(path): | |
15 path = os.path.join(path, 'setup.py') | |
16 assert os.path.exists(path), "'%s' not found" % path | |
17 self.setup_py = os.path.abspath(path) | |
18 | |
19 def __call__(self): | |
20 """returns dictionary of package info""" | |
21 raise NotImplementedError("abstract base class") | |
22 | |
23 class SetupOverridePackageInfo(PackageInfo): | |
24 """ | |
25 gather setup.py information by overriding the function | |
26 """ | |
27 | |
28 def __call__(self): | |
29 setuptools = sys.modules.get('setuptools') | |
30 sys.modules['setuptools'] = sys.modules[__name__] | |
31 globals()['setup'] = self._setup | |
32 try: | |
33 | |
34 return self.__dict__.pop('_info') | |
35 | |
36 def _setup(self, **kwargs): | |
37 self._info = kwargs |