[Checkins] SVN: zope.kgs/trunk/ A new script that lists all
versions of a package that have been
Stephan Richter
srichter at cosmos.phy.tufts.edu
Mon Jan 14 21:50:42 EST 2008
Log message for revision 82881:
A new script that lists all versions of a package that have been
released after the last version listed in the KGS. This makes it easier
to update the KGS.
Changed:
U zope.kgs/trunk/CHANGES.txt
U zope.kgs/trunk/setup.py
U zope.kgs/trunk/src/zope/kgs/README.txt
A zope.kgs/trunk/src/zope/kgs/latest.py
-=-
Modified: zope.kgs/trunk/CHANGES.txt
===================================================================
--- zope.kgs/trunk/CHANGES.txt 2008-01-15 00:44:34 UTC (rev 82880)
+++ zope.kgs/trunk/CHANGES.txt 2008-01-15 02:50:41 UTC (rev 82881)
@@ -7,6 +7,9 @@
- Initial version as ``zope.kgs``.
+ * A script that lists all versions of a package released after the latest
+ version lsited in the KGS.
+
* A script that manages the generation of the entire KGS site.
* Generate an intro page to the KGS.
Modified: zope.kgs/trunk/setup.py
===================================================================
--- zope.kgs/trunk/setup.py 2008-01-15 00:44:34 UTC (rev 82880)
+++ zope.kgs/trunk/setup.py 2008-01-15 02:50:41 UTC (rev 82881)
@@ -49,6 +49,7 @@
test=['zope.testing'],
),
install_requires=[
+ 'lxml',
'setuptools',
'zc.buildout',
'zope.pagetemplate',
@@ -60,6 +61,7 @@
'generate-links = zope.kgs.link:main',
'generate-intro = zope.kgs.intro:main',
'generate-site = zope.kgs.site:main',
+ 'list-latest = zope.kgs.latest:main',
]),
include_package_data = True,
zip_safe = False,
Modified: zope.kgs/trunk/src/zope/kgs/README.txt
===================================================================
--- zope.kgs/trunk/src/zope/kgs/README.txt 2008-01-15 00:44:34 UTC (rev 82880)
+++ zope.kgs/trunk/src/zope/kgs/README.txt 2008-01-15 02:50:41 UTC (rev 82881)
@@ -188,6 +188,9 @@
... [zope.interface]
... versions = 3.4.0
... 3.4.1
+ ...
+ ... [z3c.formdemo]
+ ... versions = 1.1.0
... ''')
Let's now create the links page:
@@ -204,14 +207,17 @@
</head>
<body>
<h1>Links for the "zope-dev" KGS (version 3.4.0b2)</h1>
+ <a href="http://pypi.python.org/packages/2.4/z/z3c.formdemo/z3c.formdemo-1.1.0-py2.4.egg#md5=9d605bd559ea33ac57ce11f5c80fa3d3">z3c.formdemo-1.1.0-py2.4.egg</a><br/>
+ <a href="http://pypi.python.org/packages/source/z/z3c.formdemo/z3c.formdemo-1.1.0.tar.gz#md5=f224a49cea737112284f74b859e3eed0">z3c.formdemo-1.1.0.tar.gz</a><br/>
+ <a href="http://pypi.python.org/packages/2.4/z/zope.component/zope.component-3.4.0-py2.4.egg#md5=c0763e94912e4a8ac1e321a068c916ba">zope.component-3.4.0-py2.4.egg</a><br/>
<a href="http://pypi.python.org/packages/source/z/zope.component/zope.component-3.4.0.tar.gz#md5=94afb57dfe605d7235ff562d1eaa3bed">zope.component-3.4.0.tar.gz</a><br/>
- <a href="http://pypi.python.org/packages/2.4/z/zope.component/zope.component-3.4.0-py2.4.egg#md5=c0763e94912e4a8ac1e321a068c916ba">zope.component-3.4.0-py2.4.egg</a><br/>
<a href="http://pypi.python.org/packages/source/z/zope.interface/zope.interface-3.4.0.tar.gz#md5=0be9fd80b7bb6bee520e56eba7d29c90">zope.interface-3.4.0.tar.gz</a><br/>
<a href="http://pypi.python.org/packages/2.4/z/zope.interface/zope.interface-3.4.0-py2.4-win32.egg#md5=3fa5e992271375eac597622d8e2fd5ec">zope.interface-3.4.0-py2.4-win32.egg</a><br/>
<a href="http://pypi.python.org/packages/source/z/zope.interface/zope.interface-3.4.1.tar.gz#md5=b085f4a774adab688e037ad32fbbf08e">zope.interface-3.4.1.tar.gz</a><br/>
</body>
</html>
+
PPIX Support
------------
@@ -230,7 +236,7 @@
>>> import os
>>> sorted(os.listdir(indexDir))
- ['PIL', 'zope.component', 'zope.interface']
+ ['PIL', 'z3c.formdemo', 'zope.component', 'zope.interface']
Each directory contains a single "index.html" file with the download links:
@@ -246,8 +252,8 @@
</head>
<body>
<h1>Links for "zope.component"</h1>
+ <a href="http://pypi.python.org/packages/2.4/z/zope.component/zope.component-3.4.0-py2.4.egg#md5=c0763e94912e4a8ac1e321a068c916ba">zope.component-3.4.0-py2.4.egg</a><br/>
<a href="http://pypi.python.org/packages/source/z/zope.component/zope.component-3.4.0.tar.gz#md5=94afb57dfe605d7235ff562d1eaa3bed">zope.component-3.4.0.tar.gz</a><br/>
- <a href="http://pypi.python.org/packages/2.4/z/zope.component/zope.component-3.4.0-py2.4.egg#md5=c0763e94912e4a8ac1e321a068c916ba">zope.component-3.4.0-py2.4.egg</a><br/>
</body>
</html>
@@ -256,17 +262,17 @@
>>> pkgIndex = os.path.join(indexDir, 'PIL', 'index.html')
>>> print open(pkgIndex, 'r').read()
- <html><head><title>Links for PIL</title></head><body><h1>Links for PIL</h1><a href='http://www.pythonware.com/products/pil' rel="homepage">1.1.6 home_page</a><br/>
- <a href='http://effbot.org/downloads/#Imaging' rel="download">1.1.6 download_url</a><br/>
+ <html><head><title>Links for PIL</title></head><body><h1>Links for PIL</h1><a href='http://www.pythonware.com/products/pil' rel="homepage">1.1.5 home_page</a><br/>
+ <a href='http://effbot.org/zone/pil-changes-115.htm' rel="download">1.1.5 download_url</a><br/>
+ <a href='http://www.pythonware.com/products/pil' rel="homepage">1.1.5a2 home_page</a><br/>
+ <a href='http://effbot.org/zone/pil-changes-115.htm' rel="download">1.1.5a2 download_url</a><br/>
+ <a href='http://www.pythonware.com/products/pil' rel="homepage">1.1.5a1 home_page</a><br/>
+ <a href='http://effbot.org/zone/pil-changes-115.htm' rel="download">1.1.5a1 download_url</a><br/>
<a href='http://www.pythonware.com/products/pil/' rel="homepage">1.1.4 home_page</a><br/>
<a href='http://www.pythonware.com/products/pil/' rel="homepage">1.1.3 home_page</a><br/>
<a href='http://www.pythonware.com/downloads/Imaging-1.1.3.tar.gz' rel="download">1.1.3 download_url</a><br/>
- <a href='http://www.pythonware.com/products/pil' rel="homepage">1.1.5a1 home_page</a><br/>
- <a href='http://effbot.org/zone/pil-changes-115.htm' rel="download">1.1.5a1 download_url</a><br/>
- <a href='http://www.pythonware.com/products/pil' rel="homepage">1.1.5a2 home_page</a><br/>
- <a href='http://effbot.org/zone/pil-changes-115.htm' rel="download">1.1.5a2 download_url</a><br/>
- <a href='http://www.pythonware.com/products/pil' rel="homepage">1.1.5 home_page</a><br/>
- <a href='http://effbot.org/zone/pil-changes-115.htm' rel="download">1.1.5 download_url</a><br/>
+ <a href='http://www.pythonware.com/products/pil' rel="homepage">1.1.6 home_page</a><br/>
+ <a href='http://effbot.org/downloads/#Imaging' rel="download">1.1.6 download_url</a><br/>
</body></html>
Optionally, you can also specify the `-i` option to generate an overview:
@@ -274,7 +280,7 @@
>>> ppix.main(('-i', cfgFileReal, indexDir))
>>> sorted(os.listdir(indexDir))
- ['PIL', 'index.html', 'zope.component', 'zope.interface']
+ ['PIL', 'index.html', 'z3c.formdemo', 'zope.component', 'zope.interface']
Let's now look at the file:
@@ -287,6 +293,7 @@
<body>
<h1>Simple Index for the "zope-dev" KGS (version 3.4.0b2)</h1>
<a href="PIL">PIL</a><br/>
+ <a href="z3c.formdemo">z3c.formdemo</a><br/>
<a href="zope.component">zope.component</a><br/>
<a href="zope.interface">zope.interface</a><br/>
</body>
@@ -299,6 +306,24 @@
only provides the packages of the KGS.
+Getting the Latest Versions
+---------------------------
+
+When updating the KGS, it is often useful to know for which packages have new
+releases.
+
+ >>> from zope.kgs import latest
+ >>> latest.main((cfgFileReal,))
+ z3c.formdemo: 1.1.1, 1.1.2, 1.2.0, 1.3.0, 1.3.0b1, 1.4.0, ...
+
+However, it is often desired only to show new minor versions; in this case, we
+can pass an option to exclude all versions that have a different major
+version:
+
+ >>> latest.main(('-m', cfgFileReal))
+ z3c.formdemo: 1.1.1, 1.1.2
+
+
Introduction Page
-----------------
@@ -413,10 +438,10 @@
'links-3.4.0b2.html', 'links.html',
'minimal', 'minimal-3.4.0b2',
'versions-3.4.0b2.cfg', 'versions.cfg',
- 'zope.component', 'zope.interface']
+ 'z3c.formdemo', 'zope.component', 'zope.interface']
>>> sorted(os.listdir(os.path.join(siteDir, 'minimal')))
- ['PIL', 'index.html', 'zope.component', 'zope.interface']
+ ['PIL', 'index.html', 'z3c.formdemo', 'zope.component', 'zope.interface']
If you try to generate the site again without changing the controlled packages
config file, it will simply return, because it checks the timestamp from the
Added: zope.kgs/trunk/src/zope/kgs/latest.py
===================================================================
--- zope.kgs/trunk/src/zope/kgs/latest.py (rev 0)
+++ zope.kgs/trunk/src/zope/kgs/latest.py 2008-01-15 02:50:41 UTC (rev 82881)
@@ -0,0 +1,92 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""For each package in the KGS, find all versions later than the last one
+listed in the KGS for that package.
+
+Usage: %s [-m] package-cfg-path
+
+* -m
+
+ Only list the versions that have the same major revision as the KGS version.
+
+* ``package-cfg-path``
+
+ This is the path to the controlled packages configuration file.
+"""
+import lxml.etree
+import os
+import pkg_resources
+import re
+import urllib
+import urllib2
+import zope.kgs.kgs
+
+SIMPLE_BASE_URL = "http://cheeseshop.python.org/simple/"
+VERSION_REGEX = '%s-(.*)(?:\.tar\.gz|\.zip)'
+
+def getAllVersions(packageName):
+ # Download the links URL, since the XML-RPC API does not provide the
+ # versions of hidden releases. :-(
+ packageName = urllib.quote(packageName)
+ page = urllib2.urlopen(SIMPLE_BASE_URL + packageName + '/').read()
+ # Parse the page to find all links that could possibly contain versoin
+ # information.
+ tree = lxml.etree.fromstring(page)
+ # Extract the versions from the links.
+ regex = re.compile(VERSION_REGEX %packageName)
+ versions = []
+ for url in tree.xpath('//a/@href'):
+ res = regex.findall(url)
+ if res and res[0] and res[0] not in versions:
+ versions.append(res[0])
+ return versions
+
+
+def generateList(packageConfigPath, minorOnly):
+ kgs = zope.kgs.kgs.KGS(packageConfigPath)
+
+ for package in kgs.packages:
+ kgsVersion = pkg_resources.parse_version(package.versions[-1])
+ serverVersions = getAllVersions(package.name)
+
+ newVersions = []
+ for version in serverVersions:
+ parsedVersion = pkg_resources.parse_version(version)
+ if minorOnly:
+ if parsedVersion[:2] != kgsVersion[:2]:
+ continue
+ if parsedVersion > kgsVersion:
+ newVersions.append(version)
+
+ newVersions.sort()
+ if newVersions:
+ print package.name + ': ' + ', '.join(newVersions)
+
+
+def main(args=None):
+ if args is None:
+ args = sys.argv[1:]
+
+ if len(args) < 1:
+ print __file__.__doc__ % sys.argv[0]
+ sys.exit(1)
+
+ minorOnly = False
+ if args[0] == '-m':
+ minorOnly = True
+ args = args[1:]
+
+ packageConfigPath = os.path.abspath(args[0])
+
+ generateList(packageConfigPath, minorOnly)
Property changes on: zope.kgs/trunk/src/zope/kgs/latest.py
___________________________________________________________________
Name: svn:keywords
+ Id
More information about the Checkins
mailing list