diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | __pkginfo__.py | 2 | ||||
-rw-r--r-- | adbh.py | 5 | ||||
-rw-r--r-- | context.py | 11 | ||||
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | debian/control | 2 | ||||
-rw-r--r-- | graph.py | 6 | ||||
-rw-r--r-- | test/unittest_context.py | 38 |
9 files changed, 73 insertions, 7 deletions
@@ -1,7 +1,12 @@ ChangeLog for logilab.common ============================ - -- +2008-09-10 -- 0.35.0 + + * fix #5945: wrong edge proporties in graph.DotBackend + + * testlib: filter tests with tag decorator + * shellutils: new simple unzip function 2008-08-07 -- 0.34.0 @@ -60,6 +60,9 @@ Here is a brief description of the available modules : Two mix-in classes to handle configuration from both command line (using optik/optparse) and configuration file. +* context.py : + One context manager (python 2.5+) to handle temporary directories. + * corbautils.py: Usefull functions for use with the OmniORB CORBA library. diff --git a/__pkginfo__.py b/__pkginfo__.py index b84461a..1fda9e9 100644 --- a/__pkginfo__.py +++ b/__pkginfo__.py @@ -8,7 +8,7 @@ __docformat__ = "restructuredtext en" distname = 'logilab-common' modname = 'common' -numversion = (0, 34, 0) +numversion = (0, 35, 0) version = '.'.join([str(num) for num in numversion]) license = 'GPL' @@ -257,7 +257,10 @@ INSERT INTO %s VALUES (0);''' % (seq_name, seq_name) def drop_index(self, cursor, table, column, unique=False): if self.index_exists(cursor, table, column, unique): idx = self._index_name(table, column, unique) - cursor.execute('DROP INDEX %s' % idx) + if unique: + cursor.execute('ALTER TABLE %s DROP CONSTRAINT %s' % (table, idx)) + else: + cursor.execute('DROP INDEX %s' % idx) def index_exists(self, cursor, table, column, unique=False): idx = self._index_name(table, column, unique) diff --git a/context.py b/context.py new file mode 100644 index 0000000..39c32a4 --- /dev/null +++ b/context.py @@ -0,0 +1,11 @@ +from contextlib import contextmanager +import tempfile +import shutil + +@contextmanager +def tempdir(ignore_error=False, onerror=None): + try: + path = tempfile.mkdtemp() + yield path + finally: + shutil.rmtree(path, ignore_error, onerror) diff --git a/debian/changelog b/debian/changelog index 82ed194..4f90842 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +logilab-common (0.35.0-1) unstable; urgency=low + + * new upstream release + + -- Emile Anclin <emile.anclin@logilab.fr> Wed, 10 Sep 2008 14:17:23 +0200 + logilab-common (0.34.0-1) unstable; urgency=low * new upstream release diff --git a/debian/control b/debian/control index fbb3573..7815729 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ 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 Homepage: http://www.logilab.org/project/logilab-common -Standards-Version: 3.7.3 +Standards-Version: 3.8.0 Package: python-logilab-common Architecture: all @@ -54,7 +54,7 @@ class DotBackend: def get_source(self): """returns self._source""" if self._source is None: - self.emit("}") + self.emit("}\n") self._source = '\n'.join(self.lines) del self.lines return self._source @@ -104,8 +104,8 @@ class DotBackend: Authorized props: see http://www.graphviz.org/doc/info/attrs.html """ attrs = ['%s="%s"' % (prop, value) for prop, value in props.items()] - self.emit('edge [%s];' % ", ".join(attrs)) - self.emit('%s -> %s' % (normalize_node_id(name1), normalize_node_id(name2))) + n_from, n_to = normalize_node_id(name1), normalize_node_id(name2) + self.emit('%s -> %s edge [%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/test/unittest_context.py b/test/unittest_context.py new file mode 100644 index 0000000..11fbe98 --- /dev/null +++ b/test/unittest_context.py @@ -0,0 +1,38 @@ +TEST = """ +from __future__ import with_statement +from os.path import isdir, exists +import shutil +from logilab.common.testlib import TestCase, unittest_main +from logilab.common.context import tempdir + +class ContextTC(TestCase): + + def test_withtempdir(self): + with tempdir() as tmpdir: + assert exists(tmpdir) + assert isdir(tmpdir) + assert not exists(tmpdir) + try: + with tempdir() as tmpdir: + assert exists(tmpdir) + shutil.rmtree(tmpdir) + except OSError: + pass + else: + self.assertTrue(False, "we should fail") + assert not exists(tmpdir) + with tempdir(ignore_error=True) as tmpdir: + shutil.rmtree(tmpdir) + def rmtree_handler(func, path, excinfo): + self.assertTrue(issubclass(excinfo[0], OSError)) + with tempdir(onerror=rmtree_handler) as tmpdir: + shutil.rmtree(tmpdir) +try: + unittest_main() +except SystemExit: + pass +""" + +import sys +if sys.version_info[:2] >= (2, 5): + exec(TEST) |