Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dm-docs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
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
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hammonds
dm-docs
Commits
8860bb05
Commit
8860bb05
authored
9 years ago
by
sveseli
Browse files
Options
Downloads
Patches
Plain Diff
allow arbitrary args to be converted into dicts
parent
43270239
No related branches found
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
src/python/dm/common/cli/dmCli.py
+15
-0
15 additions, 0 deletions
src/python/dm/common/cli/dmCli.py
with
15 additions
and
0 deletions
src/python/dm/common/cli/dmCli.py
+
15
−
0
View file @
8860bb05
...
@@ -21,6 +21,8 @@ from dm.common.constants import dmStatus
...
@@ -21,6 +21,8 @@ from dm.common.constants import dmStatus
class
DmCli
(
object
):
class
DmCli
(
object
):
"""
Base dm command line interface class.
"""
"""
Base dm command line interface class.
"""
DEFAULT_SESSION_CACHE_FILE
=
OsUtility
.
getUserHomeDir
()
+
'
/.dm/.session.cache
'
DEFAULT_SESSION_CACHE_FILE
=
OsUtility
.
getUserHomeDir
()
+
'
/.dm/.session.cache
'
ANY_NUMBER_OF_POSITIONAL_ARGS
=
10000000
def
__init__
(
self
,
validArgCount
=
0
):
def
__init__
(
self
,
validArgCount
=
0
):
self
.
logger
=
LoggingManager
.
getInstance
().
getLogger
(
self
.
__class__
.
__name__
)
self
.
logger
=
LoggingManager
.
getInstance
().
getLogger
(
self
.
__class__
.
__name__
)
# Do not log into a file for CLIs
# Do not log into a file for CLIs
...
@@ -178,6 +180,19 @@ class DmCli(object):
...
@@ -178,6 +180,19 @@ class DmCli(object):
"""
Returns the command line argument list.
"""
"""
Returns the command line argument list.
"""
return
self
.
args
return
self
.
args
def
splitArgsIntoDict
(
self
,
keyValueDelimiter
=
'
:
'
):
"""
Returns the command line argument list as dictionary of key/value
pairs. Each argument is split using specified delimiter.
"""
argDict
=
{}
for
a
in
self
.
args
:
sList
=
a
.
split
(
keyValueDelimiter
)
key
=
sList
[
0
]
value
=
''
if
len
(
sList
)
>
1
:
value
=
keyValueDelimiter
.
join
(
sList
[
1
:])
argDict
[
key
]
=
value
return
argDict
def
getArg
(
self
,
i
):
def
getArg
(
self
,
i
):
"""
Returns the i-th command line argument.
"""
"""
Returns the i-th command line argument.
"""
return
self
.
args
[
i
]
return
self
.
args
[
i
]
...
...
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