Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cfel_fmt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
dataAnalysis
cfel_fmt
Commits
a281d5ed
Commit
a281d5ed
authored
8 years ago
by
Valerio Mariani
Browse files
Options
Downloads
Plain Diff
Merge branch 'testing'
parents
d1af2e16
01cb8852
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cfel_optarg.py
+36
-6
36 additions, 6 deletions
cfel_optarg.py
cfel_vtk.py
+543
-0
543 additions, 0 deletions
cfel_vtk.py
with
579 additions
and
6 deletions
cfel_optarg.py
+
36
−
6
View file @
a281d5ed
...
...
@@ -28,6 +28,9 @@ configuration files.
"""
import
ast
def
parse_parameters
(
config
):
"""
Sets correct types for parameter dictionaries.
...
...
@@ -36,12 +39,18 @@ def parse_parameters(config):
The parser tries to interpret each entry in the dictionary according to the following rules:
- If the entry starts and ends with a single quote, it is interpreted as a string.
- If the entry is the word None, without quotes, then the entry is interpreted as NoneType.
- If the entry is the word False, without quotes, then the entry is interpreted as a boolean False.
- If the entry is the word True, without quotes, then the entry is interpreted as a boolean True.
- If non of the previous options match the content of the entry, the parser tries to interpret the entry in order
as:
- If the entry starts and ends with a single quote or double quote, it is
interpreted as a string.
- If the entry starts and ends with a square bracket, it is interpreted as a list.
- If the entry starts and ends with a brace, it is interpreted as a dictionary.
- If the entry is the word None, without quotes, then the entry is
interpreted as NoneType.
- If the entry is the word False, without quotes, then the entry is
interpreted as a boolean False.
- If the entry is the word True, without quotes, then the entry is
interpreted as a boolean True.
- If none of the previous options match the content of the entry,
the parser tries to interpret the entry in order as:
- An integer number.
- A float number.
...
...
@@ -68,6 +77,27 @@ def parse_parameters(config):
if
monitor_params
[
sect
][
op
].
startswith
(
"'"
)
and
monitor_params
[
sect
][
op
].
endswith
(
"'"
):
monitor_params
[
sect
][
op
]
=
monitor_params
[
sect
][
op
][
1
:
-
1
]
continue
if
monitor_params
[
sect
][
op
].
startswith
(
'"'
)
and
monitor_params
[
sect
][
op
].
endswith
(
'"'
):
monitor_params
[
sect
][
op
]
=
monitor_params
[
sect
][
op
][
1
:
-
1
]
continue
if
monitor_params
[
sect
][
op
].
startswith
(
"
[
"
)
and
monitor_params
[
sect
][
op
].
endswith
(
"
]
"
):
try
:
monitor_params
[
sect
][
op
]
=
ast
.
literal_eval
(
config
.
get
(
sect
,
op
))
continue
except
(
SyntaxError
,
ValueError
):
raise
RuntimeError
(
'
Error parsing parameter {0} in section {1}. Make sure that the syntax is
'
'
correct: list elements must be separated by commas and dict entries must
'
'
contain the colon symbol. Strings must be quoted, even in lists and
'
'
dicts.
'
.
format
(
op
,
sect
))
if
monitor_params
[
sect
][
op
].
startswith
(
"
{
"
)
and
monitor_params
[
sect
][
op
].
endswith
(
"
}
"
):
try
:
monitor_params
[
sect
][
op
]
=
ast
.
literal_eval
(
config
.
get
(
sect
,
op
))
continue
except
(
SyntaxError
,
ValueError
):
raise
RuntimeError
(
'
Error parsing parameter {0} in section {1}. Make sure that the syntax is
'
'
correct: list elements must be separated by commas and dict entries must
'
'
contain the colon symbol. Strings must be quoted, even in lists and
'
'
dicts.
'
.
format
(
op
,
sect
))
if
monitor_params
[
sect
][
op
]
==
'
None
'
:
monitor_params
[
sect
][
op
]
=
None
continue
...
...
This diff is collapsed.
Click to expand it.
cfel_vtk.py
0 → 100644
+
543
−
0
View file @
a281d5ed
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