pyparam.param
Definition of a single parameter
PARAM_MAPPINGS
(dict(str: type of Param)) — The type to Param mappings, used for params to init a parameter. Managed byregister_param
Param
— Base class for parameter</>ParamAuto
— An auto parameter whose value is automatically casted</>ParamInt
— An int parameter whose value is automatically casted into an int</>ParamFloat
— A float parameter whose value is automatically casted into a float</>ParamStr
— A str parameter whose value is automatically casted into a str</>ParamBool
— A bool parameter whose value is automatically casted into a bool</>ParamCount
— A bool parameter whose value is automatically casted into a bool</>ParamPath
— A path parameter whose value is automatically casted into a pathlib.Path</>ParamDir
— Subclass of ParamPath.</>ParamPy
— A parameter whose value will be ast.literal_eval'ed</>ParamJson
— A parameter whose value will be parsed as json</>ParamList
— A parameter whose value is a list</>ParamChoice
— A bool parameter whose value is automatically casted into a bool</>ParamNamespace
— A pseudo parameter serving as a namespace for parameters under it</>ParamNamespace
— A pseudo parameter serving as a namespace for parameters under it</>
register_param
(
param
)
— Register a parameter class</>
pyparam.param.
Param
(
names
, default
, desc
, prefix='auto'
, show=True
, required=False
, subtype=None
, type_frozen=True
, callback=None
, complete_callback=None
, argname_shorten=True
, **kwargs
)
Base class for parameter
names
(Union(str, list of str)) — The names of the parameterdefault
(any) — The default valuedesc
(list of str) — The description of the parameterprefix
(str, optional) — The prefix of the parameter on the command lineshow
(bool, optional) — Whether this parameter should show on help pagerequired
(bool, optional) — Whether this parameter is requiredsubtype
(str or bool, optional) — The subtype of the parameter if this is a complex typetype_frozen
(bool, optional) — Whether the type is frozen (not allowing overwritting from command line)callback
(callable, optional) — The callback to modify the final valuecomplete_callback
(callable, optional) — The callback for complete the values of the parameterargname_shorten
(bool, optional) — Whether show shortened name for parameters under namespace parameters**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Give the completion candidates</>consume
(
value
)
(bool) — Consume a value</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_value
(
current
, prefix=''
)
Give the completion candidates
current
(str) — Current prefix
None when there are no candidates, nor should we have next paramters/commands as candidates (requiring a value). An empty string if we should put next parameters/commands as candidates. Otherwise yields The candidates should be either 1-, 2-, or 3-element tuple. If 1-element, type plain and no description implied. If 2-element, type plain and 2nd element should be description. If 3-element, 2nd element the type, 3rd the description.
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
consume
(
value
)
Consume a value
Value
— value to consume
True if value was consumed, otherwise False
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
pyparam.param.
ParamAuto
(
names
, default
, desc
, prefix='auto'
, show=True
, required=False
, subtype=None
, type_frozen=True
, callback=None
, complete_callback=None
, argname_shorten=True
, **kwargs
)
An auto parameter whose value is automatically casted
names
(Union(str, list of str)) — The names of the parameterdefault
(any) — The default valuedesc
(list of str) — The description of the parameterprefix
(str, optional) — The prefix of the parameter on the command lineshow
(bool, optional) — Whether this parameter should show on help pagerequired
(bool, optional) — Whether this parameter is requiredsubtype
(str or bool, optional) — The subtype of the parameter if this is a complex typetype_frozen
(bool, optional) — Whether the type is frozen (not allowing overwritting from command line)callback
(callable, optional) — The callback to modify the final valuecomplete_callback
(callable, optional) — The callback for complete the values of the parameterargname_shorten
(bool, optional) — Whether show shortened name for parameters under namespace parameters**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Give the completion candidates</>consume
(
value
)
(bool) — Consume a value</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_value
(
current
, prefix=''
)
Give the completion candidates
current
(str) — Current prefix
None when there are no candidates, nor should we have next paramters/commands as candidates (requiring a value). An empty string if we should put next parameters/commands as candidates. Otherwise yields The candidates should be either 1-, 2-, or 3-element tuple. If 1-element, type plain and no description implied. If 2-element, type plain and 2nd element should be description. If 3-element, 2nd element the type, 3rd the description.
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
consume
(
value
)
Consume a value
True if value was consumed, otherwise False
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
pyparam.param.
ParamInt
(
*args
, **kwargs
)
An int parameter whose value is automatically casted into an int
**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Give the completion candidates</>consume
(
value
)
(bool) — Consume a value</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_value
(
current
, prefix=''
)
Give the completion candidates
current
(str) — Current prefix
None when there are no candidates, nor should we have next paramters/commands as candidates (requiring a value). An empty string if we should put next parameters/commands as candidates. Otherwise yields The candidates should be either 1-, 2-, or 3-element tuple. If 1-element, type plain and no description implied. If 2-element, type plain and 2nd element should be description. If 3-element, 2nd element the type, 3rd the description.
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
consume
(
value
)
Consume a value
True if value was consumed, otherwise False
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
pyparam.param.
ParamFloat
(
*args
, **kwargs
)
A float parameter whose value is automatically casted into a float
**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Give the completion candidates</>consume
(
value
)
(bool) — Consume a value</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_value
(
current
, prefix=''
)
Give the completion candidates
current
(str) — Current prefix
None when there are no candidates, nor should we have next paramters/commands as candidates (requiring a value). An empty string if we should put next parameters/commands as candidates. Otherwise yields The candidates should be either 1-, 2-, or 3-element tuple. If 1-element, type plain and no description implied. If 2-element, type plain and 2nd element should be description. If 3-element, 2nd element the type, 3rd the description.
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
consume
(
value
)
Consume a value
True if value was consumed, otherwise False
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
pyparam.param.
ParamStr
(
*args
, **kwargs
)
A str parameter whose value is automatically casted into a str
**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Give the completion candidates</>consume
(
value
)
(bool) — Consume a value</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_value
(
current
, prefix=''
)
Give the completion candidates
current
(str) — Current prefix
None when there are no candidates, nor should we have next paramters/commands as candidates (requiring a value). An empty string if we should put next parameters/commands as candidates. Otherwise yields The candidates should be either 1-, 2-, or 3-element tuple. If 1-element, type plain and no description implied. If 2-element, type plain and 2nd element should be description. If 3-element, 2nd element the type, 3rd the description.
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
consume
(
value
)
Consume a value
True if value was consumed, otherwise False
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
pyparam.param.
ParamBool
(
*args
, **kwargs
)
A bool parameter whose value is automatically casted into a bool
**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str), iterator of (str, str), iterator of (str, str, str))) — Get the completion candidates for the current parameter</>consume
(
value
)
(bool) — Should I consume given value?</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
consume
(
value
)
→ bool
Should I consume given value?
complete_value
(
current
, prefix=''
)
→ Union(str, iterator of (str), iterator of (str, str), iterator of (str, str, str))
Get the completion candidates for the current parameter
current
(str) — Current prefix
pyparam.param.
ParamCount
(
*args
, **kwargs
)
A bool parameter whose value is automatically casted into a bool
**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(str, str) — Complete names for a count parameter</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Give the completion candidates</>consume
(
value
)
(bool) — Should I consume given parameter?</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_value
(
current
, prefix=''
)
Give the completion candidates
current
(str) — Current prefix
None when there are no candidates, nor should we have next paramters/commands as candidates (requiring a value). An empty string if we should put next parameters/commands as candidates. Otherwise yields The candidates should be either 1-, 2-, or 3-element tuple. If 1-element, type plain and no description implied. If 2-element, type plain and 2nd element should be description. If 3-element, 2nd element the type, 3rd the description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
consume
(
value
)
→ bool
Should I consume given parameter?
complete_name
(
current
)
→ (str, str)
Complete names for a count parameter
Since we have -v, -vv, -vvv allowed for a count parameter, we need to put them in the completions, too.
current
(str) — The current prefix or word under cursor
pyparam.param.
ParamPath
(
names
, default
, desc
, prefix='auto'
, show=True
, required=False
, subtype=None
, type_frozen=True
, callback=None
, complete_callback=None
, argname_shorten=True
, **kwargs
)
A path parameter whose value is automatically casted into a pathlib.Path
names
(Union(str, list of str)) — The names of the parameterdefault
(any) — The default valuedesc
(list of str) — The description of the parameterprefix
(str, optional) — The prefix of the parameter on the command lineshow
(bool, optional) — Whether this parameter should show on help pagerequired
(bool, optional) — Whether this parameter is requiredsubtype
(str or bool, optional) — The subtype of the parameter if this is a complex typetype_frozen
(bool, optional) — Whether the type is frozen (not allowing overwritting from command line)callback
(callable, optional) — The callback to modify the final valuecomplete_callback
(callable, optional) — The callback for complete the values of the parameterargname_shorten
(bool, optional) — Whether show shortened name for parameters under namespace parameters**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Generate file paths with given current prefix as completion candidates</>consume
(
value
)
(bool) — Consume a value</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
consume
(
value
)
Consume a value
True if value was consumed, otherwise False
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
complete_value
(
current
, prefix=''
)
→ Union(str, iterator of (str, ...))
Generate file paths with given current prefix as completion candidates
current
(str) — The current word or prefix under cursor
pyparam.param.
ParamDir
(
names
, default
, desc
, prefix='auto'
, show=True
, required=False
, subtype=None
, type_frozen=True
, callback=None
, complete_callback=None
, argname_shorten=True
, **kwargs
)
Subclass of ParamPath.
It does not make any difference with pyparam. However, it works differently for completions. The completion items for this param will only give directories instead of all paths
names
(Union(str, list of str)) — The names of the parameterdefault
(any) — The default valuedesc
(list of str) — The description of the parameterprefix
(str, optional) — The prefix of the parameter on the command lineshow
(bool, optional) — Whether this parameter should show on help pagerequired
(bool, optional) — Whether this parameter is requiredsubtype
(str or bool, optional) — The subtype of the parameter if this is a complex typetype_frozen
(bool, optional) — Whether the type is frozen (not allowing overwritting from command line)callback
(callable, optional) — The callback to modify the final valuecomplete_callback
(callable, optional) — The callback for complete the values of the parameterargname_shorten
(bool, optional) — Whether show shortened name for parameters under namespace parameters**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Generate dir paths with given current prefix as completion candidates</>consume
(
value
)
(bool) — Consume a value</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
consume
(
value
)
Consume a value
True if value was consumed, otherwise False
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
complete_value
(
current
, prefix=''
)
→ Union(str, iterator of (str, ...))
Generate dir paths with given current prefix as completion candidates
current
(str) — The current word or prefix under cursor
pyparam.param.
ParamPy
(
names
, default
, desc
, prefix='auto'
, show=True
, required=False
, subtype=None
, type_frozen=True
, callback=None
, complete_callback=None
, argname_shorten=True
, **kwargs
)
A parameter whose value will be ast.literal_eval'ed
names
(Union(str, list of str)) — The names of the parameterdefault
(any) — The default valuedesc
(list of str) — The description of the parameterprefix
(str, optional) — The prefix of the parameter on the command lineshow
(bool, optional) — Whether this parameter should show on help pagerequired
(bool, optional) — Whether this parameter is requiredsubtype
(str or bool, optional) — The subtype of the parameter if this is a complex typetype_frozen
(bool, optional) — Whether the type is frozen (not allowing overwritting from command line)callback
(callable, optional) — The callback to modify the final valuecomplete_callback
(callable, optional) — The callback for complete the values of the parameterargname_shorten
(bool, optional) — Whether show shortened name for parameters under namespace parameters**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Give the completion candidates</>consume
(
value
)
(bool) — Consume a value</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_value
(
current
, prefix=''
)
Give the completion candidates
current
(str) — Current prefix
None when there are no candidates, nor should we have next paramters/commands as candidates (requiring a value). An empty string if we should put next parameters/commands as candidates. Otherwise yields The candidates should be either 1-, 2-, or 3-element tuple. If 1-element, type plain and no description implied. If 2-element, type plain and 2nd element should be description. If 3-element, 2nd element the type, 3rd the description.
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
consume
(
value
)
Consume a value
True if value was consumed, otherwise False
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
pyparam.param.
ParamJson
(
names
, default
, desc
, prefix='auto'
, show=True
, required=False
, subtype=None
, type_frozen=True
, callback=None
, complete_callback=None
, argname_shorten=True
, **kwargs
)
A parameter whose value will be parsed as json
names
(Union(str, list of str)) — The names of the parameterdefault
(any) — The default valuedesc
(list of str) — The description of the parameterprefix
(str, optional) — The prefix of the parameter on the command lineshow
(bool, optional) — Whether this parameter should show on help pagerequired
(bool, optional) — Whether this parameter is requiredsubtype
(str or bool, optional) — The subtype of the parameter if this is a complex typetype_frozen
(bool, optional) — Whether the type is frozen (not allowing overwritting from command line)callback
(callable, optional) — The callback to modify the final valuecomplete_callback
(callable, optional) — The callback for complete the values of the parameterargname_shorten
(bool, optional) — Whether show shortened name for parameters under namespace parameters**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Give the completion candidates</>consume
(
value
)
(bool) — Consume a value</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_value
(
current
, prefix=''
)
Give the completion candidates
current
(str) — Current prefix
None when there are no candidates, nor should we have next paramters/commands as candidates (requiring a value). An empty string if we should put next parameters/commands as candidates. Otherwise yields The candidates should be either 1-, 2-, or 3-element tuple. If 1-element, type plain and no description implied. If 2-element, type plain and 2nd element should be description. If 3-element, 2nd element the type, 3rd the description.
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
consume
(
value
)
Consume a value
True if value was consumed, otherwise False
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
pyparam.param.
ParamList
(
*args
, **kwargs
)
A parameter whose value is a list
**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Give the completion candidates</>consume
(
value
)
(bool) — Should I consume given parameter?</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Also register reset type</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Deal with when param_type is reset</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_value
(
current
, prefix=''
)
Give the completion candidates
current
(str) — Current prefix
None when there are no candidates, nor should we have next paramters/commands as candidates (requiring a value). An empty string if we should put next parameters/commands as candidates. Otherwise yields The candidates should be either 1-, 2-, or 3-element tuple. If 1-element, type plain and no description implied. If 2-element, type plain and 2nd element should be description. If 3-element, 2nd element the type, 3rd the description.
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
on_register
(
)
Also register reset type
consume
(
value
)
→ bool
Should I consume given parameter?
push
(
item
)
Push a value into the stack for calculating
pyparam.param.
ParamChoice
(
*args
, **kwargs
)
A bool parameter whose value is automatically casted into a bool
**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
— Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
— If default is not specified in desc, just to add with the default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Generate choices with given current prefix as completion candidates</>consume
(
value
)
(bool) — Consume a value</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
)
— Push a value into the stack for calculating</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
consume
(
value
)
Consume a value
True if value was consumed, otherwise False
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
push
(
item
)
Push a value into the stack for calculating
The item to be pushed
complete_value
(
current
, prefix=''
)
→ Union(str, iterator of (str, ...))
Generate choices with given current prefix as completion candidates
current
(str) — The current word or prefix under cursor
pyparam.param.
ParamNamespace
(
*args
, **kwargs
)
A pseudo parameter serving as a namespace for parameters under it
So that it is possible to do:
prog --namespace.arg1 1 --namespace.arg2 2
**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
(str) — Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
(list of str) — Namespace parameters do not have a default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Give the completion candidates</>consume
(
value
)
(bool) — Should I consume given parameter?</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>decendents
(
show_only
)
(list of Param) — Get all decendents of this namespace parameter</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>get_param
(
name
,depth
)
(Param) — Get the paraemeter by given name</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
,depth
)
— Push the parameter under this namespace.</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_value
(
current
, prefix=''
)
Give the completion candidates
current
(str) — Current prefix
None when there are no candidates, nor should we have next paramters/commands as candidates (requiring a value). An empty string if we should put next parameters/commands as candidates. Otherwise yields The candidates should be either 1-, 2-, or 3-element tuple. If 1-element, type plain and no description implied. If 2-element, type plain and 2nd element should be description. If 3-element, 2nd element the type, 3rd the description.
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
consume
(
value
)
→ bool
Should I consume given parameter?
push
(
item
, depth=0
)
Push the parameter under this namespace.
We are not pushing any values to this namespace, but pushing parameters that are under it.
pyparam.param.
ParamNamespace
(
*args
, **kwargs
)
A pseudo parameter serving as a namespace for parameters under it
So that it is possible to do:
prog --namespace.arg1 1 --namespace.arg2 2
**kwargs
(dict(str: any)) — Additional keyword arguments
_desc
(list of str) — The raw description of the parameter_kwargs
(dict(str: any)) — other kwargs_stack
(list of any) — The stack to push the values_value_cached
(any) — The cached value calculated from the stackargname_shorten
(bool) — Whether show shortened name for the parameters under namespace parameterscallback
(callable) — The callback to modify the final valuecomplete_callback
(callable) — The callback for complete the values of the parameterdefault
— The default valuedefault_group
(str) — Get the default group of the parameter</>desc
(list of str) — The formatted description using attributes and _kwargs</>desc_with_default
(list of str) — Namespace parameters do not have a default value</>hit
(bool) — Whether the parameter is just hitis_help
(bool) — Whether this is a help parameteris_positional
— Tell if this parameter is positional</>names
— The names of the parameterns_param
(ParamNamespace) — The namespace parameter where this parameter is underprefix
(str) — The prefix of the parameter on the command linerequired
(bool) — Whether this parameter is requiredshow
(bool) — Whether this parameter should show on help pagesubtype
— The subtype of the parameter if this is a complex typetype_frozen
(bool) — Whether the type is frozen (not allowing overwritting from command line)value
— Return the cached value if possible, otherwise calcuate one</>
apply_callback
(
all_values
)
(any) — Apply the callback function to the value</>close
(
)
— Close up the parameter while scanning the command line</>complete_name
(
current
)
(iterator of (str, str)) — Give the completion name candidates</>complete_value
(
current
,prefix
)
(Union(str, iterator of (str, ...))) — Give the completion candidates</>consume
(
value
)
(bool) — Should I consume given parameter?</>copy
(
)
(Param) — Copy a parameter so that it can be reused.</>decendents
(
show_only
)
(list of Param) — Get all decendents of this namespace parameter</>full_names
(
)
(list of str) — make the names with full combinations of namespaces and terminals</>get_param
(
name
,depth
)
(Param) — Get the paraemeter by given name</>name
(
which
,with_prefix
)
(str) — Get the shortest/longest name of the parameter</>namespaces
(
index
)
(Union(list of str, int)) — Get the namespaces at the given index or number of namespaces</>namestr
(
sep
,with_prefix
)
(str) — Get all names connected with a separator.</>on_register
(
)
— Opens opportunity to do something when a parameter is registered</>optstr
(
)
(str) — Get the string representation of the parameter names and types in the optname section in help page</>overwrite_type
(
param_type
)
(Param) — Try to overwrite the type</>push
(
item
,depth
)
— Push the parameter under this namespace.</>to
(
to_type
)
(Param) — Generate a different type of parameter using current settings</>typestr
(
)
(str) — Get the string representation of the type</>usagestr
(
)
(str) — Get the string representation of the parameter in the default usage constructor</>
complete_value
(
current
, prefix=''
)
Give the completion candidates
current
(str) — Current prefix
None when there are no candidates, nor should we have next paramters/commands as candidates (requiring a value). An empty string if we should put next parameters/commands as candidates. Otherwise yields The candidates should be either 1-, 2-, or 3-element tuple. If 1-element, type plain and no description implied. If 2-element, type plain and 2nd element should be description. If 3-element, 2nd element the type, 3rd the description.
complete_name
(
current
)
Give the completion name candidates
current
(str) — The current prefix or word under cursor
An iterator of a tuple including the prefixed name and description.
on_register
(
)
Opens opportunity to do something when a parameter is registered
namespaces
(
index='len'
)
Get the namespaces at the given index or number of namespaces
index
(int or str, optional) — The index or a length indicator
The length of the namespaces or the namespaces at index.
full_names
(
)
make the names with full combinations of namespaces and terminals
Since one can define a parameter like n.arg
but namespace n
can
have aliases (i.e. ns
). This makes sure the names of n.arg
expands
to n.arg
and ns.arg
The names with full combinations of namespaces and terminals
close
(
)
Close up the parameter while scanning the command line
We are mostly doing nothing, only if, say, param is bool and it was just hit, we should push a true value to it.
overwrite_type
(
param_type
)
Try to overwrite the type
Only when param_type is not None and it's different from mine A new param will be returned if different
param_type
(str) — The type to overwrite
Self when type not changed otherwise a new parameter with the given type
name
(
which
, with_prefix=True
)
Get the shortest/longest name of the parameter
A name is ensured to be returned. It does not mean it is the real short/long name, but just the shortest/longest name among all the names
which
(str) — Whether get the shortest or longest name Could useshort
orlong
for short.with_prefix
(bool, optional) — Whether to include the prefix or not
The shortest/longest name of the parameter
namestr
(
sep=', '
, with_prefix=True
)
Get all names connected with a separator.
sep
(str, optional) — The separator to connect the nameswith_prefix
(bool, optional) — Whether to include the prefix or not
the connected names
typestr
(
)
Get the string representation of the type
the string representation of the type
usagestr
(
)
Get the string representation of the parameter in the default usage constructor
the string representation of the parameter in the default usage
optstr
(
)
Get the string representation of the parameter names and types in the optname section in help page
the string representation of the parameter names and types in the optname section in help page
consume
(
value
)
→ bool
Should I consume given parameter?
push
(
item
, depth=0
)
Push the parameter under this namespace.
We are not pushing any values to this namespace, but pushing parameters that are under it.
pyparam.param.
register_param
(
param
)
Register a parameter class
param
(type of Param) — The param to register A param class should include a type You can also define type alias for a param type