diff paint/pypi.py @ 29:59524b6d25c0

implementing making pypi directory strcuture from a package
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 30 Mar 2012 11:41:04 -0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paint/pypi.py	Fri Mar 30 11:41:04 2012 -0700
@@ -0,0 +1,25 @@
+"""
+functions for python package indices
+"""
+
+import os
+import pkginfo
+
+def pypi_path(path):
+    """
+    returns subpath 2-tuple appropriate for pypi path structure:
+    http://k0s.org/portfolio/pypi.html
+    """
+    sdist = pkginfo.sdist.SDist(path)
+
+    # determine the extension (XXX hacky)
+    extensions = ('.tar.gz', '.zip', '.tar.bz2')
+    for ext in extensions:
+        if sdist.filename.endswith(ext):
+            break
+    else:
+        raise Exception("Extension %s not found: %s" % (extensions, sdist.filename))
+
+    # get the filename destination
+    filename = '%s-%s%s' % (sdist.name, sdist.version, ext)
+    return sdist.name, filename