annotate paint/pypi.py @ 69:fea269259222

move comment to more appropriate place
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 26 Jan 2013 00:00:56 -0800
parents 59524b6d25c0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 """
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 functions for python package indices
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 import os
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 import pkginfo
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 def pypi_path(path):
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 """
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 returns subpath 2-tuple appropriate for pypi path structure:
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 http://k0s.org/portfolio/pypi.html
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 """
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 sdist = pkginfo.sdist.SDist(path)
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 # determine the extension (XXX hacky)
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 extensions = ('.tar.gz', '.zip', '.tar.bz2')
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 for ext in extensions:
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 if sdist.filename.endswith(ext):
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 break
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 else:
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 raise Exception("Extension %s not found: %s" % (extensions, sdist.filename))
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 # get the filename destination
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 filename = '%s-%s%s' % (sdist.name, sdist.version, ext)
59524b6d25c0 implementing making pypi directory strcuture from a package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 return sdist.name, filename