diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2010-09-24 14:44:16 +0200 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2010-09-24 14:44:16 +0200 |
commit | 2c6b07b2740b1d23617aa103e108e016766b6186 (patch) | |
tree | 1869c280aa98b60ce9c02594738c766a1da53f0b | |
parent | b8d45493069b9374d7b354189abd63f96c49a966 (diff) | |
download | logilab-common-2c6b07b2740b1d23617aa103e108e016766b6186.tar.gz |
py2.3 compat : import compat.set, remove deprecated stuff
-rw-r--r-- | configuration.py | 3 | ||||
-rw-r--r-- | deprecation.py | 6 | ||||
-rw-r--r-- | graph.py | 3 | ||||
-rw-r--r-- | proc.py | 3 | ||||
-rw-r--r-- | shellutils.py | 9 | ||||
-rw-r--r-- | test/unittest_shellutils.py | 2 |
6 files changed, 10 insertions, 16 deletions
diff --git a/configuration.py b/configuration.py index 5347539..543f534 100644 --- a/configuration.py +++ b/configuration.py @@ -115,13 +115,10 @@ from warnings import warn from logilab.common.compat import set, reversed from logilab.common.textutils import normalize_text, unquote -from logilab.common.deprecation import deprecated from logilab.common import optik_ext as optparse REQUIRED = [] -check_csv = deprecated('use lgc.optik_ext.check_csv')(optparse.check_csv) - class UnsupportedAction(Exception): """raised by set_option when it doesn't know what to do for an action""" diff --git a/deprecation.py b/deprecation.py index 4eff2b2..c43bc03 100644 --- a/deprecation.py +++ b/deprecation.py @@ -82,7 +82,10 @@ def deprecated(reason=None, stacklevel=2): def wrapped(*args, **kwargs): warn(message, DeprecationWarning, stacklevel=stacklevel) return func(*args, **kwargs) - wrapped.__name__ = func.__name__ + try: + wrapped.__name__ = func.__name__ + except TypeError: # readonly attribute in 2.3 + pass wrapped.__doc__ = func.__doc__ return wrapped return deprecated_decorator @@ -106,5 +109,4 @@ def moved(modpath, objname): return getattr(m, objname)(*args, **kwargs) return callnew -obsolete = deprecated('obsolete is deprecated, use deprecated instead')(deprecated) @@ -28,6 +28,7 @@ import os.path as osp import os import sys import tempfile +from logilab.common.compat import sorted, reversed def escape(value): """Make <value> usable in a dot file.""" @@ -183,7 +184,7 @@ def ordered_nodes(graph): """ cycles = get_cycles(graph) if cycles: - cycles = '\n'.join(' -> '.join(cycle) for cycle in cycles) + cycles = '\n'.join([' -> '.join(cycle) for cycle in cycles]) raise UnorderableGraph(cycles) ordered = [] while graph: @@ -71,7 +71,8 @@ class ProcInfo(Node): return 0 def lineage_memory_usage(self): - return self.memory_usage() + sum(child.lineage_memory_usage() for child in self.children) + return self.memory_usage() + sum([child.lineage_memory_usage() + for child in self.children]) def time(self, children=0): """return the number of jiffies that this process has been scheduled diff --git a/shellutils.py b/shellutils.py index 4c6e8a8..8e3cc3e 100644 --- a/shellutils.py +++ b/shellutils.py @@ -339,13 +339,6 @@ class ProgressBar(object): self._last_text_write_size = len(text.rstrip()) self._stream.flush() -from logilab.common.deprecation import deprecated - -@deprecated('confirm() is deprecated, use RawInput.confirm() instead') -def confirm(question, default_is_yes=True): - """ask for confirmation and return true on positive answer""" - return RawInput().confirm(question, default_is_yes) - class RawInput(object): @@ -365,7 +358,7 @@ class RawInput(object): label += '(%s)' % option[1:].lower() choices.append((option, label)) prompt = "%s [%s]: " % (question, - '/'.join(opt[1] for opt in choices)) + '/'.join([opt[1] for opt in choices])) tries = 3 while tries > 0: answer = self._input(prompt).strip().lower() diff --git a/test/unittest_shellutils.py b/test/unittest_shellutils.py index c795c14..d919205 100644 --- a/test/unittest_shellutils.py +++ b/test/unittest_shellutils.py @@ -25,7 +25,7 @@ from logilab.common.testlib import TestCase, unittest_main from logilab.common.shellutils import (globfind, find, ProgressBar, acquire_lock, release_lock, - RawInput, confirm) + RawInput) from logilab.common.proc import NoSuchProcess from StringIO import StringIO |