Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mkexp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esmenv
mkexp
Commits
d7ac06ca
Commit
d7ac06ca
authored
3 years ago
by
Karl-Hermann Wieners
Browse files
Options
Downloads
Patches
Plain Diff
Config: allow hiding for namelist files with templates
parent
c178230d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGES.txt
+8
-0
8 additions, 0 deletions
CHANGES.txt
mkexp
+5
-2
5 additions, 2 deletions
mkexp
test.py
+26
-0
26 additions, 0 deletions
test.py
test/standard_experiments/namelist.tmpl
+1
-0
1 addition, 0 deletions
test/standard_experiments/namelist.tmpl
with
40 additions
and
2 deletions
CHANGES.txt
+
8
−
0
View file @
d7ac06ca
...
...
@@ -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
=============
...
...
This diff is collapsed.
Click to expand it.
mkexp
+
5
−
2
View file @
d7ac06ca
...
...
@@ -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
'
)
...
...
This diff is collapsed.
Click to expand it.
test.py
+
26
−
0
View file @
d7ac06ca
...
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
test/standard_experiments/namelist.tmpl
0 → 100644
+
1
−
0
View file @
d7ac06ca
%{group.value}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment