From b82df1b1ea25f74504e6ea9ef9520eb6ecf4c36f Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 13 Mar 2013 20:20:31 +0000 Subject: [PATCH] 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. --- interfaces/python/ck2cti.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/interfaces/python/ck2cti.py b/interfaces/python/ck2cti.py index afd38853a..5fa51c5a0 100755 --- a/interfaces/python/ck2cti.py +++ b/interfaces/python/ck2cti.py @@ -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