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
c101e054
Commit
c101e054
authored
5 years ago
by
Karl-Hermann Wieners
Browse files
Options
Downloads
Patches
Plain Diff
mkexp: moved update information to separate module
parent
8eaf74d3
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
getconfig
+4
-32
4 additions, 32 deletions
getconfig
setup.py
+1
-1
1 addition, 1 deletion
setup.py
update.py
+48
-0
48 additions, 0 deletions
update.py
with
53 additions
and
33 deletions
getconfig
+
4
−
32
View file @
c101e054
...
...
@@ -6,13 +6,11 @@
#
import
argparse
import
os
import
re
import
sys
from
configobj
import
ConfigObj
import
expargpars
e
import
updat
e
from
feedback
import
die
import
package_info
...
...
@@ -31,39 +29,13 @@ command_line.add_argument('-V', '--version', action='version',
args
=
command_line
.
parse_args
()
# Check mkexp command line
mkexp_line
=
expargparse
.
MkexpArgumentParser
()
# Experiment configuration
config_dir
=
''
config_file
=
''
config_dicts
=
[]
try
:
update_file
=
open
(
args
.
update
)
for
line
in
update_file
:
match
=
re
.
match
(
r
"
^cd
'
(.*)
'
$
"
,
line
)
if
match
:
config_dir
=
match
.
group
(
1
)
else
:
match
=
re
.
match
(
r
"
^exec
'
.*?
'
'
(.*)
'"
,
line
)
if
match
:
mkexp_args
=
mkexp_line
.
parse_args
(
match
.
group
(
1
).
split
(
"'
'"
))
config_file
=
mkexp_args
.
config
config_dicts
=
expargparse
.
assigns_to_dicts
(
mkexp_args
)
update_file
.
close
()
update_data
=
update
.
Update
(
args
.
update
)
except
IOError
as
error
:
die
(
"'
{0}
'
: {1}
"
.
format
(
error
.
filename
,
error
.
strerror
))
if
not
os
.
path
.
isabs
(
config_file
):
config_file
=
os
.
path
.
join
(
config_dir
,
config_file
)
config_data
=
ConfigObj
(
config_file
,
interpolation
=
False
)
for
d
in
config_dicts
:
config_data
=
ConfigObj
(
update_data
.
get_config_file
(),
interpolation
=
False
)
for
d
in
update_data
.
get_config_dicts
():
config_data
.
merge
(
d
)
config_data
.
indent_type
=
'
'
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
c101e054
...
...
@@ -9,7 +9,7 @@ setup(
author
=
'
Karl-Hermann Wieners
'
,
author_email
=
'
karl-hermann.wieners@mpimet.mpg.de
'
,
url
=
'
http://code.mpimet.mpg.de/projects/esmenv
'
,
py_modules
=
[
'
_version
'
,
'
configobj
'
,
'
validate
'
,
'
feedback
'
,
'
expargparse
'
,
'
expconfig
'
,
'
files
'
,
'
package_info
'
],
py_modules
=
[
'
_version
'
,
'
configobj
'
,
'
validate
'
,
'
feedback
'
,
'
expargparse
'
,
'
expconfig
'
,
'
files
'
,
'
package_info
'
,
'
update
'
],
scripts
=
[
'
mkexp
'
,
'
getexp
'
,
'
rmexp
'
,
'
diffexp
'
,
'
diffpath
'
,
'
cpexp
'
,
'
cppath
'
,
'
duexp
'
,
'
getconfig
'
],
data_files
=
[(
'
share/doc/
'
+
package_info
.
name
,
[
'
doc/mkexp.pdf
'
,
'
mkexp.bash
'
])],
platforms
=
[
'
Posix
'
],
...
...
This diff is collapsed.
Click to expand it.
update.py
0 → 100644
+
48
−
0
View file @
c101e054
'''
Module for
'
update
'
information generated by mkexp tool.
$Id update.py -1 2019-06-28 10:10:05Z m221078 $
'''
import
os
import
re
import
expargparse
class
Update
:
'''
Object containing
'
update
'
information generated by mkexp tool
'''
def
__init__
(
self
,
update_name
):
# Experiment configuration
self
.
config_dir
=
None
self
.
mkexp_args
=
None
# Read data from update file
update_file
=
open
(
update_name
)
for
line
in
update_file
:
match
=
re
.
match
(
r
"
^cd
'
(.*)
'
$
"
,
line
)
if
match
:
self
.
config_dir
=
match
.
group
(
1
)
else
:
match
=
re
.
match
(
r
"
^exec
'
.*?
'
'
(.*)
'"
,
line
)
if
match
:
# Check mkexp command line
mkexp_line
=
expargparse
.
MkexpArgumentParser
()
self
.
mkexp_args
=
\
mkexp_line
.
parse_args
(
match
.
group
(
1
).
split
(
"'
'"
))
update_file
.
close
()
def
get_config_file
(
self
):
config_file
=
self
.
mkexp_args
.
config
if
not
os
.
path
.
isabs
(
config_file
):
config_file
=
os
.
path
.
join
(
self
.
config_dir
,
config_file
)
return
config_file
def
get_config_dicts
(
self
):
return
expargparse
.
assigns_to_dicts
(
self
.
mkexp_args
)
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