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

Config: added configurable hiding (disabling) of namelist files

parent 5f9f2b70
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@ Configuration
* Added '.default' variable to namelists and namelist groups to define an
alternative default value if the empty string is a valid value
* Added 'is_set' utility to be used on logicals in 'eval(...)' expressions
* Added configurable hiding (disabling) of namelist files
Templates
---------
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
No preview for this file type
......@@ -171,8 +171,12 @@ def format_namelist(section, group=None, default_value=''):
# Settings
base_indent = 4
end_key = '.end'
hide_key = '.hide'
default_key = '.default'
default_value = section.get(default_key, default_value)
# Skip if whole section (usually namelist file) is hidden
if is_set(section.get(hide_key, 'false')):
return ''
# Create list of removed namelist groups.
# Support old keyword for backward compatibility
remove_list = get_remove_list(section, '.remove')
......@@ -184,7 +188,7 @@ def format_namelist(section, group=None, default_value=''):
iterator = {group: section[group]}.iteritems() if group else section.iteritems()
for group, contents in iterator:
if isinstance(contents, dict):
hidden = is_set(contents.get('.hide', 'false'))
hidden = is_set(contents.get(hide_key, 'false'))
group_def_val = contents.get(default_key, default_value)
group_id = group.lower()
if not hidden and not any(map(lambda x: re.match(x, group_id), black_list)):
......
......@@ -542,6 +542,8 @@ class NamelistTestCase(MkexpSimpleTestCase):
value = 43
""")
class NamelistHiddenTestCase(MkexpSimpleTestCase):
def test_namelist_hide(self):
self.run_test("""
%{NAMELIST}
......@@ -565,6 +567,18 @@ class NamelistTestCase(MkexpSimpleTestCase):
value = 43
""")
def test_hidden_namelist_file(self):
self.run_test("""
%{NAMELIST}
""", """
""", """
[namelists]
[[namelist]]
.hide = true
[[[group]]]
value = 42
""")
class NamelistDefaultValueTestCase(MkexpSimpleTestCase):
def test_standard_default_value(self):
......
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