Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
caosdb
Software
caosdb-server
Commits
a9271b9c
Verified
Commit
a9271b9c
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
Add doctests to diagnostics
parent
01166917
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripting/bin/administration/diagnostics.py
+39
-2
39 additions, 2 deletions
scripting/bin/administration/diagnostics.py
with
39 additions
and
2 deletions
scripting/bin/administration/diagnostics.py
+
39
−
2
View file @
a9271b9c
...
@@ -54,9 +54,44 @@ def get_files():
...
@@ -54,9 +54,44 @@ def get_files():
return
result
return
result
def
get_option
(
name
,
default
=
None
):
def
get_option
(
name
,
default
=
None
,
args
=
None
):
"""
get_option
Return the value of a command line options by name or a default value if
the command line parameters do not contain such an option.
Examples
--------
>>>
get_option
(
"
opt1
"
,
args
=
[
"
--opt1=bla
"
,
"
--opt2=blub
"
])
'
bla
'
>>>
get_option
(
"
opt1
"
,
args
=
[
"
--opt1
"
,
"
bla
"
,
"
--opt2
"
,
"
blub
"
])
'
bla
'
>>>
get_option
(
"
opt1
"
,
default
=
"
def
"
,
args
=
[
"
--other=blub
"
])
'
def
'
>>>
get_option
(
"
opt1
"
,
args
=
[
"
--opt1
"
,
"
--opt2=blub
"
])
True
>>>
get_option
(
"
opt1
"
,
args
=
[
"
--opt1
"
])
True
>>>
get_option
(
"
opt1
"
,
args
=
[
"
--other=blub
"
])
is
None
True
Parameters
----------
name : str
The name
default : str (optional)
Return this value if the arguments do not contain the option. Defaults
to `None`.
args : list of str (optional)
List of command line parameters which are to be parsed. Defaults to
`sys.argv`.
Returns
-------
"""
_next
=
False
_next
=
False
for
arg
in
sys
.
argv
:
_args
=
args
if
args
is
not
None
else
sys
.
argv
for
arg
in
_args
:
if
_next
is
True
:
if
_next
is
True
:
if
arg
.
startswith
(
"
--
"
):
if
arg
.
startswith
(
"
--
"
):
return
True
return
True
...
@@ -66,6 +101,8 @@ def get_option(name, default=None):
...
@@ -66,6 +101,8 @@ def get_option(name, default=None):
return
arg
[
index
:]
return
arg
[
index
:]
elif
arg
==
"
--{}
"
.
format
(
name
):
elif
arg
==
"
--{}
"
.
format
(
name
):
_next
=
True
_next
=
True
if
_next
is
True
:
return
True
return
default
return
default
...
...
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