[optik_ext] Merge textutils imports

authorRémi Cardona <remi.cardona@logilab.fr>
changesetad40b2f7b256
branchdefault
phasepublic
hiddenno
parent revision#09fc1c367857 Use next(iterator) instead of py3k incompatible iterator.next() (related to #264017)
child revision#f07a5a5b3f4a [test] fix text_to_dict doctest (closes #174440)
files modified by this revision
optik_ext.py
# HG changeset patch
# User Rémi Cardona <remi.cardona@logilab.fr>
# Date 1409140546 -7200
# Wed Aug 27 13:55:46 2014 +0200
# Node ID ad40b2f7b2569860df30dd6bf424245d2b0ad9eb
# Parent 09fc1c367857ba9e15401466fc6a9e99c95d3579
[optik_ext] Merge textutils imports

diff --git a/optik_ext.py b/optik_ext.py
@@ -63,11 +63,13 @@
1      from mx import DateTime
2      HAS_MX_DATETIME = True
3  except ImportError:
4      HAS_MX_DATETIME = False
5 
6 -from logilab.common.textutils import splitstrip
7 +from logilab.common.textutils import splitstrip, TIME_UNITS, BYTE_UNITS, \
8 +    apply_units
9 +
10 
11  def check_regexp(option, opt, value):
12      """check a regexp value by trying to compile it
13      return the compiled regexp
14      """
@@ -163,17 +165,15 @@
15      msg = "option %s: invalid color : %r, should be either hexadecimal \
16      value or predefined color"
17      raise OptionValueError(msg % (opt, value))
18 
19  def check_time(option, opt, value):
20 -    from logilab.common.textutils import TIME_UNITS, apply_units
21      if isinstance(value, (int, long, float)):
22          return value
23      return apply_units(value, TIME_UNITS)
24 
25  def check_bytes(option, opt, value):
26 -    from logilab.common.textutils import BYTE_UNITS, apply_units
27      if hasattr(value, '__int__'):
28          return value
29      return apply_units(value, BYTE_UNITS)
30 
31