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

Config: allow hiding for namelist files with templates

parent c178230d
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,14 @@ Global
* TODO: Porting to python3
Version 1.1.1rc1
================
Configuration
-------------
* Allow hiding for namelist files with templates
Release 1.1.0
=============
......
......@@ -175,7 +175,7 @@ def format_namelist(section, group=None, default_value=''):
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')):
if is_set(section.get(hide_key)):
return ''
# Create list of removed namelist groups.
# Support old keyword for backward compatibility
......@@ -188,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_key, 'false'))
hidden = is_set(contents.get(hide_key))
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)):
......@@ -540,6 +540,9 @@ for subjob, subconfig in jobs_config.iteritems():
job_config['VARIABLES_'] = var_list
for namelist, groups in job_config['namelists'].iteritems():
if isinstance(groups, dict):
# Skip hidden namelists
if is_set(groups.get('.hide')):
continue
# Support deprecated keyword 'use_template' but warn user
if groups.get('use_template'):
keyword_warning('use_template')
......
......@@ -542,6 +542,19 @@ class NamelistTestCase(MkexpSimpleTestCase):
value = 43
""")
def test_namelist_with_template(self):
self.run_test("""
%{NAMELIST}
""", """
42
""", """
[namelists]
[[namelist]]
.use_template = true
[[[group]]]
value = 42
""")
class NamelistHiddenTestCase(MkexpSimpleTestCase):
def test_namelist_hide(self):
......@@ -579,6 +592,19 @@ class NamelistHiddenTestCase(MkexpSimpleTestCase):
value = 42
""")
def test_hidden_namelist_with_template(self):
self.run_test("""
%{NAMELIST}
""", """
""", """
[namelists]
[[namelist]]
.hide = true
.use_template = true
[[[group]]]
value = 42
""")
class NamelistDefaultValueTestCase(MkexpSimpleTestCase):
def test_standard_default_value(self):
......
%{group.value}
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