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
eb3d13cb
Commit
eb3d13cb
authored
12 years ago
by
Karl-Hermann Wieners
Browse files
Options
Downloads
Patches
Plain Diff
Changed mkexp to allow removal of predefined namelist groups (remove keyword).
parent
dccd451a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mkexp
+18
-5
18 additions, 5 deletions
mkexp
with
18 additions
and
5 deletions
mkexp
+
18
−
5
View file @
eb3d13cb
...
...
@@ -94,13 +94,26 @@ def format_value(value):
def
format_namelist
(
section
):
'''
Format config section as a namelist
'''
# Create list of removed namelist groups
remove_list
=
[]
if
'
remove
'
in
section
:
if
isinstance
(
section
[
'
remove
'
],
basestring
):
remove_list
=
[
section
[
'
remove
'
]]
else
:
remove_list
=
section
[
'
remove
'
]
del
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
lines
=
StringIO
.
StringIO
()
for
group
,
contents
in
section
.
iteritems
():
group_name
=
re
.
sub
(
r
'
.*$
'
,
''
,
group
.
lower
())
lines
.
write
(
'
&
'
+
group_name
+
'
\n
'
)
for
key
,
value
in
contents
.
iteritems
():
lines
.
write
(
'
'
+
key
.
lower
()
+
'
=
'
+
format_value
(
value
)
+
'
\n
'
)
lines
.
write
(
'
/
\n
'
)
group
=
group
.
lower
()
if
not
any
(
map
(
lambda
x
:
re
.
match
(
x
,
group
),
black_list
)):
group_name
=
re
.
sub
(
r
'
.*$
'
,
''
,
group
)
lines
.
write
(
'
&
'
+
group_name
+
'
\n
'
)
for
key
,
value
in
contents
.
iteritems
():
lines
.
write
(
'
'
+
key
.
lower
()
+
'
=
'
+
format_value
(
value
)
+
'
\n
'
)
lines
.
write
(
'
/
\n
'
)
return
lines
.
getvalue
()
#
...
...
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