MWCtxObj¶
- class lsst.daf.butler.cli.utils.MWCtxObj¶
Bases:
object
Helper object for managing the
click.Context.obj
parameter, allows obj data to be managed in a consistent way.Context.obj
defaults to None.MWCtxObj.getFrom(ctx)
can be used to initialize the obj if needed and return a new or existingMWCtxObj
.The
args
attribute contains a list of options, option values, and argument values that is similar to the list of arguments and options that were passed in on the command line, with differences noted below:Option namess and option values are first in the list, and argument values come last. The order of options and option values is preserved within the options. The order of argument values is preserved.
The longest option name is used for the option in the
args
list, e.g. if an option accepts both short and long names “-o / –option” and the short option name “-o” was used on the command line, the longer name will be the one that appears inargs
.A long option name (which begins with two dashes “–”) and its value may be separated by an equal sign; the name and value are split at the equal sign and it is removed. In
args
, the option is in one list item, and the option value (without the equal sign) is in the next list item. e.g. “–option=foo” and “–option foo” both become["--opt", "foo"]
inargs
.A short option name, (which begins with one dash “-”) and its value are split immediately after the short option name, and if there is whitespace between the short option name and its value it is removed. Everything after the short option name (excluding whitespace) is included in the value. If the
Option
has a long name, the long name will be used inargs
e.g. for the option “-o / –option”: “-ofoo” and “-o foo” become["--option", "foo"]
, and (note!) “-o=foo” will become["--option", "=foo"]
(because everything after the short option name, except whitespace, is used for the value (as is standard with unix command line tools).
- Attributes:
Methods Summary
getFrom
(ctx)If needed, initialize
ctx.obj
with a newMWCtxObj
, and return the new or already existingMWCtxObj
.Methods Documentation