Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
UW-Glance
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
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
Eva Schiffer
UW-Glance
Commits
3f77f2bf
Commit
3f77f2bf
authored
3 years ago
by
Eva Schiffer
Browse files
Options
Downloads
Patches
Plain Diff
update to clean up argparse use
parent
bb98c242
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyglance/glance/compare.py
+23
-21
23 additions, 21 deletions
pyglance/glance/compare.py
pyglance/glance/config_organizer.py
+4
-4
4 additions, 4 deletions
pyglance/glance/config_organizer.py
with
27 additions
and
25 deletions
pyglance/glance/compare.py
+
23
−
21
View file @
3f77f2bf
...
@@ -1287,25 +1287,8 @@ def inspect_stats_library_call (afn, var_list=None, options_set=None, do_documen
...
@@ -1287,25 +1287,8 @@ def inspect_stats_library_call (afn, var_list=None, options_set=None, do_documen
def
main
():
def
main
():
# get our command line argument handling set up
# horray, dummy options!
options
=
config_organizer
.
parse_arguments
()
options
=
None
args
=
options
.
misc
if
options
.
self_test
:
import
doctest
doctest
.
testmod
()
sys
.
exit
(
2
)
# set up the logging level based on the options the user selected on the command line
lvl
=
logging
.
WARNING
if
options
.
debug
:
lvl
=
logging
.
DEBUG
elif
options
.
verbose
:
lvl
=
logging
.
INFO
elif
options
.
quiet
:
lvl
=
logging
.
ERROR
logging
.
basicConfig
(
level
=
lvl
)
# display the version
if
options
.
version
:
print
(
get_glance_version_string
()
+
'
\n
'
)
commands
=
{}
commands
=
{}
prior
=
None
prior
=
None
...
@@ -1879,10 +1862,29 @@ def main():
...
@@ -1879,10 +1862,29 @@ def main():
# lowercase locals
# lowercase locals
# Future: this is an awkward use and could be made more elegant
# Future: this is an awkward use and could be made more elegant
lower_locals
=
{
}
lower_locals
=
{}
for
command_key
in
commands
:
for
command_key
in
commands
:
lower_locals
[
command_key
.
lower
()]
=
locals
()[
command_key
]
lower_locals
[
command_key
.
lower
()]
=
locals
()[
command_key
]
# get our command line argument handling set up
options
=
config_organizer
.
parse_arguments
(
get_glance_version_string
(),
list
(
lower_locals
.
keys
()),
)
args
=
options
.
misc
if
options
.
self_test
:
import
doctest
doctest
.
testmod
()
sys
.
exit
(
2
)
# set up the logging level based on the options the user selected on the command line
lvl
=
logging
.
WARNING
if
options
.
debug
:
lvl
=
logging
.
DEBUG
elif
options
.
verbose
:
lvl
=
logging
.
INFO
elif
options
.
quiet
:
lvl
=
logging
.
ERROR
logging
.
basicConfig
(
level
=
lvl
)
# if what the user asked for is not one of our existing functions, print the help
# if what the user asked for is not one of our existing functions, print the help
to_return
=
0
to_return
=
0
if
(
options
.
command
==
""
)
or
(
options
.
command
not
in
lower_locals
):
if
(
options
.
command
==
""
)
or
(
options
.
command
not
in
lower_locals
):
...
...
This diff is collapsed.
Click to expand it.
pyglance/glance/config_organizer.py
+
4
−
4
View file @
3f77f2bf
...
@@ -435,7 +435,7 @@ def load_config_or_options(aPath, bPath, optionsSet, requestedVars = [ ]) :
...
@@ -435,7 +435,7 @@ def load_config_or_options(aPath, bPath, optionsSet, requestedVars = [ ]) :
return
paths
,
runInfo
,
defaultsToUse
,
requestedNames
,
usedConfigFile
return
paths
,
runInfo
,
defaultsToUse
,
requestedNames
,
usedConfigFile
def
parse_arguments
()
:
def
parse_arguments
(
version_string
,
commands_list
,
)
:
"""
"""
Parse command line options and return an options object
Parse command line options and return an options object
...
@@ -505,8 +505,8 @@ def parse_arguments () :
...
@@ -505,8 +505,8 @@ def parse_arguments () :
parser
.
add_argument
(
'
-w
'
,
'
--debug
'
,
dest
=
"
debug
"
,
parser
.
add_argument
(
'
-w
'
,
'
--debug
'
,
dest
=
"
debug
"
,
action
=
"
store_true
"
,
default
=
False
,
action
=
"
store_true
"
,
default
=
False
,
help
=
"
enable logging of debug output (warning: this will generate far more messages)
"
)
help
=
"
enable logging of debug output (warning: this will generate far more messages)
"
)
parser
.
add_argument
(
'
-n
'
,
'
--version
'
,
dest
=
'
version
'
,
parser
.
add_argument
(
'
-n
'
,
'
--version
'
,
version
=
version_string
,
action
=
"
version
"
,
action
=
"
store_true
"
,
default
=
False
,
help
=
"
print the Glance version
"
)
help
=
"
print the Glance version
"
)
# data options for setting variable defaults
# data options for setting variable defaults
parser
.
add_argument
(
'
-e
'
,
'
--epsilon
'
,
dest
=
EPSILON_KEY
,
type
=
float
,
default
=
0.0
,
parser
.
add_argument
(
'
-e
'
,
'
--epsilon
'
,
dest
=
EPSILON_KEY
,
type
=
float
,
default
=
0.0
,
...
@@ -556,7 +556,7 @@ def parse_arguments () :
...
@@ -556,7 +556,7 @@ def parse_arguments () :
help
=
"
format output to be programmatically parsed. (only affects
'
info
'
)
"
)
help
=
"
format output to be programmatically parsed. (only affects
'
info
'
)
"
)
# get the command
# get the command
parser
.
add_argument
(
'
command
'
,
metavar
=
"
COMMAND
"
,
help
=
"
command to invoke
"
,
type
=
str
.
lower
)
parser
.
add_argument
(
'
command
'
,
metavar
=
"
COMMAND
"
,
choices
=
commands_list
,
help
=
"
command to invoke
"
,
type
=
str
.
lower
)
parser
.
add_argument
(
'
misc
'
,
metavar
=
'
[FILE [VARIABLE]]+
'
,
nargs
=
'
*
'
)
parser
.
add_argument
(
'
misc
'
,
metavar
=
'
[FILE [VARIABLE]]+
'
,
nargs
=
'
*
'
)
# options.misc is expected to catch the COMMAND and FILE and VARIABLE
# options.misc is expected to catch the COMMAND and FILE and VARIABLE
...
...
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