comparison paint/info.py @ 68:d001017d5870

migrate this code to the right place
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 25 Jan 2013 23:43:13 -0800
parents 8f39ba642531
children fea269259222
comparison
equal deleted inserted replaced
67:8f39ba642531 68:d001017d5870
35 35
36 def __call__(self): 36 def __call__(self):
37 """returns dictionary of package info""" 37 """returns dictionary of package info"""
38 raise NotImplementedError("abstract base class") 38 raise NotImplementedError("abstract base class")
39 39
40 def dependencies(self):
41 raise NotImplementedError("abstract base class")
40 42
41 class SetupOverridePackageInfo(PackageInfo): 43 class SetupOverridePackageInfo(PackageInfo):
42 """ 44 """
43 gather setup.py information by overriding the function 45 gather setup.py information by overriding the function
44 """ 46 """
87 info_dict[key] = value 89 info_dict[key] = value
88 90
89 # return the information 91 # return the information
90 return info_dict 92 return info_dict
91 93
94 def dependencies(self):
95 """return the dependencies of the package"""
96
97 # TODO: should probably have a more detailed dict:
98 # {'mozinfo': {'version': '>= 0.2',
99 # 'url': 'http://something.com/'}}
100
101 # get the egg_info directory
102 egg_info = self._egg_info()
103
104 # read the dependencies
105 requires = os.path.join(egg_info, 'requires.txt')
106 if os.path.exists(requires):
107 dependencies = [i.strip() for i in file(requires).readlines() if i.strip()]
108 else:
109 dependencies = []
110 dependencies = dict([(i, None) for i in dependencies])
111
112 # read the dependency links
113 dependency_links = os.path.join(egg_info, 'dependency_links.txt')
114 if os.path.exists(dependency_links):
115 links = [i.strip() for i in file(dependency_links).readlines() if i.strip()]
116 for link in links:
117 # XXX pretty ghetto
118 assert '#egg=' in link
119 url, dep = link.split('#egg=', 1)
120 if dep in dependencies:
121 dependencies[dep] = link
122
123 return dependencies
124
125
92 def _egg_info(self): 126 def _egg_info(self):
93 """build the egg_info directory""" 127 """build the egg_info directory"""
94 128
95 # cached result 129 # cached result
96 if getattr(self, '_egg_info_path', None): 130 if getattr(self, '_egg_info_path', None):