diff options
author | Jeremy Kloth <jeremy.kloth@gmail.com> | 2011-09-12 17:12:42 (GMT) |
---|---|---|
committer | Jeremy Kloth <jeremy.kloth@gmail.com> | 2011-09-12 17:12:42 (GMT) |
commit | aa2b442bdccf68c191a0023084b1160804fb5e4c (patch) | |
tree | 6e6b9ade0d959ea36e21fa72d1f308215e7fc80c /Lib/packaging/command | |
parent | 4c3124c2b94add8cc168ebe29aa47f0f7326d7d8 (diff) | |
download | cpython-aa2b442bdccf68c191a0023084b1160804fb5e4c.zip cpython-aa2b442bdccf68c191a0023084b1160804fb5e4c.tar.gz cpython-aa2b442bdccf68c191a0023084b1160804fb5e4c.tar.bz2 |
Factor out the distribution file-system safe name functions from install_distinfo to allow all metadata consumers access to them.
Diffstat (limited to 'Lib/packaging/command')
-rw-r--r-- | Lib/packaging/command/install_distinfo.py | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/Lib/packaging/command/install_distinfo.py b/Lib/packaging/command/install_distinfo.py index 1f48eed..c1f85ed 100644 --- a/Lib/packaging/command/install_distinfo.py +++ b/Lib/packaging/command/install_distinfo.py @@ -63,9 +63,7 @@ class install_distinfo(Command): metadata = self.distribution.metadata - basename = "%s-%s.dist-info" % ( - to_filename(safe_name(metadata['Name'])), - to_filename(safe_version(metadata['Version']))) + basename = metadata.get_fullname(filesafe=True) + ".dist-info" self.distinfo_dir = os.path.join(self.distinfo_dir, basename) @@ -145,31 +143,3 @@ class install_distinfo(Command): def get_outputs(self): return self.outfiles - - -# The following functions are taken from setuptools' pkg_resources module. - -def safe_name(name): - """Convert an arbitrary string to a standard distribution name - - Any runs of non-alphanumeric/. characters are replaced with a single '-'. - """ - return re.sub('[^A-Za-z0-9.]+', '-', name) - - -def safe_version(version): - """Convert an arbitrary string to a standard version string - - Spaces become dots, and all other non-alphanumeric characters become - dashes, with runs of multiple dashes condensed to a single dash. - """ - version = version.replace(' ', '.') - return re.sub('[^A-Za-z0-9.]+', '-', version) - - -def to_filename(name): - """Convert a project or version name to its filename-escaped form - - Any '-' characters are currently replaced with '_'. - """ - return name.replace('-', '_') |