diff options
author | Nicolas Chauvat <nicolas.chauvat@logilab.fr> | 2008-11-14 13:09:51 +0100 |
---|---|---|
committer | Nicolas Chauvat <nicolas.chauvat@logilab.fr> | 2008-11-14 13:09:51 +0100 |
commit | 1b7fe6a5fc9b101a46e9bda27b6f206d11b6cfe9 (patch) | |
tree | a720d620590c979664886d9ed32ed71685342ac4 | |
parent | 871009629bdc1c55709470a4d5bb36a7a38c41e1 (diff) | |
parent | 75f1b62191d9f294b6c518b482ec050feae05140 (diff) | |
download | logilab-common-1b7fe6a5fc9b101a46e9bda27b6f206d11b6cfe9.tar.gz |
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | __pkginfo__.py | 2 | ||||
-rw-r--r-- | configuration.py | 5 | ||||
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | debian/control | 2 | ||||
-rw-r--r-- | graph.py | 2 | ||||
-rw-r--r-- | optik_ext.py | 8 | ||||
-rw-r--r-- | pytest.py | 2 | ||||
-rw-r--r-- | shellutils.py | 33 | ||||
-rw-r--r-- | test/unittest_shellutils.py | 21 | ||||
-rw-r--r-- | testlib.py | 2 |
11 files changed, 83 insertions, 15 deletions
@@ -1,6 +1,21 @@ ChangeLog for logilab.common ============================ +2008-10-30 -- 0.36.0 + * configuration: + - option yn is now behaving like a flag (i.e --ex : if ex.default=True and --ex in sys.args then ex.value=False) + - new attribute hide in option (i.e --ex : if --ex has 'hide':True then the option will not be displayed in man or --help) + + * pytest: + - add colors in display + - new option --restart that skips tests that succeeded on last run + + * cache: new herits from dict class + + * decorators: add @require_version @require_module that skip test if decorators are not satisfied + + + 2008-10-09 -- 0.35.3 * graph: new has_path method diff --git a/__pkginfo__.py b/__pkginfo__.py index 334d884..19e4206 100644 --- a/__pkginfo__.py +++ b/__pkginfo__.py @@ -8,7 +8,7 @@ __docformat__ = "restructuredtext en" distname = 'logilab-common' modname = 'common' -numversion = (0, 35, 3) +numversion = (0, 36, 0) version = '.'.join([str(num) for num in numversion]) license = 'GPL' diff --git a/configuration.py b/configuration.py index ac27166..943de94 100644 --- a/configuration.py +++ b/configuration.py @@ -162,7 +162,7 @@ def password_validator(opt_dict, name, value): def date_validator(opt_dict, name, value): """validate and return a mx DateTime object for option of type 'date'""" - return check_password(None, name, value) + return check_date(None, name, value) VALIDATORS = {'string' : unquote, @@ -378,7 +378,8 @@ class OptionsManagerMixIn(object): """add an option group including the listed options """ # add section to the config file - self._config_parser.add_section(group_name) + if group_name != "DEFAULT": + self._config_parser.add_section(group_name) # add option group to the command line parser if options: group = OptionGroup(self._optik_parser, diff --git a/debian/changelog b/debian/changelog index 4fd86a6..6edf74f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +logilab-common (0.36.0-1) unstable; urgency=low + + * new upstream release + + -- Fabrice Douchant <fabrice.douchant@logilab.fr> Thu, 30 Oct 2008 14:48:17 +0100 + logilab-common (0.35.3-1) unstable; urgency=low * new upstream release diff --git a/debian/control b/debian/control index 7815729..8827eec 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: logilab-common Section: python Priority: optional Maintainer: Alexandre Fayolle <afayolle@debian.org> -Uploaders: David Douard <david.douard@logilab.fr> +Uploaders: David Douard <david.douard@logilab.fr> , Fabrice Douchant <fabrice.douchant@logilab.fr> Build-Depends: debhelper (>= 5.0.38), python-all-dev (>= 2.3.5-11) Build-Depends-Indep: python (>=2.3.5-7), python-central (>=0.5.6) XS-Python-Version: all @@ -105,7 +105,7 @@ class DotBackend: """ attrs = ['%s="%s"' % (prop, value) for prop, value in props.items()] n_from, n_to = normalize_node_id(name1), normalize_node_id(name2) - self.emit('%s -> %s edge [%s];' % (n_from, n_to, ", ".join(attrs)) ) + self.emit('%s -> %s [%s];' % (n_from, n_to, ", ".join(attrs)) ) def emit_node(self, name, **props): """Authorized props: see http://www.graphviz.org/doc/info/attrs.html diff --git a/optik_ext.py b/optik_ext.py index 123a2a6..2074fe6 100644 --- a/optik_ext.py +++ b/optik_ext.py @@ -29,7 +29,7 @@ try: # python >= 2.3 from optparse import OptionParser as BaseParser, Option as BaseOption, \ OptionGroup, OptionValueError, OptionError, Values, HelpFormatter, \ - NO_DEFAULT + NO_DEFAULT, SUPPRESS_HELP except ImportError: # python < 2.3 from optik import OptionParser as BaseParser, Option as BaseOption, \ @@ -153,6 +153,7 @@ class Option(BaseOption): """ TYPES = BaseOption.TYPES + ('regexp', 'csv', 'yn', 'named', 'password', 'multiple_choice', 'file', 'font', 'color') + ATTRS = BaseOption.ATTRS + ['hide'] TYPE_CHECKER = copy(BaseOption.TYPE_CHECKER) TYPE_CHECKER['regexp'] = check_regexp TYPE_CHECKER['csv'] = check_csv @@ -166,6 +167,11 @@ class Option(BaseOption): TYPES += ('date',) TYPE_CHECKER['date'] = check_date + def __init__(self, *opts, **attrs): + BaseOption.__init__(self, *opts, **attrs) + if hasattr(self, "hide") and self.hide: + self.help = SUPPRESS_HELP + def _check_choice(self): """FIXME: need to override this due to optik misdesign""" if self.type in ("choice", "multiple_choice"): @@ -583,7 +583,7 @@ def make_parser(): dest="exitfirst", default=False, action="callback", help="Exit on first failure " "(only make sense when pytest run one test file)") - parser.add_option('-r', '--restart', callback=rebuild_and_store, + parser.add_option('-R', '--restart', callback=rebuild_and_store, dest="restart", default=False, action="callback", help="Restart tests from where it failed (implies exitfirst) " diff --git a/shellutils.py b/shellutils.py index f6072f1..6a7509d 100644 --- a/shellutils.py +++ b/shellutils.py @@ -8,12 +8,13 @@ scripts. """ __docformat__ = "restructuredtext en" -import os +import os import glob import shutil import sys import tempfile import time +import fnmatch from os.path import exists, isdir, islink, basename, join, walk from logilab.common import STD_BLACKLIST @@ -141,6 +142,35 @@ def find(directory, exts, exclude=False, blacklist=STD_BLACKLIST): return files +def globfind(directory, pattern, blacklist=STD_BLACKLIST): + """Recursively finds files matching glob `pattern` under `directory`. + + This is an alternative to `logilab.common.shellutils.find`. + + :type directory: str + :param directory: + directory where the search should start + + :type pattern: basestring + :param pattern: + the glob pattern (e.g *.py, foo*.py, etc.) + + :type blacklist: list or tuple + :param blacklist: + optional list of files or directory to ignore, default to the value of + `logilab.common.STD_BLACKLIST` + + :rtype: iterator + :return: + iterator over the list of all matching files + """ + for curdir, dirnames, filenames in os.walk(directory): + for fname in fnmatch.filter(filenames, pattern): + yield join(curdir, fname) + for skipped in blacklist: + if skipped in dirnames: + dirnames.remove(skipped) + def unzip(archive, destdir): import zipfile if not exists(destdir): @@ -154,7 +184,6 @@ def unzip(archive, destdir): outfile.write(zfobj.read(name)) outfile.close() - class Execute: """This is a deadlock safe version of popen2 (no stdin), that returns an object with errorlevel, out and err. diff --git a/test/unittest_shellutils.py b/test/unittest_shellutils.py index 5e63170..396d7c6 100644 --- a/test/unittest_shellutils.py +++ b/test/unittest_shellutils.py @@ -5,7 +5,7 @@ from os.path import join from logilab.common.testlib import TestCase, unittest_main -from logilab.common.shellutils import find, ProgressBar +from logilab.common.shellutils import globfind, find, ProgressBar from StringIO import StringIO DATA_DIR = join('data','find_test') @@ -36,10 +36,21 @@ class FindTC(TestCase): join('sub', 'doc.txt'), 'write_protected_file.txt', ]])) - -# def test_exclude_base_dir(self): -# self.assertEquals(files_by_ext(DATA_DIR, include_exts=('.py',), exclude_dirs=(DATA_DIR,)), -# []) + + def test_globfind(self): + files = set(globfind(DATA_DIR, '*.py')) + self.assertSetEqual(files, + set([join(DATA_DIR, f) for f in ['__init__.py', 'module.py', + 'module2.py', 'noendingnewline.py', + 'nonregr.py', join('sub', 'momo.py')]])) + files = set(globfind(DATA_DIR, 'mo*.py')) + self.assertSetEqual(files, + set([join(DATA_DIR, f) for f in ['module.py', 'module2.py', + join('sub', 'momo.py')]])) + files = set(globfind(DATA_DIR, 'mo*.py', blacklist=('sub',))) + self.assertSetEqual(files, + set([join(DATA_DIR, f) for f in ['module.py', 'module2.py']])) + class ProgressBarTC(TestCase): def test_refresh(self): @@ -80,7 +80,7 @@ DEFAULT_PREFIXES = ('test', 'regrtest', 'smoketest', 'unittest', ENABLE_DBC = False -FILE_RESTART = ".restart" +FILE_RESTART = ".pytest.restart" def with_tempdir(callable): |