diff --git a/basketweaver/__init__.py b/basketweaver/__init__.py
new file mode 100644
index 0000000..792d600
--- /dev/null
+++ b/basketweaver/__init__.py
@@ -0,0 +1 @@
+#
diff --git a/basketweaver/makeindex.py b/basketweaver/makeindex.py
new file mode 100644
index 0000000..d67d626
--- /dev/null
+++ b/basketweaver/makeindex.py
@@ -0,0 +1,172 @@
+"""
+From Chris McDonough:
+
+If it's not labeled otherwise and it comes from us, it's released under this license... http://repoze.org/license.html (BSD-like)...
+
+"""
+
+import os
+import setuptools
+import shutil
+import subprocess
+import sys
+import tarfile
+import zipfile
+import tempfile
+
+class TarArchive:
+ def __init__(self, filename):
+ self.filename = filename
+ self.tgz = tarfile.TarFile.gzopen(filename, 'r')
+
+ def names(self):
+ return self.tgz.getnames()
+
+ def lines(self, name):
+ return self.tgz.extractfile(name).readlines()
+
+ def extract(self, name, tempdir):
+ return self.tgz.extract(name, tempdir)
+
+ def extractall(self, tempdir):
+ os.system('cd %s && tar xzf %s' % (tempdir,
+ os.path.abspath(self.filename)))
+
+ def close(self):
+ return self.tgz.close()
+
+class ZipArchive:
+ def __init__(self, filename):
+ self.filename = filename
+ self.zipf = zipfile.ZipFile(filename, 'r')
+
+ def names(self):
+ return self.zipf.namelist()
+
+ def lines(self, name):
+ return self.zipf.read(name).split('\n')
+
+ def extract(self, name, tempdir):
+ data = self.zipf.read(name)
+ fn = name.split(os.sep)[-1]
+ fn = os.path.join(tempdir, fn)
+ f = open(fn, 'wb')
+ f.write(data)
+
+ def extractall(self, tempdir):
+ os.system('cd %s && unzip %s' % (tempdir,
+ os.path.abspath(self.filename)))
+
+ def close(self):
+ return self.zipf.close()
+
+def _extractNameVersion(filename, tempdir):
+ print 'Parsing:', filename
+
+ archive = None
+
+ if filename.endswith('.gz') or filename.endswith('.tgz'):
+ archive = TarArchive(filename)
+
+ elif filename.endswith('.egg') or filename.endswith('.zip'):
+ archive = ZipArchive(filename)
+
+ if archive is None:
+ return
+ try:
+ for name in archive.names():
+ if len(name.split('/'))==2 and name.endswith('PKG-INFO'):
+
+ project, version = None, None
+
+ lines = archive.lines(name)
+
+ for line in lines:
+ key, value = line.split(':', 1)
+
+ if key == 'Name':
+ print filename, value
+ project = value.strip()
+
+ elif key == 'Version':
+ version = value.strip()
+
+ if project is not None and version is not None:
+ return project, version
+ contiue;
+
+ # no PKG-INFO found, do it the hard way.
+ archive.extractall(tempdir)
+ dirs = os.listdir(tempdir)
+ dir = os.path.join(tempdir, dirs[0])
+ if not os.path.isdir(dir):
+ dir = tempdir
+ command = ('cd %s && %s setup.py --name --version'
+ % (dir, sys.executable))
+ popen = subprocess.Popen(command,
+ stdout=subprocess.PIPE,
+ shell=True,
+ )
+ output = popen.communicate()[0]
+ return output.splitlines()[:2]
+ finally:
+ archive.close()
+
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv[1:]
+
+ projects = {}
+ for arg in argv:
+ if arg.startswith('*'):
+ continue
+ try:
+ tempdir = tempfile.mkdtemp()
+ project, revision = _extractNameVersion(arg, tempdir)
+ projects.setdefault(project, []).append((revision, arg))
+ except:
+ pass
+ finally:
+ shutil.rmtree(tempdir)
+
+ items = projects.items()
+ items.sort()
+ topname = 'index'
+
+ if not os.path.exists(topname):
+ os.makedirs(topname)
+ top = open('%s/index.html' % topname, 'w')
+ top.writelines(['\n',
+ '
\n',
+ 'Package Index
\n',
+ '\n'])
+
+ for key, value in items:
+ print 'Project: %s' % key
+ dirname = '%s/%s' % (topname, key)
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+ top.write('- %s\n' % (key, key))
+
+ sub = open('%s/%s/index.html' % (topname, key), 'w')
+ sub.writelines(['\n',
+ '\n',
+ '
%s Distributions
\n' % key,
+ '\n'])
+
+ for revision, archive in value:
+ print ' -> %s, %s' % (revision, archive)
+ sub.write('- %s\n' % (archive, archive))
+
+ sub.writelines(['
\n',
+ '\n',
+ '\n'])
+
+ top.writelines(['
\n',
+ '\n',
+ '\n'])
+ top.close()
+
+if __name__ == '__main__':
+ main()
diff --git a/build/lib/basketweaver/__init__.py b/build/lib/basketweaver/__init__.py
new file mode 100644
index 0000000..792d600
--- /dev/null
+++ b/build/lib/basketweaver/__init__.py
@@ -0,0 +1 @@
+#
diff --git a/build/lib/basketweaver/makeindex.py b/build/lib/basketweaver/makeindex.py
new file mode 100644
index 0000000..d67d626
--- /dev/null
+++ b/build/lib/basketweaver/makeindex.py
@@ -0,0 +1,172 @@
+"""
+From Chris McDonough:
+
+If it's not labeled otherwise and it comes from us, it's released under this license... http://repoze.org/license.html (BSD-like)...
+
+"""
+
+import os
+import setuptools
+import shutil
+import subprocess
+import sys
+import tarfile
+import zipfile
+import tempfile
+
+class TarArchive:
+ def __init__(self, filename):
+ self.filename = filename
+ self.tgz = tarfile.TarFile.gzopen(filename, 'r')
+
+ def names(self):
+ return self.tgz.getnames()
+
+ def lines(self, name):
+ return self.tgz.extractfile(name).readlines()
+
+ def extract(self, name, tempdir):
+ return self.tgz.extract(name, tempdir)
+
+ def extractall(self, tempdir):
+ os.system('cd %s && tar xzf %s' % (tempdir,
+ os.path.abspath(self.filename)))
+
+ def close(self):
+ return self.tgz.close()
+
+class ZipArchive:
+ def __init__(self, filename):
+ self.filename = filename
+ self.zipf = zipfile.ZipFile(filename, 'r')
+
+ def names(self):
+ return self.zipf.namelist()
+
+ def lines(self, name):
+ return self.zipf.read(name).split('\n')
+
+ def extract(self, name, tempdir):
+ data = self.zipf.read(name)
+ fn = name.split(os.sep)[-1]
+ fn = os.path.join(tempdir, fn)
+ f = open(fn, 'wb')
+ f.write(data)
+
+ def extractall(self, tempdir):
+ os.system('cd %s && unzip %s' % (tempdir,
+ os.path.abspath(self.filename)))
+
+ def close(self):
+ return self.zipf.close()
+
+def _extractNameVersion(filename, tempdir):
+ print 'Parsing:', filename
+
+ archive = None
+
+ if filename.endswith('.gz') or filename.endswith('.tgz'):
+ archive = TarArchive(filename)
+
+ elif filename.endswith('.egg') or filename.endswith('.zip'):
+ archive = ZipArchive(filename)
+
+ if archive is None:
+ return
+ try:
+ for name in archive.names():
+ if len(name.split('/'))==2 and name.endswith('PKG-INFO'):
+
+ project, version = None, None
+
+ lines = archive.lines(name)
+
+ for line in lines:
+ key, value = line.split(':', 1)
+
+ if key == 'Name':
+ print filename, value
+ project = value.strip()
+
+ elif key == 'Version':
+ version = value.strip()
+
+ if project is not None and version is not None:
+ return project, version
+ contiue;
+
+ # no PKG-INFO found, do it the hard way.
+ archive.extractall(tempdir)
+ dirs = os.listdir(tempdir)
+ dir = os.path.join(tempdir, dirs[0])
+ if not os.path.isdir(dir):
+ dir = tempdir
+ command = ('cd %s && %s setup.py --name --version'
+ % (dir, sys.executable))
+ popen = subprocess.Popen(command,
+ stdout=subprocess.PIPE,
+ shell=True,
+ )
+ output = popen.communicate()[0]
+ return output.splitlines()[:2]
+ finally:
+ archive.close()
+
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv[1:]
+
+ projects = {}
+ for arg in argv:
+ if arg.startswith('*'):
+ continue
+ try:
+ tempdir = tempfile.mkdtemp()
+ project, revision = _extractNameVersion(arg, tempdir)
+ projects.setdefault(project, []).append((revision, arg))
+ except:
+ pass
+ finally:
+ shutil.rmtree(tempdir)
+
+ items = projects.items()
+ items.sort()
+ topname = 'index'
+
+ if not os.path.exists(topname):
+ os.makedirs(topname)
+ top = open('%s/index.html' % topname, 'w')
+ top.writelines(['\n',
+ '\n',
+ 'Package Index
\n',
+ '\n'])
+
+ for key, value in items:
+ print 'Project: %s' % key
+ dirname = '%s/%s' % (topname, key)
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+ top.write('- %s\n' % (key, key))
+
+ sub = open('%s/%s/index.html' % (topname, key), 'w')
+ sub.writelines(['\n',
+ '\n',
+ '
%s Distributions
\n' % key,
+ '\n'])
+
+ for revision, archive in value:
+ print ' -> %s, %s' % (revision, archive)
+ sub.write('- %s\n' % (archive, archive))
+
+ sub.writelines(['
\n',
+ '\n',
+ '\n'])
+
+ top.writelines(['
\n',
+ '\n',
+ '\n'])
+ top.close()
+
+if __name__ == '__main__':
+ main()
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..5d9ff11
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,14 @@
+[aliases]
+release = egg_info -rDb "" sdist bdist_egg register upload
+
+[egg_info]
+tag_build = dev
+tag_date = true
+
+# The following lines are here to test that tw.extjs' resources can be built
+# correctly. Normally this section will be in the project that uses tw.extjs
+[archive_tw_resources]
+output = build/static
+onepass = true
+compresslevel = 2
+distributions=tw.extjs
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..ad56764
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,29 @@
+from setuptools import setup, find_packages
+import sys, os
+
+version = '0.1'
+
+setup(name='basketweaver',
+ version=version,
+ description="Provides utilities for making your own python package index.",
+ long_description="""\
+""",
+ classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
+ keywords='python eggs pypi index package gz tar zip',
+ author='Christopher Perkins, Chris McDonough',
+ author_email='chris@percious.com',
+ url='http://code.google.com/p/basket-weaver/',
+ license='MIT',
+ packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
+ include_package_data=True,
+ zip_safe=True,
+ install_requires=[
+ # -*- Extra requirements: -*-
+
+ ],
+ entry_points={
+ 'console_scripts': [
+ 'makeindex = basketweaver.makeindex:main'
+ ],
+ }
+ )