Index: third_party/logilab/common/textutils.py |
diff --git a/third_party/logilab/common/textutils.py b/third_party/logilab/common/textutils.py |
index 9046f975b7c66c8ac3823029137b14b97c27c74b..bdeed415f0244a26552cf43d5b578c03479274ce 100644 |
--- a/third_party/logilab/common/textutils.py |
+++ b/third_party/logilab/common/textutils.py |
@@ -284,14 +284,11 @@ def text_to_dict(text): |
dict of {'key': 'value'}. When the same key is encountered multiple time, |
value is turned into a list containing all values. |
- >>> d = text_to_dict('''multiple=1 |
+ >>> text_to_dict('''multiple=1 |
... multiple= 2 |
... single =3 |
... ''') |
- >>> d['single'] |
- '3' |
- >>> d['multiple'] |
- ['1', '2'] |
+ {'single': '3', 'multiple': ['1', '2']} |
""" |
res = {} |
@@ -316,8 +313,6 @@ _BLANK_RE = re.compile(_BLANK_URE) |
__VALUE_URE = r'-?(([0-9]+\.[0-9]*)|((0x?)?[0-9]+))' |
__UNITS_URE = r'[a-zA-Z]+' |
_VALUE_RE = re.compile(r'(?P<value>%s)(?P<unit>%s)?'%(__VALUE_URE, __UNITS_URE)) |
-_VALIDATION_RE = re.compile(r'^((%s)(%s))*(%s)?$' % (__VALUE_URE, __UNITS_URE, |
- __VALUE_URE)) |
BYTE_UNITS = { |
"b": 1, |
@@ -357,12 +352,12 @@ def apply_units(string, units, inter=None, final=float, blank_reg=_BLANK_RE, |
""" |
if inter is None: |
inter = final |
- fstring = _BLANK_RE.sub('', string) |
- if not (fstring and _VALIDATION_RE.match(fstring)): |
- raise ValueError("Invalid unit string: %r." % string) |
+ string = _BLANK_RE.sub('', string) |
values = [] |
- for match in value_reg.finditer(fstring): |
+ for match in value_reg.finditer(string): |
dic = match.groupdict() |
+ #import sys |
+ #print >> sys.stderr, dic |
lit, unit = dic["value"], dic.get("unit") |
value = inter(lit) |
if unit is not None: |