Skip to content
Snippets Groups Projects
Commit 5992a4e5 authored by Karl-Hermann Wieners's avatar Karl-Hermann Wieners
Browse files

Changed calls to regular expression substitution and string formatting to be...

Changed calls to regular expression substitution and string formatting to be compatible with python-2.6
parent a0920432
No related branches found
No related tags found
No related merge requests found
......@@ -156,7 +156,7 @@ class ExpConfig(ConfigObj):
years = int(years)
dt = map(int, split_date(value))
dt[0] += years
return "{:+05}-{:02}-{:02}".format(*dt).lstrip('+')
return "{0:+05}-{1:02}-{2:02}".format(*dt).lstrip('+')
def add_days(value, days):
'''Add specified number of days (possible negative) to date'''
......@@ -195,7 +195,7 @@ class ExpConfig(ConfigObj):
days = int(days)
dt = map(int, split_date(value))
dt = add_days_(dt[0], dt[1], dt[2], days)
return "{:+05}-{:02}-{:02}".format(*dt).lstrip('+')
return "{0:+05}-{1:02}-{2:02}".format(*dt).lstrip('+')
def eval_value(value):
'''
......
......@@ -98,14 +98,14 @@ def format_atom(value):
'''Format atomic value for use in namelists'''
result = quote(value)
# Strip quotes from all-numeric strings
result = re.sub('^(["'r"'])([-+]?(\d+\.\d*|\.?\d+)([de][-+]?\d+)?)\1$", r'\2',
result, flags=re.I)
result = re.sub('(?i)^(["'r"'])([-+]?(\d+\.\d*|\.?\d+)([de][-+]?\d+)?)\1$", r'\2',
result)
# Strip leading zeroes from integers (just to be sure)
result = re.sub(r'^0+([1-9]\d*|0)$', r'\1', result)
#
result = re.sub('^(["'r"'])\.?t(rue)?\.?\1$", '.true.', result, flags=re.I)
result = re.sub('(?i)^(["'r"'])\.?t(rue)?\.?\1$", '.true.', result)
result = \
re.sub('^(["'r"'])\.?f(alse)?\.?\1$", '.false.', result, flags=re.I)
re.sub('(?i)^(["'r"'])\.?f(alse)?\.?\1$", '.false.', result)
result = re.sub('^(["'r"'])raw\((.*)\)\1$", r'\2', result)
return result
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment