[Checkins] SVN: z3c.checkversions/trunk/ Added a --incremental option to suggest only one upgrade
Christophe Combelles
ccomb at free.fr
Sun Jul 25 14:07:13 EDT 2010
Log message for revision 115090:
Added a --incremental option to suggest only one upgrade
Changed:
U z3c.checkversions/trunk/CHANGELOG.txt
U z3c.checkversions/trunk/README.txt
U z3c.checkversions/trunk/z3c/checkversions/base.py
U z3c.checkversions/trunk/z3c/checkversions/buildout.txt
U z3c.checkversions/trunk/z3c/checkversions/main.py
-=-
Modified: z3c.checkversions/trunk/CHANGELOG.txt
===================================================================
--- z3c.checkversions/trunk/CHANGELOG.txt 2010-07-25 16:03:22 UTC (rev 115089)
+++ z3c.checkversions/trunk/CHANGELOG.txt 2010-07-25 18:07:12 UTC (rev 115090)
@@ -4,8 +4,9 @@
0.4 (unreleased)
----------------
-- added a `blacklist` option for versions to avoid
+- added a `blacklist` option for passing versions to avoid
(possibly coming from a buildbot)
+- added a `incremental` option to suggest only one upgrade
- remove a temporary file during tests
0.3 (2010-07-09)
Modified: z3c.checkversions/trunk/README.txt
===================================================================
--- z3c.checkversions/trunk/README.txt 2010-07-25 16:03:22 UTC (rev 115089)
+++ z3c.checkversions/trunk/README.txt 2010-07-25 18:07:12 UTC (rev 115090)
@@ -56,9 +56,11 @@
Provide and alternative package index URL
-b BLACKLIST, --blacklist=BLACKLIST
Provide a blacklist file with bad versions
+ -1, --incremental Suggest only one upgrade. Skip others.
-v, --verbose Verbose mode (prints old versions too)
+
Examples
========
@@ -82,12 +84,14 @@
[versions]
somepackage=0.5.3
+ otherpackage=0.1.1
-You can create a new versions.cfg by retrieving the output ::
+You can generate a new versions.cfg ::
$ checkversions -v -l 1 versions.cfg
# Checking buildout file versions.cfg
somepackage=0.6.2 # was: 0.5.0
+ otherpackage=0.1.2 # was: 0.1.1
If you provide a blacklist file, such as `blacklist.cfg` containing bad
versions, such as::
@@ -97,11 +101,19 @@
Then these versions won't be suggested::
- $ checkversions -v -l 1 versions.cfg
+ $ checkversions -v -l 1 versions.cfg -b blacklist.cfg
# Checking buildout file versions.cfg
somepackage=0.6.0 # was: 0.5.0
+ otherpackage=0.1.2 # was: 0.1.1
+If you enable the incremental option, only one upgrade will be suggested::
+ $ checkversions --incremental -v -l 1 versions.cfg
+ # Checking buildout file versions.cfg
+ somepackage=0.6.0 # was: 0.5.0
+ otherpackage=0.1.1
+
+
Run tests
=========
Modified: z3c.checkversions/trunk/z3c/checkversions/base.py
===================================================================
--- z3c.checkversions/trunk/z3c/checkversions/base.py 2010-07-25 16:03:22 UTC (rev 115089)
+++ z3c.checkversions/trunk/z3c/checkversions/base.py 2010-07-25 18:07:12 UTC (rev 115090)
@@ -28,10 +28,23 @@
class Checker(object):
"""Base class for version checkers
+
+ attributes:
+
+ index_url: url of an alternative package index
+ verbose: display every version, not only new ones,
+ and display the previous version as a comment
+ blacklist: filename of the blacklist
+ incremental: suggest only one package upgrade
"""
__custom_url = False
- def __init__(self, index_url=None, verbose=False, blacklist=None):
+ def __init__(self,
+ index_url=None,
+ verbose=False,
+ blacklist=None,
+ incremental=False):
self.verbose = verbose
+ self.incremental = incremental
if blacklist:
# create a set of tuples with bad versions
self.blacklist = set([tuple(map(lambda x: x.strip(), line.split('=')))
@@ -66,6 +79,10 @@
versions = self.get_versions()
for name, version in versions.items():
+ if self.incremental == 'stop':
+ # skip subsequent scans
+ print("%s=%s" % (name, version))
+ continue
parsed_version = parse_version(version)
req = Requirement.parse(name)
self.pi.find_packages(req)
@@ -75,6 +92,8 @@
# and is a final version
# and is not in the blacklist
for dist in self.pi[req.key]:
+ if self.incremental == 'stop':
+ continue
if (dist.project_name, dist.version) in self.blacklist:
continue
if not _final_version(dist.parsed_version):
@@ -85,6 +104,8 @@
break
if new_dist and new_dist.parsed_version > parsed_version:
+ if self.incremental == True:
+ self.incremental = 'stop'
if self.verbose:
print("%s=%s # was: %s"
% (name, new_dist.version, version.split()[0]))
Modified: z3c.checkversions/trunk/z3c/checkversions/buildout.txt
===================================================================
--- z3c.checkversions/trunk/z3c/checkversions/buildout.txt 2010-07-25 16:03:22 UTC (rev 115089)
+++ z3c.checkversions/trunk/z3c/checkversions/buildout.txt 2010-07-25 18:07:12 UTC (rev 115090)
@@ -109,9 +109,24 @@
Reading file:///.../zope.component/
zope.component=3.9.2 # was: 3.4.0
+We can let the checker to suggest only one new package. This should be used to
+test a just single new package against a set of other packages.
+
+>>> checker = buildout.Checker(filename=buildout_path,
+... verbose=True,
+... incremental=True,
+... blacklist=blacklist_path)
+>>> checker.check()
+# Checking buildout file ...
+Reading file:///.../zope.interface/
+zope.interface=3.6.1 # was: 3.4.1
+Reading file:///.../zope.component/
+zope.component=3.4.0
+
>>> os.remove(blacklist_path)
>>> os.remove(buildout_path)
+
console script
--------------
Modified: z3c.checkversions/trunk/z3c/checkversions/main.py
===================================================================
--- z3c.checkversions/trunk/z3c/checkversions/main.py 2010-07-25 16:03:22 UTC (rev 115089)
+++ z3c.checkversions/trunk/z3c/checkversions/main.py 2010-07-25 18:07:12 UTC (rev 115090)
@@ -47,6 +47,12 @@
default="",
help=u"Provide a blacklist file with bad versions")
+ parser.add_option('-1', '--incremental',
+ dest='incremental',
+ action='store_true',
+ default=False,
+ help=u"Suggest only one upgrade. Skip others.")
+
parser.add_option('-v', '--verbose',
dest='verbose',
action='store_true',
@@ -72,11 +78,13 @@
import buildout
checker = buildout.Checker(filename=buildoutcfg,
blacklist=options.blacklist,
+ incremental=options.incremental,
verbose=options.verbose,
**kw)
else:
import installed
checker = installed.Checker(blacklist=options.blacklist,
+ incremental=options.incremental,
verbose=options.verbose)
checker.check(level=options.level)
More information about the checkins
mailing list