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
e05d6905
Commit
e05d6905
authored
2 months ago
by
Karl-Hermann Wieners
Browse files
Options
Downloads
Patches
Plain Diff
Config: identify group names differing by whitespace only
Closes issue
#3
parent
38389829
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/mkexp.fodt
+764
-707
764 additions, 707 deletions
doc/mkexp.fodt
expconfig.py
+35
-0
35 additions, 0 deletions
expconfig.py
test.py
+2
-5
2 additions, 5 deletions
test.py
with
801 additions
and
712 deletions
doc/mkexp.fodt
+
764
−
707
View file @
e05d6905
Source diff could not be displayed: it is too large. Options to address this:
view the blob
.
This diff is collapsed.
Click to expand it.
expconfig.py
+
35
−
0
View file @
e05d6905
...
...
@@ -156,6 +156,9 @@ class ExpConfig(ConfigObj):
# Helper functions
#
# Common pattern to be used for helper functions
pattern_whitespace_sequences
=
re
.
compile
(
r
"
\s+
"
)
def
split_shared_sections
(
config
):
'''
Process sections to expand shared entries as [[job1, job2]]
...
...
@@ -265,6 +268,32 @@ class ExpConfig(ConfigObj):
for
key
in
section
.
sections
:
list_assign
(
section
[
key
])
def
unify_section_keys
(
config
):
'''
Process sections to unify [base ident] entries
Collapses whitespace sequences to a single space
'''
def
unify_key
(
current
):
for
subkey_orig
in
current
.
sections
:
subkey
=
pattern_whitespace_sequences
.
sub
(
"
"
,
subkey_orig
)
if
subkey
!=
subkey_orig
:
if
subkey
in
current
:
raise
ExpConfigError
(
f
"
duplicate key
'
{
subkey
}
'
after whitespace
"
"
unification
"
,
subkey_orig
)
else
:
current
.
rename
(
subkey_orig
,
subkey
)
if
'
namelists
'
in
config
.
sections
:
for
group
in
config
[
'
namelists
'
].
sections
:
unify_key
(
config
[
'
namelists
'
][
group
])
if
'
jobs
'
in
config
.
sections
:
unify_key
(
config
[
'
jobs
'
])
for
job
in
config
[
'
jobs
'
].
sections
:
if
'
namelists
'
in
config
[
'
jobs
'
][
job
].
sections
:
for
group
in
config
[
'
namelists
'
].
sections
:
unify_key
(
config
[
'
jobs
'
][
job
][
'
namelists
'
][
group
])
# Helper functions for value definitions
def
read_value
(
value
):
...
...
@@ -544,12 +573,14 @@ class ExpConfig(ConfigObj):
if
lib_config_name
:
pre_config
.
merge
(
ConfigObj
(
lib_config_name
))
split_shared_sections
(
pre_config
)
unify_section_keys
(
pre_config
)
list_assign
(
pre_config
)
register_version
(
pre_config
,
config_versions
)
if
setup_config_name
:
pre_config
.
merge
(
ConfigObj
(
setup_config_name
))
split_shared_sections
(
pre_config
)
unify_section_keys
(
pre_config
)
list_assign
(
pre_config
)
register_version
(
pre_config
,
config_versions
)
...
...
@@ -558,6 +589,7 @@ class ExpConfig(ConfigObj):
if
lib_config_name
:
pre_config
.
merge
(
ConfigObj
(
lib_config_name
))
split_shared_sections
(
pre_config
)
unify_section_keys
(
pre_config
)
list_assign
(
pre_config
)
register_version
(
pre_config
,
config_versions
)
elif
(
experiment_type
and
...
...
@@ -571,6 +603,7 @@ class ExpConfig(ConfigObj):
if
lib_config_name
:
pre_config
.
merge
(
ConfigObj
(
lib_config_name
))
split_shared_sections
(
pre_config
)
unify_section_keys
(
pre_config
)
list_assign
(
pre_config
)
register_version
(
pre_config
,
config_versions
)
else
:
...
...
@@ -584,6 +617,7 @@ class ExpConfig(ConfigObj):
if
lib_config_name
:
pre_config
.
merge
(
ConfigObj
(
lib_config_name
))
split_shared_sections
(
pre_config
)
unify_section_keys
(
pre_config
)
list_assign
(
pre_config
)
register_version
(
pre_config
,
config_versions
)
...
...
@@ -596,6 +630,7 @@ class ExpConfig(ConfigObj):
experiment_config
=
ConfigObj
(
experiment_config_name
)
pre_config
.
merge
(
experiment_config
)
split_shared_sections
(
pre_config
)
unify_section_keys
(
pre_config
)
list_assign
(
pre_config
)
# Add extra dictionary
...
...
This diff is collapsed.
Click to expand it.
test.py
+
2
−
5
View file @
e05d6905
...
...
@@ -640,8 +640,6 @@ class NamelistTestCase(MkexpSimpleTestCase):
"""
,
u
"""
&group !
'
1
'
/
&group !
'
1
'
/
&group !
'
2
'
/
&group !
'
i i i
'
...
...
@@ -650,9 +648,8 @@ class NamelistTestCase(MkexpSimpleTestCase):
[namelists]
[[namelist]]
[[[group 1]]]
[[[group 1]]]
[[[group 2]]]
[[[group i i i]]]
[[[group 2]]]
[[[group i i i]]]
"""
)
def
test_namelist_case_twist
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Karl-Hermann Wieners
@m221078
mentioned in commit
d6c291ca
·
1 month ago
mentioned in commit
d6c291ca
mentioned in commit d6c291cabd92de53029a207fb76b500127d0917b
Toggle commit list
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