Mercurial > hg > PaInt
diff 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 |
line wrap: on
line diff
--- a/paint/info.py Fri Jan 25 15:56:26 2013 -0800 +++ b/paint/info.py Fri Jan 25 23:43:13 2013 -0800 @@ -37,6 +37,8 @@ """returns dictionary of package info""" raise NotImplementedError("abstract base class") + def dependencies(self): + raise NotImplementedError("abstract base class") class SetupOverridePackageInfo(PackageInfo): """ @@ -89,6 +91,38 @@ # return the information return info_dict + def dependencies(self): + """return the dependencies of the package""" + + # TODO: should probably have a more detailed dict: + # {'mozinfo': {'version': '>= 0.2', + # 'url': 'http://something.com/'}} + + # get the egg_info directory + egg_info = self._egg_info() + + # read the dependencies + requires = os.path.join(egg_info, 'requires.txt') + if os.path.exists(requires): + dependencies = [i.strip() for i in file(requires).readlines() if i.strip()] + else: + dependencies = [] + dependencies = dict([(i, None) for i in dependencies]) + + # read the dependency links + dependency_links = os.path.join(egg_info, 'dependency_links.txt') + if os.path.exists(dependency_links): + links = [i.strip() for i in file(dependency_links).readlines() if i.strip()] + for link in links: + # XXX pretty ghetto + assert '#egg=' in link + url, dep = link.split('#egg=', 1) + if dep in dependencies: + dependencies[dep] = link + + return dependencies + + def _egg_info(self): """build the egg_info directory"""