Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: third_party/logilab/common/textutils.py

Issue 739393004: Revert "Revert "pylint: upgrade to 1.3.1"" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/logilab/common/testlib.py ('k') | third_party/logilab/common/umessage.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/logilab/common/textutils.py
===================================================================
--- third_party/logilab/common/textutils.py (revision 293047)
+++ third_party/logilab/common/textutils.py (working copy)
@@ -284,11 +284,14 @@
dict of {'key': 'value'}. When the same key is encountered multiple time,
value is turned into a list containing all values.
- >>> text_to_dict('''multiple=1
+ >>> d = text_to_dict('''multiple=1
... multiple= 2
... single =3
... ''')
- {'single': '3', 'multiple': ['1', '2']}
+ >>> d['single']
+ '3'
+ >>> d['multiple']
+ ['1', '2']
"""
res = {}
@@ -313,6 +316,8 @@
__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,
@@ -352,12 +357,12 @@
"""
if inter is None:
inter = final
- string = _BLANK_RE.sub('', string)
+ fstring = _BLANK_RE.sub('', string)
+ if not (fstring and _VALIDATION_RE.match(fstring)):
+ raise ValueError("Invalid unit string: %r." % string)
values = []
- for match in value_reg.finditer(string):
+ for match in value_reg.finditer(fstring):
dic = match.groupdict()
- #import sys
- #print >> sys.stderr, dic
lit, unit = dic["value"], dic.get("unit")
value = inter(lit)
if unit is not None:
« no previous file with comments | « third_party/logilab/common/testlib.py ('k') | third_party/logilab/common/umessage.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698