Mercurial > hg > PaInt
diff paint/info.py @ 77:00c0f668f332
implementation of setup2metadata
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 27 Jan 2013 22:19:10 -0800 |
parents | 84890934af1f |
children |
line wrap: on
line diff
--- a/paint/info.py Sun Jan 27 21:43:41 2013 -0800 +++ b/paint/info.py Sun Jan 27 22:19:10 2013 -0800 @@ -4,12 +4,12 @@ import imp +import pkginfo import os import subprocess import sys from distutils.dist import Distribution -from distutils.dist import DistributionMetadata from subprocess import check_call as call from StringIO import StringIO @@ -37,7 +37,17 @@ distribution = Distribution(attrs) buffer = StringIO() distribution.metadata.write_pkg_file(buffer) - raise NotImplementedError("TODO") + pkginfo_dist = pkginfo.Distribution() + pkinfo_dist.parse(buffer.getvalue()) + newattrs = dict((i, getattr(pkginfo_dist, i)) for i in pkginfo_dist) + header_dict = dict((attr_name, header_name) + for header_name, attr_name, multiple in pkginfo_dist._getHeaderAttrs()) + info = dict((header_dict[key], value) for key, value in newattrs.items()) + + # XXX pkginfo says 'Home-Page' though the spec says Home-page + info.setdefault('Home-page', info['Home-Page']) + + return info class PackageInfo(object):