Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
EasyCloud
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
Model registry
Operate
Environments
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
DSDF
EasyCloud
Commits
331cb864
Commit
331cb864
authored
4 years ago
by
sguazt
Browse files
Options
Downloads
Patches
Plain Diff
Core: created an interactive version of 'get_parameter'
parent
18cebfef
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
easycloud/core/metaconfmanager.py
+34
-11
34 additions, 11 deletions
easycloud/core/metaconfmanager.py
with
34 additions
and
11 deletions
easycloud/core/metaconfmanager.py
+
34
−
11
View file @
331cb864
...
...
@@ -78,20 +78,20 @@ class MetaConfManager(ABC):
def
get_parameter
(
self
,
section
,
option
,
return_type
=
None
,
regex
=
None
,
default
=
None
):
"""
Return the parameter stored in the module configuration file or
ask the user to provide it
the given default value.
Args:
section (str): name of the section (a name surrounded with square
brackets
inside the configuration file)
option (str): name of the parameter
return_type (<return_type>
, optional): the return type assigned to user input,
if not specified in the configuration
f
ile
section (str): name of the section (a name surrounded with square
brackets
inside the configuration file)
.
option (str): name of the parameter
.
return_type (<return_type>
): the type to which convert the parameter
value read from the configuration file and returned from this
f
unction.
regex (str): the regular expression the input must follow, if a user input is
required
required
.
Returns:
<return_type>:
user input of type <
return
_
type
>
<return_type>:
the parameter value converted to the given
return
type
.
"""
if
self
.
parser
.
has_option
(
section
,
option
):
value
=
self
.
parser
.
get
(
section
,
option
)
...
...
@@ -100,9 +100,32 @@ class MetaConfManager(ABC):
return
True
else
:
return
return_type
(
value
)
elif
default
is
not
None
:
return
default
else
:
return
default
def
get_parameter_ui
(
self
,
section
,
option
,
return_type
=
None
,
regex
=
None
,
default
=
None
):
"""
Return the parameter stored in the module configuration file or
ask the user to provide it if no default value is given.
Args:
section (str): name of the section (a name surrounded with square brackets
inside the configuration file).
option (str): name of the parameter.
return_type (<return_type>, optional): the return type assigned to
user input, if not specified in the configuration file.
regex (str): the regular expression the input must follow, if a user
input is required.
Returns:
<return_type>: user input of type <return_type>.
"""
value
=
self
.
get_parameter
(
section
,
option
,
return_type
=
return_type
,
regex
=
regex
,
default
=
default
)
if
value
is
None
:
return
self
.
ask_for_data
(
section
,
option
,
regex
=
regex
,
return_type
=
return_type
)
def
get_parameters
(
self
,
section
):
...
...
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