[Checkins] SVN: z3c.checkversions/tags/0.4/ tag 0.4

Christophe Combelles ccomb at free.fr
Sun Jul 25 18:50:21 EDT 2010


Log message for revision 115094:
  tag 0.4
  

Changed:
  A   z3c.checkversions/tags/0.4/
  D   z3c.checkversions/tags/0.4/CHANGELOG.txt
  A   z3c.checkversions/tags/0.4/CHANGELOG.txt
  D   z3c.checkversions/tags/0.4/README.txt
  A   z3c.checkversions/tags/0.4/README.txt
  D   z3c.checkversions/tags/0.4/setup.py
  A   z3c.checkversions/tags/0.4/setup.py
  D   z3c.checkversions/tags/0.4/z3c/checkversions/base.py
  A   z3c.checkversions/tags/0.4/z3c/checkversions/base.py
  D   z3c.checkversions/tags/0.4/z3c/checkversions/buildout.txt
  A   z3c.checkversions/tags/0.4/z3c/checkversions/buildout.txt
  D   z3c.checkversions/tags/0.4/z3c/checkversions/main.py
  A   z3c.checkversions/tags/0.4/z3c/checkversions/main.py

-=-
Deleted: z3c.checkversions/tags/0.4/CHANGELOG.txt
===================================================================
--- z3c.checkversions/trunk/CHANGELOG.txt	2010-07-25 09:34:01 UTC (rev 115059)
+++ z3c.checkversions/tags/0.4/CHANGELOG.txt	2010-07-25 22:50:20 UTC (rev 115094)
@@ -1,24 +0,0 @@
-Changelog
-=========
-
-0.4 (unreleased)
-----------------
-
-- ...
-
-0.3 (2010-07-09)
-----------------
-
-- don't accumulate old comments
-- prefer final versions
-
-0.2 (2010-05-22)
-----------------
-
-- added a verbose option to print old versions as well
-- updated metadata, doc and license
-
-0.1 (2010-05-16)
-----------------
-
-- Initial release

Copied: z3c.checkversions/tags/0.4/CHANGELOG.txt (from rev 115093, z3c.checkversions/trunk/CHANGELOG.txt)
===================================================================
--- z3c.checkversions/tags/0.4/CHANGELOG.txt	                        (rev 0)
+++ z3c.checkversions/tags/0.4/CHANGELOG.txt	2010-07-25 22:50:20 UTC (rev 115094)
@@ -0,0 +1,27 @@
+Changelog
+=========
+
+0.4 (2010-07-26)
+----------------
+
+- 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)
+----------------
+
+- don't accumulate old comments
+- prefer final versions
+
+0.2 (2010-05-22)
+----------------
+
+- added a verbose option to print old versions as well
+- updated metadata, doc and license
+
+0.1 (2010-05-16)
+----------------
+
+- Initial release

Deleted: z3c.checkversions/tags/0.4/README.txt
===================================================================
--- z3c.checkversions/trunk/README.txt	2010-07-25 09:34:01 UTC (rev 115059)
+++ z3c.checkversions/tags/0.4/README.txt	2010-07-25 22:50:20 UTC (rev 115094)
@@ -1,90 +0,0 @@
-Introduction
-============
-
-Find newer versions of your installed Python packages, or newer versions of
-packages in a buildout file.
-
-This package provides a console script named ``checkversions``.
-
-Install
-=======
-
-you can install this package either in a virtualenv::
-
-    $ virtualenv sandbox
-    $ sandbox/bin/pip install z3c.checkversions
-    $ sandbox/bin/checkversions --help
-
-or in your system::
-
-    $ sudo pip install z3c.checkversions
-    $ checkversions --help
-
-or in a buildout::
-
-    [buildout]
-    parts = checkversions
-    
-    [checkversions]
-    recipe=zc.recipe.egg
-    eggs=z3c.checkversions [buildout]
-
-Note that buildout support is optional and must be enabled with [buildout] so
-that zc.buildout is installed as well.
-
-Usage
-=====
-
-::
-
-    $ checkversions -h
-    Usage: checkversions [-v] [-l LEVEL] [-i INDEX] [buildout_file]
-    
-    This script will check new package versions of either your current installed
-    distributions or a buildout file if provided. It can detect major or minor
-    versions availability: level 0 gets the highest version (X.y.z), level 1 gets
-    the highest intermediate version (x.Y.z), level 2 gets the highest minor
-    version (x.y.Z).  Using level 2, you can automatically retrieve all bugfix
-    versions of a buildout.
-    
-    Options:
-      -h, --help            show this help message and exit
-      -l LEVEL, --level=LEVEL
-                            Version level to check
-      -i INDEX, --index=INDEX
-                            Alternative package index URL
-      -v, --verbose         Verbose mode (prints old versions too)
-
-
-Examples
-========
-
-For installed packages
-----------------------
-
-Example with a virtualenv::
-
-    $ virtualenv --no-site-packages sandbox
-    $ sandbox/bin/pip install z3c.checkversions
-    $ sandbox/bin/checkversions -v -l 1
-    # Checking your installed distributions
-    pip=0.7.1 # was: 0.6.3
-
-For a buildout
---------------
-
-It can work either with a full buildout.cfg or with a simple versions.cfg file.
-
-Here is a sample `versions.cfg` file::
-
-    [versions]
-    pip=0.6.3
-
-You can create a new versions.cfg with the output ::
-
-    $ checkversions -v -l 1 versions.cfg
-    # Checking buildout file versions.cfg
-    pip=0.7.1 # was: 0.6.3
-
-
-

Copied: z3c.checkversions/tags/0.4/README.txt (from rev 115093, z3c.checkversions/trunk/README.txt)
===================================================================
--- z3c.checkversions/tags/0.4/README.txt	                        (rev 0)
+++ z3c.checkversions/tags/0.4/README.txt	2010-07-25 22:50:20 UTC (rev 115094)
@@ -0,0 +1,124 @@
+Introduction
+============
+
+Find newer versions of your installed Python packages, or newer versions of
+packages in a buildout file.
+
+This package provides a console script named ``checkversions``.
+
+Install
+=======
+
+you can install this package either in a virtualenv::
+
+    $ virtualenv sandbox
+    $ sandbox/bin/pip install z3c.checkversions
+    $ sandbox/bin/checkversions --help
+
+or in your system::
+
+    $ sudo pip install z3c.checkversions
+    $ checkversions --help
+
+or in a buildout::
+
+    [buildout]
+    parts = checkversions
+    
+    [checkversions]
+    recipe=zc.recipe.egg
+    eggs=z3c.checkversions [buildout]
+
+Note that buildout support is optional and must be enabled with [buildout] so
+that zc.buildout is installed as well.
+
+Usage
+=====
+
+::
+
+    $ checkversions -h
+    Usage: checkversions [-v] [-l LEVEL] [-i INDEX] [-b BLACKLIST] [buildout_file]
+    
+    This script will check new package versions of either your current installed
+    distributions or a buildout file if provided. It can detect major or minor
+    versions availability: level 0 gets the highest version (X.y.z), level 1 gets
+    the highest intermediate version (x.Y.z), level 2 gets the highest minor
+    version (x.y.Z).  Using level 2, you can automatically retrieve all bugfix
+    versions of a buildout.  If you provide a blacklist file with bad versions,
+    these versions won't be suggested.
+    
+    Options:
+      -h, --help            show this help message and exit
+      -l LEVEL, --level=LEVEL
+                            Version level to check
+      -i INDEX, --index=INDEX
+                            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
+========
+
+For installed packages
+----------------------
+
+Example with a virtualenv::
+
+    $ virtualenv --no-site-packages sandbox
+    $ sandbox/bin/pip install z3c.checkversions
+    $ sandbox/bin/checkversions -v -l 1
+    # Checking your installed distributions
+    pip=0.7.1 # was: 0.6.3
+
+For a buildout
+--------------
+
+It can work either with a full buildout.cfg or with a simple versions.cfg file.
+
+Here is a sample `versions.cfg` file::
+
+    [versions]
+    somepackage=0.5.3
+    otherpackage=0.1.1
+
+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::
+
+    somepackage=0.6.2
+    somepackage=0.6.1
+
+Then these versions won't be suggested::
+
+    $ 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
+=========
+
+Uncompress the archive, then run::
+
+    $ python setup.py test
+
+
+

Deleted: z3c.checkversions/tags/0.4/setup.py
===================================================================
--- z3c.checkversions/trunk/setup.py	2010-07-25 09:34:01 UTC (rev 115059)
+++ z3c.checkversions/tags/0.4/setup.py	2010-07-25 22:50:20 UTC (rev 115094)
@@ -1,61 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2010 Zope Foundation 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.
-#
-##############################################################################
-
-from setuptools import setup, find_packages
-import os
-
-version = '0.4dev'
-
-setup(name='z3c.checkversions',
-      version=version,
-      description="Find newer package versions on PyPI",
-      long_description=open("README.txt").read() + "\n" +
-                       open("CHANGELOG.txt").read(),
-      # Get more strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
-      classifiers=[
-       "Programming Language :: Python",
-       'Development Status :: 4 - Beta',
-       'Environment :: Console',
-       'Intended Audience :: Developers',
-       'License :: OSI Approved :: Zope Public License',
-       'Programming Language :: Python',
-       'Natural Language :: English',
-       'Operating System :: OS Independent',
-       'Topic :: Software Development :: Quality Assurance',
-       'Framework :: Zope2',
-       'Framework :: Zope3',
-       'Framework :: Buildout',
-        ],
-      keywords='version, buildout, packages, upgrade, zope, ztk',
-      author='Christophe Combelles and the Zope Community',
-      author_email='zope-dev at zope.org',
-      url='http://pypi.python.org/pypi/z3c.checkversions',
-      license='ZPL 2.1',
-      packages=find_packages(exclude=['ez_setup']),
-      namespace_packages=['z3c'],
-      include_package_data=True,
-      zip_safe=False,
-      install_requires=[
-          'setuptools',
-          # -*- Extra requirements: -*-
-      ],
-      extras_require={'buildout': ['zc.buildout']},
-      tests_require=['zc.buildout'],
-      test_suite='z3c.checkversions.test.test',
-      entry_points="""
-      # -*- Entry points: -*-
-      [console_scripts]
-      checkversions = z3c.checkversions.main:main
-      """,
-      )

Copied: z3c.checkversions/tags/0.4/setup.py (from rev 115093, z3c.checkversions/trunk/setup.py)
===================================================================
--- z3c.checkversions/tags/0.4/setup.py	                        (rev 0)
+++ z3c.checkversions/tags/0.4/setup.py	2010-07-25 22:50:20 UTC (rev 115094)
@@ -0,0 +1,61 @@
+##############################################################################
+#
+# Copyright (c) 2010 Zope Foundation 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.
+#
+##############################################################################
+
+from setuptools import setup, find_packages
+import os
+
+version = '0.4'
+
+setup(name='z3c.checkversions',
+      version=version,
+      description="Find newer package versions on PyPI",
+      long_description=open("README.txt").read() + "\n" +
+                       open("CHANGELOG.txt").read(),
+      # Get more strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
+      classifiers=[
+       "Programming Language :: Python",
+       'Development Status :: 4 - Beta',
+       'Environment :: Console',
+       'Intended Audience :: Developers',
+       'License :: OSI Approved :: Zope Public License',
+       'Programming Language :: Python',
+       'Natural Language :: English',
+       'Operating System :: OS Independent',
+       'Topic :: Software Development :: Quality Assurance',
+       'Framework :: Zope2',
+       'Framework :: Zope3',
+       'Framework :: Buildout',
+        ],
+      keywords='version, buildout, packages, upgrade, zope, ztk',
+      author='Christophe Combelles and the Zope Community',
+      author_email='zope-dev at zope.org',
+      url='http://pypi.python.org/pypi/z3c.checkversions',
+      license='ZPL 2.1',
+      packages=find_packages(exclude=['ez_setup']),
+      namespace_packages=['z3c'],
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=[
+          'setuptools',
+          # -*- Extra requirements: -*-
+      ],
+      extras_require={'buildout': ['zc.buildout']},
+      tests_require=['zc.buildout'],
+      test_suite='z3c.checkversions.test.test',
+      entry_points="""
+      # -*- Entry points: -*-
+      [console_scripts]
+      checkversions = z3c.checkversions.main:main
+      """,
+      )

Deleted: z3c.checkversions/tags/0.4/z3c/checkversions/base.py
===================================================================
--- z3c.checkversions/trunk/z3c/checkversions/base.py	2010-07-25 09:34:01 UTC (rev 115059)
+++ z3c.checkversions/tags/0.4/z3c/checkversions/base.py	2010-07-25 22:50:20 UTC (rev 115094)
@@ -1,93 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2010 Zope Foundation 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.
-#
-##############################################################################
-
-from pkg_resources import parse_version, Requirement
-from setuptools import package_index
-
-
-_final_parts = '*final-', '*final'
-def _final_version(parsed_version):
-    """Function copied from zc.buildout.easy_install._final_version
-    """
-    for part in parsed_version:
-        if (part[:1] == '*') and (part not in _final_parts):
-            return False
-    return True
-
-
-class Checker(object):
-    """Base class for version checkers
-    """
-    __custom_url = False
-    def __init__(self, index_url=None, verbose=False):
-        self.verbose = verbose
-        self.pi = package_index.PackageIndex()
-        self._set_index_url(index_url)
-        if index_url is not None:
-            self.__custom_url = True
-
-    def _set_index_url(self, url):
-        """set the index URL
-        """
-        if url is not None:
-            self.pi.index_url = url
-        if not self.pi.index_url.endswith('/'):
-            self.pi.index_url += '/'
-
-    def check(self, level=0):
-        """Search new versions in a version list
-        versions must be a dict {'name': 'version'}
-
-        The new version is limited to the given level:
-        Example with version x.y.z
-        level = 0: checks new version x
-        level = 1: checks new version y
-        level = 2: checks new version z
-
-        By default, the highest version is found.
-        """
-        versions = self.get_versions()
-
-        for name, version in versions.items():
-            parsed_version = parse_version(version)
-            req = Requirement.parse(name)
-            self.pi.find_packages(req)
-            new_dist = None
-            # loop all index versions until we find the 1st newer version
-            # that keeps the major versions (below level)
-            # and is a final version
-            for dist in self.pi[req.key]:
-                if not _final_version(dist.parsed_version):
-                    continue
-                if dist.parsed_version[:level] > parsed_version[:level]:
-                    continue
-                new_dist = dist
-                break
-
-            if new_dist and new_dist.parsed_version > parsed_version:
-                if self.verbose:
-                    print("%s=%s # was: %s"
-                          % (name, new_dist.version, version.split()[0]))
-                else:
-                    print("%s=%s" % (name, new_dist.version))
-            elif self.verbose:
-                print("%s=%s" % (name, version.split()[0]))
-
-
-    def get_versions(self):
-        """Get a dict {'name': 'version', ...} with package versions to check.
-        This should be implemented by derived classes
-        """
-        raise NotImplementedError
-

Copied: z3c.checkversions/tags/0.4/z3c/checkversions/base.py (from rev 115090, z3c.checkversions/trunk/z3c/checkversions/base.py)
===================================================================
--- z3c.checkversions/tags/0.4/z3c/checkversions/base.py	                        (rev 0)
+++ z3c.checkversions/tags/0.4/z3c/checkversions/base.py	2010-07-25 22:50:20 UTC (rev 115094)
@@ -0,0 +1,123 @@
+##############################################################################
+#
+# Copyright (c) 2010 Zope Foundation 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.
+#
+##############################################################################
+
+from pkg_resources import parse_version, Requirement
+from setuptools import package_index
+
+
+_final_parts = '*final-', '*final'
+def _final_version(parsed_version):
+    """Function copied from zc.buildout.easy_install._final_version
+    """
+    for part in parsed_version:
+        if (part[:1] == '*') and (part not in _final_parts):
+            return False
+    return True
+
+
+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,
+                 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('=')))
+                        for line in open(blacklist).readlines() if '=' in line])
+        else:
+            self.blacklist = set()
+        self.pi = package_index.PackageIndex()
+        self._set_index_url(index_url)
+        if index_url is not None:
+            self.__custom_url = True
+
+    def _set_index_url(self, url):
+        """set the index URL
+        """
+        if url is not None:
+            self.pi.index_url = url
+        if not self.pi.index_url.endswith('/'):
+            self.pi.index_url += '/'
+
+    def check(self, level=0):
+        """Search new versions in a version list
+        versions must be a dict {'name': 'version'}
+
+        The new version is limited to the given level:
+        Example with version x.y.z
+        level = 0: checks new version x
+        level = 1: checks new version y
+        level = 2: checks new version z
+
+        By default, the highest version is found.
+        """
+        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)
+            new_dist = None
+            # loop all index versions until we find the 1st newer version
+            # that keeps the major versions (below level)
+            # 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):
+                    continue
+                if dist.parsed_version[:level] > parsed_version[:level]:
+                    continue
+                new_dist = dist
+                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]))
+                else:
+                    print("%s=%s" % (name, new_dist.version))
+            elif self.verbose:
+                print("%s=%s" % (name, version.split()[0]))
+
+
+    def get_versions(self):
+        """Get a dict {'name': 'version', ...} with package versions to check.
+        This should be implemented by derived classes
+        """
+        raise NotImplementedError
+

Deleted: z3c.checkversions/tags/0.4/z3c/checkversions/buildout.txt
===================================================================
--- z3c.checkversions/trunk/z3c/checkversions/buildout.txt	2010-07-25 09:34:01 UTC (rev 115059)
+++ z3c.checkversions/tags/0.4/z3c/checkversions/buildout.txt	2010-07-25 22:50:20 UTC (rev 115094)
@@ -1,112 +0,0 @@
-Checking versions of a buildout
--------------------------------
-
-For the tests, we use two fake local indices
-
->>> import z3c.checkversions
->>> from os.path import dirname, sep
->>> testindex = 'file://' + dirname(z3c.checkversions.__file__).replace(sep, '/') + '/testindex'
->>> testindex2 = 'file://' + dirname(z3c.checkversions.__file__).replace(sep, '/') + '/testindex2'
->>> print testindex
-file:///.../testindex
-
-We create a buildout with a versions section and a custom index:
-
->>> import os
->>> from tempfile import mkstemp
->>> buildout_fd, buildout_path = mkstemp()
->>> buildout_file = os.fdopen(buildout_fd, 'w')
->>> buildout_file.write("""
-... [buildout]
-... index = %s
-... versions = versions
-... [versions]
-... zope.interface = 3.4.0
-... zope.component = 3.4.0
-... """ % testindex)
->>> buildout_file.close()
-
-We can now check the new highest versions:
-
->>> from z3c.checkversions import buildout
->>> checker = buildout.Checker(filename=buildout_path)
->>> checker.get_versions()
-# Checking buildout file ...
-{'zope.interface': '3.4.0', 'zope.component': '3.4.0'}
->>> checker.check()
-# Checking buildout file ...
-Reading file:///.../zope.interface/
-zope.interface=3.6.1
-Reading file:///.../zope.component/
-zope.component=3.9.4
-
-We can check only the minor versions:
-
->>> checker.check(level=2)
-# Checking buildout file ...
-zope.interface=3.4.1
-
-We can provide a different index url:
-
->>> checker = buildout.Checker(filename=buildout_path, index_url=testindex2)
->>> checker.check()
-# Checking buildout file ...
-Reading file:///.../zope.interface/
-zope.interface=3.6.2
-Reading file:///.../zope.component/
-zope.component=3.9.3
-
-The verbose mode gives the current and previous versions
-
->>> checker = buildout.Checker(filename=buildout_path, verbose=True)
->>> checker.check(level=2)
-# Checking buildout file ...
-Reading file:///.../zope.interface/
-zope.interface=3.4.1 # was: 3.4.0
-Reading file:///.../zope.component/
-zope.component=3.4.0
-
-The old comments are removed:
-
->>> buildout_fd, buildout_path = mkstemp()
->>> buildout_file = os.fdopen(buildout_fd, 'w')
->>> buildout_file.write("""
-... [buildout]
-... index = %s
-... versions = versions
-... [versions]
-... zope.interface = 3.4.1 # was: 3.4.0
-... zope.component = 3.4.0
-... """ % testindex)
->>> buildout_file.close()
-
->>> checker = buildout.Checker(filename=buildout_path, verbose=True)
->>> 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.9.4 # was: 3.4.0
-
-
-
-console script
---------------
-
-the 'main' module is exposed through a console_script entry point.
-We are using it directly here:
-
->>> import sys
->>> from z3c.checkversions import main
->>> from subprocess import Popen, PIPE
->>> p = Popen([sys.executable, main.__file__, '-h'],
-...           stdout=PIPE, stdin=PIPE, stderr=PIPE)
->>> print p.stdout.read()
-Usage: ...
-...
-
-
-Clean the tmp file:
-
->>> os.remove(buildout_path)
-

Copied: z3c.checkversions/tags/0.4/z3c/checkversions/buildout.txt (from rev 115091, z3c.checkversions/trunk/z3c/checkversions/buildout.txt)
===================================================================
--- z3c.checkversions/tags/0.4/z3c/checkversions/buildout.txt	                        (rev 0)
+++ z3c.checkversions/tags/0.4/z3c/checkversions/buildout.txt	2010-07-25 22:50:20 UTC (rev 115094)
@@ -0,0 +1,146 @@
+Checking versions of a buildout
+-------------------------------
+
+For the tests, we use two fake local indices
+
+>>> import z3c.checkversions
+>>> from os.path import dirname, sep
+>>> testindex = 'file://' + dirname(z3c.checkversions.__file__).replace(sep, '/') + '/testindex'
+>>> testindex2 = 'file://' + dirname(z3c.checkversions.__file__).replace(sep, '/') + '/testindex2'
+>>> print testindex
+file:///.../testindex
+
+We create a buildout with a versions section and a custom index:
+
+>>> import os
+>>> from tempfile import mkstemp
+>>> buildout_fd, buildout_path = mkstemp()
+>>> buildout_file = os.fdopen(buildout_fd, 'w')
+>>> buildout_file.write("""
+... [buildout]
+... index = %s
+... versions = versions
+... [versions]
+... zope.interface = 3.4.0
+... zope.component = 3.4.0
+... """ % testindex)
+>>> buildout_file.close()
+
+We can now check the new highest versions:
+
+>>> from z3c.checkversions import buildout
+>>> checker = buildout.Checker(filename=buildout_path)
+>>> checker.get_versions()
+# Checking buildout file ...
+{'zope.interface': '3.4.0', 'zope.component': '3.4.0'}
+>>> checker.check()
+# Checking buildout file ...
+Reading file:///.../zope.interface/
+zope.interface=3.6.1
+Reading file:///.../zope.component/
+zope.component=3.9.4
+
+We can check only the minor versions:
+
+>>> checker.check(level=2)
+# Checking buildout file ...
+zope.interface=3.4.1
+
+We can provide a different index url:
+
+>>> checker = buildout.Checker(filename=buildout_path, index_url=testindex2)
+>>> checker.check()
+# Checking buildout file ...
+Reading file:///.../zope.interface/
+zope.interface=3.6.2
+Reading file:///.../zope.component/
+zope.component=3.9.3
+
+The verbose mode gives the current and previous versions
+
+>>> checker = buildout.Checker(filename=buildout_path, verbose=True)
+>>> checker.check(level=2)
+# Checking buildout file ...
+Reading file:///.../zope.interface/
+zope.interface=3.4.1 # was: 3.4.0
+Reading file:///.../zope.component/
+zope.component=3.4.0
+
+The old comments are removed:
+
+>>> os.remove(buildout_path)
+>>> buildout_fd, buildout_path = mkstemp()
+>>> buildout_file = os.fdopen(buildout_fd, 'w')
+>>> buildout_file.write("""
+... [buildout]
+... index = %s
+... versions = versions
+... [versions]
+... zope.interface = 3.4.1 # was: 3.4.0
+... zope.component = 3.4.0
+... """ % testindex)
+>>> buildout_file.close()
+
+>>> checker = buildout.Checker(filename=buildout_path, verbose=True)
+>>> 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.9.4 # was: 3.4.0
+
+We can provide a blacklist file, containing versions to not suggest.
+This file may come from a buildbot remembering failures.
+
+>>> blacklist_fd, blacklist_path = mkstemp()
+>>> blacklist_file = os.fdopen(blacklist_fd, 'w')
+>>> blacklist_file.write("""
+... zope.component =3.9.4  
+... zope.component = 3.9.3""")
+>>> blacklist_file.close()
+
+>>> checker = buildout.Checker(filename=buildout_path,
+...                            verbose=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.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
+zope.component=3.4.0
+
+>>> os.remove(blacklist_path)
+>>> os.remove(buildout_path)
+
+
+console script
+--------------
+
+the 'main' module is exposed through a console_script entry point.
+We are using it directly here:
+
+>>> import sys
+>>> from z3c.checkversions import main
+>>> from subprocess import Popen, PIPE
+>>> p = Popen([sys.executable, main.__file__, '-h'],
+...           stdout=PIPE, stdin=PIPE, stderr=PIPE)
+
+# the "usage" attribute of optparse is inconsistent between python versions
+>>> p.stdout.read().lower().startswith('usage: ')
+True
+
+
+

Deleted: z3c.checkversions/tags/0.4/z3c/checkversions/main.py
===================================================================
--- z3c.checkversions/trunk/z3c/checkversions/main.py	2010-07-25 09:34:01 UTC (rev 115059)
+++ z3c.checkversions/tags/0.4/z3c/checkversions/main.py	2010-07-25 22:50:20 UTC (rev 115094)
@@ -1,73 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2010 Zope Foundation 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.
-#
-##############################################################################
-"""This script will check new package versions of either
-your current installed distributions or a buildout file if provided.
-It can detect major or minor versions availability:
-level 0 gets the highest version (X.y.z),
-level 1 gets the highest intermediate version (x.Y.z),
-level 2 gets the highest minor version (x.y.Z).
-
-Using level 2, you can automatically retrieve all bugfix versions of a buildout.
-"""
-
-from optparse import OptionParser
-
-def main():
-
-    usage = u"Usage: %prog [-v] [-l LEVEL] [-i INDEX] [buildout_file]"
-    parser = OptionParser(description=__doc__, usage=usage)
-
-    parser.add_option('-l', '--level',
-                      type='int',
-                      dest='level',
-                      default=0,
-                      help=u"Version level to check")
-
-    parser.add_option('-i', '--index',
-                      dest='index',
-                      help=u"Alternative package index URL")
-
-    parser.add_option('-v', '--verbose',
-                      dest='verbose',
-                      action='store_true',
-                      default=False,
-                      help=u"Verbose mode (prints old versions too)")
-    options, args = parser.parse_args()
-
-    if len(args) > 1:
-        parser.error("You must specify only one argument")
-
-    buildoutcfg = False
-    if len(args) == 1:
-        buildoutcfg = args[0]
-
-    kw = {}
-    if options.index is not None:
-        kw['index_url'] = options.index
-
-    if buildoutcfg:
-        import buildout
-        checker = buildout.Checker(filename=buildoutcfg,
-                                   verbose=options.verbose,
-                                   **kw)
-    else:
-        import installed
-        checker = installed.Checker(verbose=options.verbose)
-
-    checker.check(level=options.level)
-
-
-if __name__ == '__main__':
-    main()
-

Copied: z3c.checkversions/tags/0.4/z3c/checkversions/main.py (from rev 115090, z3c.checkversions/trunk/z3c/checkversions/main.py)
===================================================================
--- z3c.checkversions/tags/0.4/z3c/checkversions/main.py	                        (rev 0)
+++ z3c.checkversions/tags/0.4/z3c/checkversions/main.py	2010-07-25 22:50:20 UTC (rev 115094)
@@ -0,0 +1,95 @@
+##############################################################################
+#
+# Copyright (c) 2010 Zope Foundation 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.
+#
+##############################################################################
+"""This script will check new package versions of either
+your current installed distributions or a buildout file if provided.
+It can detect major or minor versions availability:
+level 0 gets the highest version (X.y.z),
+level 1 gets the highest intermediate version (x.Y.z),
+level 2 gets the highest minor version (x.y.Z).
+
+Using level 2, you can automatically retrieve all bugfix versions of a buildout.
+
+If you provide a blacklist file with bad versions, these versions won't be
+suggested.
+"""
+
+from optparse import OptionParser
+import os
+
+def main():
+
+    usage = u"Usage: %prog [-v] [-l LEVEL] [-i INDEX] [-b BLACKLIST] [buildout_file]"
+    parser = OptionParser(description=__doc__, usage=usage)
+
+    parser.add_option('-l', '--level',
+                      type='int',
+                      dest='level',
+                      default=0,
+                      help=u"Version level to check")
+
+    parser.add_option('-i', '--index',
+                      dest='index',
+                      help=u"Provide and alternative package index URL")
+
+    parser.add_option('-b', '--blacklist',
+                      dest='blacklist',
+                      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',
+                      default=False,
+                      help=u"Verbose mode (prints old versions too)")
+    options, args = parser.parse_args()
+
+    if len(args) > 1:
+        parser.error("You must specify only one argument")
+
+    if options.blacklist != "" and not os.path.exists(options.blacklist):
+        parser.error('The blacklist file "%s" does not exist!' % options.blacklist)
+
+    buildoutcfg = False
+    if len(args) == 1:
+        buildoutcfg = args[0]
+
+    kw = {}
+    if options.index is not None:
+        kw['index_url'] = options.index
+
+    if buildoutcfg:
+        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)
+
+
+if __name__ == '__main__':
+    main()
+



More information about the checkins mailing list