[Checkins] SVN: zope.z2release/trunk/zope/z2release/cli.py added

Andreas Jung andreas at andreas-jung.com
Thu Apr 23 11:50:25 EDT 2009


Log message for revision 99420:
  added
  

Changed:
  A   zope.z2release/trunk/zope/z2release/cli.py

-=-
Added: zope.z2release/trunk/zope/z2release/cli.py
===================================================================
--- zope.z2release/trunk/zope/z2release/cli.py	                        (rev 0)
+++ zope.z2release/trunk/zope/z2release/cli.py	2009-04-23 15:50:25 UTC (rev 99420)
@@ -0,0 +1,63 @@
+"""
+Generate an index file based on the version.cfg file of Zope 2
+in order to provide a version specific index page generated to be used
+in combination with easy_install -i <some_url>
+"""
+
+import os
+import sys
+import urlparse
+from xmlrpclib import Server
+from ConfigParser import RawConfigParser as ConfigParser
+
+# packages containing upper-case letters
+upper_names = ('ClientForm', 'RestrictedPython', 'ZConfig', 'ZODB3', 'zLOG', 
+               'Acquisition', 'DateTime', 'ExtensionClass', 'Persistence')
+
+def write_index(package, version):
+    print >>sys.stderr, 'Package %s==%s' % (package, version)
+    dest_dir = os.path.join(dirname, package)
+    if not os.path.exists(dest_dir):
+        os.makedirs(dest_dir)
+    index_html = os.path.join(dest_dir, 'index.html')
+
+    fp = file(index_html, 'w')
+    print >>fp, '<html><body>'
+    lst = server.package_urls(package, version)
+    if lst:
+        # package hosted on PyPI
+        for d in lst:
+            link = '<a href="%s">%s</a>' % (d['url'], d['filename'])
+            print >>fp, link
+            print >>fp, '<br/>'
+    else:
+        # for externally hosted packages we need to rely on the 
+        # download_url metadata
+        rel_data = server.release_data(package, version)
+        download_url = rel_data['download_url']
+        filename = os.path.basename(urlparse.urlparse(download_url)[2])
+        link = '<a href="%s">%s</a>' % (download_url, filename)
+        print >>fp, link
+
+    print >>fp, '</body></html>'
+    fp.close()
+
+CP = ConfigParser()
+CP.read(['versions.cfg'])
+
+server = Server('http://pypi.python.org/pypi')
+links = list()
+dirname = sys.argv[1]
+
+write_index('Zope2', '2.12.0a3')
+
+for package in CP.options('versions'):
+
+    # options() returns all options in lowercase but
+    # we must preserve the case for package names
+    for name in upper_names:
+        if name.lower() == package:
+            package = name
+            break
+    version = CP.get('versions', package)
+    write_index(package, version)



More information about the Checkins mailing list