Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
6009d214
Commit
6009d214
authored
3 years ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Use string.Formatter.parse to get variables from path template
parent
7e4e9250
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!554
Simplify handling of user notebook paths
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xfel_calibrate/calibrate.py
+4
-5
4 additions, 5 deletions
src/xfel_calibrate/calibrate.py
with
4 additions
and
5 deletions
src/xfel_calibrate/calibrate.py
+
4
−
5
View file @
6009d214
...
@@ -9,6 +9,7 @@ import os
...
@@ -9,6 +9,7 @@ import os
import
pprint
import
pprint
import
re
import
re
import
stat
import
stat
import
string
import
sys
import
sys
import
textwrap
import
textwrap
import
warnings
import
warnings
...
@@ -402,10 +403,8 @@ def make_extended_parser() -> argparse.ArgumentParser:
...
@@ -402,10 +403,8 @@ def make_extended_parser() -> argparse.ArgumentParser:
# Pulls out the variables in the templated path string, so that they
# Pulls out the variables in the templated path string, so that they
# can be added to the argument parser
# can be added to the argument parser
user_notebook_variables
=
[
user_notebook_variables
=
[
k
.
value
.
id
name
for
(
_
,
name
,
_
,
_
)
in
string
.
Formatter
().
parse
(
user_notebook_path
)
for
k
if
name
is
not
None
in
ast
.
walk
(
ast
.
parse
(
f
"
f
'
{
user_notebook_path
}
'"
))
if
isinstance
(
k
,
ast
.
FormattedValue
)
]
]
user_notebook_parser
=
argparse
.
ArgumentParser
()
user_notebook_parser
=
argparse
.
ArgumentParser
()
...
@@ -417,7 +416,7 @@ def make_extended_parser() -> argparse.ArgumentParser:
...
@@ -417,7 +416,7 @@ def make_extended_parser() -> argparse.ArgumentParser:
args
=
list
(
filter
(
lambda
x
:
x
!=
"
-h
"
,
_
))
# Drop help from args
args
=
list
(
filter
(
lambda
x
:
x
!=
"
-h
"
,
_
))
# Drop help from args
)
)
nb_info
[
"
notebook
"
]
=
nb_info
[
"
user
"
][
"
notebook
"
]
.
format
(
**
vars
(
user_notebook_args
))
nb_info
[
"
notebook
"
]
=
user_
notebook
_path
.
format
(
**
vars
(
user_notebook_args
))
notebook
=
nb_info
[
"
notebook
"
]
notebook
=
nb_info
[
"
notebook
"
]
cvar
=
nb_info
.
get
(
"
concurrency
"
,
{}).
get
(
"
parameter
"
,
None
)
cvar
=
nb_info
.
get
(
"
concurrency
"
,
{}).
get
(
"
parameter
"
,
None
)
...
...
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