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

Configuration: changed handling of remove lists to not remove the .remove...

Configuration: changed handling of remove lists to not remove the .remove entries from config; used to break handling of remove lists in standalone calls to format_namelist
parent afabc356
No related branches found
No related tags found
No related merge requests found
......@@ -137,17 +137,16 @@ def format_value(value, indent):
def keyword_warning(key):
feedback.warning("keyword '"+key+"' is deprecated, use '."+key+"' instead")
def cut_remove_list(section, key):
def get_remove_list(section, key):
remove_list = []
if key in section:
# Deprecation warning for non .keys
if key[0] != '.':
keyword_warning(key)
if isinstance(section[key], basestring):
remove_list = [section[key]]
remove_list = [key, section[key]]
else:
remove_list = section[key]
del section[key]
remove_list = [key] + section[key]
return remove_list
def format_namelist(section, group=None):
......@@ -161,8 +160,8 @@ def format_namelist(section, group=None):
base_indent = 4
# Create list of removed namelist groups.
# Support old keyword for backward compatibility
remove_list = cut_remove_list(section, '.remove')
remove_list += cut_remove_list(section, 'remove')
remove_list = get_remove_list(section, '.remove')
remove_list += get_remove_list(section, 'remove')
black_list = map(lambda x: x.replace(r'\*', '.*').replace(r'\?', '.')+'$',
map(lambda x: re.escape(x.lower()), remove_list))
# Format namelist groups that were not removed
......@@ -173,7 +172,7 @@ def format_namelist(section, group=None):
group_id = group.lower()
if not any(map(lambda x: re.match(x, group_id), black_list)):
# Create list of removed keys
remove_keys = cut_remove_list(contents, '.remove')
remove_keys = get_remove_list(contents, '.remove')
group_names = group_id.split(' ', 1)
if len(group_names) == 1:
lines.write('&'+group_names[0]+'\n')
......@@ -419,8 +418,8 @@ dump_file.close()
# Cut queue specific settings
job_dict = {}
remove_list = cut_remove_list(config['jobs'], '.remove')
remove_list += cut_remove_list(config['jobs'], 'remove')
remove_list = get_remove_list(config['jobs'], '.remove')
remove_list += get_remove_list(config['jobs'], 'remove')
for key, value in config['jobs'].iteritems():
if not isinstance(value, dict):
job_dict[key] = value
......
......@@ -516,10 +516,13 @@ class NamelistTestCase(MkexpSimpleTestCase):
""", """
[namelists]
[[namelist]]
.remove = group3
[[[group1]]]
value = 41
[[[group2]]]
value = 42
[[[group3]]]
value = 43
""")
class JinjaTemplateTestCase(MkexpSimpleTestCase):
......
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