Fixed compatibility of ck2cti with Python 2.6
re.sub doesn't accept the flags keyword argument until 2.7, but the same effect can be achieved using re.compile.
This commit is contained in:
parent
9a1d6532ba
commit
b82df1b1ea
1 changed files with 8 additions and 8 deletions
|
|
@ -981,20 +981,20 @@ class Parser(object):
|
|||
quantity_units = self.quantity_units
|
||||
if 'units' in entry.lower():
|
||||
for units in sorted(QUANTITY_UNITS, key=lambda k: -len(k)):
|
||||
m = re.search(r'units *\/ *%s *\/' % re.escape(units),
|
||||
entry, re.IGNORECASE)
|
||||
pattern = re.compile(r'units *\/ *%s *\/' % re.escape(units),
|
||||
flags=re.IGNORECASE)
|
||||
m = pattern.search(entry)
|
||||
if m:
|
||||
entry = re.sub(r'units *\/ *%s *\/' % re.escape(units), '',
|
||||
entry, flags=re.IGNORECASE)
|
||||
entry = pattern.sub('', entry)
|
||||
quantity_units = QUANTITY_UNITS[units]
|
||||
break
|
||||
|
||||
for units in sorted(ENERGY_UNITS, key=lambda k: -len(k)):
|
||||
m = re.search(r'units *\/ *%s *\/' % re.escape(units),
|
||||
entry, re.IGNORECASE)
|
||||
pattern = re.compile(r'units *\/ *%s *\/' % re.escape(units),
|
||||
re.IGNORECASE)
|
||||
m = pattern.search(entry)
|
||||
if m:
|
||||
entry = re.sub(r'units *\/ *%s *\/' % re.escape(units), '',
|
||||
entry, flags=re.IGNORECASE)
|
||||
entry = pattern.sub('', entry)
|
||||
energy_units = ENERGY_UNITS[units]
|
||||
break
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue