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

Configuration: Added new way to disable namelist groups (.hide)

Namelist groups may be disabled by setting the special variable '.hide' to 'true'. This allows to selectively re-enable groups in higher order config files by setting '.hide' to 'false'
parent e099ebd7
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,13 @@ Global
* Changed version info to be retrieved from version control system.
This requires an additional 'make' step before running
Configuration
-------------
* Added new way to disable namelist groups by setting the special variable
'.hide' to 'true'. This allows to selectively re-enable groups in higher
order config files by setting '.hide' to 'false'
Templates
---------
......
......@@ -169,8 +169,9 @@ def format_namelist(section, group=None):
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'))
group_id = group.lower()
if not any(map(lambda x: re.match(x, group_id), black_list)):
if not hidden and not any(map(lambda x: re.match(x, group_id), black_list)):
# Create list of removed keys
remove_keys = get_remove_list(contents, '.remove')
group_names = group_id.split(' ', 1)
......@@ -179,7 +180,7 @@ def format_namelist(section, group=None):
else:
lines.write('&'+group_names[0]+" ! '"+group_names[1]+"'\n")
for key, value in contents.iteritems():
if key not in remove_keys:
if key[0] != '.' and key not in remove_keys:
key = key.lower()
indent = base_indent + len(key) + 3
for line in contents.comments.get(key, []):
......
......@@ -525,6 +525,29 @@ class NamelistTestCase(MkexpSimpleTestCase):
value = 43
""")
def test_namelist_hide(self):
self.run_test("""
%{NAMELIST}
""", """
&group1
value = 41
/
&group3
value = 43
/
""", """
[namelists]
[[namelist]]
[[[group1]]]
value = 41
[[[group2]]]
.hide = true
value = 42
[[[group3]]]
.hide = dont_care_if_we_dont_start_with_t
value = 43
""")
class JinjaTemplateTestCase(MkexpSimpleTestCase):
def test_ignore_blocks(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