palgen.application.util
#
Module Contents#
- palgen.application.util.T#
- class palgen.application.util.ListParam(initlist=None)#
palgen.application.util.ListParam _collections_abc.Collection _collections_abc.Collection _collections_abc.Container _collections_abc.Container _collections_abc.Collection->_collections_abc.Container _collections_abc.Iterable _collections_abc.Iterable _collections_abc.Collection->_collections_abc.Iterable _collections_abc.Sized _collections_abc.Sized _collections_abc.Collection->_collections_abc.Sized _collections_abc.MutableSequence _collections_abc.MutableSequence _collections_abc.Sequence _collections_abc.Sequence _collections_abc.MutableSequence->_collections_abc.Sequence _collections_abc.Reversible _collections_abc.Reversible _collections_abc.Reversible->_collections_abc.Iterable _collections_abc.Sequence->_collections_abc.Collection _collections_abc.Sequence->_collections_abc.Reversible abc.ABC abc.ABC click.types.ParamType click.types.ParamType collections.UserList collections.UserList collections.UserList->_collections_abc.MutableSequence palgen.application.util.ListParam palgen.application.util.ListParam palgen.application.util.ListParam palgen.application.util.ListParam->abc.ABC palgen.application.util.ListParam->click.types.ParamType palgen.application.util.ListParam->collections.UserList Click friendly list proxy. Can be used like a parameterized generic, ie ListParam[int] will check if all elements of the list are actually of type int.
- name = 'list'#
- __class_getitem__#
- __rmul__#
- __slots__ = ()#
- __abc_tpflags__#
- convert(value, *_)#
Convert the value to the correct type. This is not called if the value is
None
(the missing value).This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.
The
param
andctx
arguments may beNone
in certain situations, such as when converting prompt input.If the value cannot be converted, call
fail()
with a descriptive message.- Parameters:
value – The value to convert.
param – The parameter that is using this type to convert its value. May be
None
.ctx – The current context that arrived at this value. May be
None
.
- __repr__()#
Return repr(self).
- __lt__(other)#
Return self<value.
- __le__(other)#
Return self<=value.
- __eq__(other)#
Return self==value.
- __gt__(other)#
Return self>value.
- __ge__(other)#
Return self>=value.
- __contains__(item)#
- __len__()#
- __getitem__(i)#
- __setitem__(i, item)#
- __delitem__(i)#
- __add__(other)#
- __radd__(other)#
- __iadd__(other)#
- __mul__(n)#
- __imul__(n)#
- __copy__()#
- append(item)#
S.append(value) – append value to the end of the sequence
- insert(i, item)#
S.insert(index, value) – insert value before index
- pop(i=-1)#
S.pop([index]) -> item – remove and return item at index (default last). Raise IndexError if list is empty or index is out of range.
- remove(item)#
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- clear()#
S.clear() -> None – remove all items from S
- copy()#
- count(item)#
S.count(value) -> integer – return number of occurrences of value
- index(item, *args)#
S.index(value, [start, [stop]]) -> integer – return first index of value. Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- reverse()#
S.reverse() – reverse IN PLACE
- sort(/, *args, **kwds)#
- extend(other)#
S.extend(iterable) – extend sequence by appending elements from the iterable
- __iter__()#
- __reversed__()#
- classmethod __subclasshook__(C)#
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- to_info_dict()#
Gather information that could be useful for a tool generating user-facing documentation.
Use
click.Context.to_info_dict()
to traverse the entire CLI structure.New in version 8.0.
- Return type:
Dict[str, Any]
- __call__(value, param=None, ctx=None)#
- Parameters:
value (Any) –
param (Optional[click.core.Parameter]) –
ctx (Optional[click.core.Context]) –
- Return type:
Any
- get_metavar(param)#
Returns the metavar default for this param if it provides one.
- Parameters:
param (click.core.Parameter) –
- Return type:
Optional[str]
- get_missing_message(param)#
Optionally might return extra information about a missing parameter.
New in version 2.0.
- Parameters:
param (click.core.Parameter) –
- Return type:
Optional[str]
- split_envvar_value(rv)#
Given a value from an environment variable this splits it up into small chunks depending on the defined envvar list splitter.
If the splitter is set to None, which means that whitespace splits, then leading and trailing whitespace is ignored. Otherwise, leading and trailing splitters usually lead to empty items being included.
- fail(message, param=None, ctx=None)#
Helper method to fail with an invalid value message.
- Parameters:
message (str) –
param (Optional[click.core.Parameter]) –
ctx (Optional[click.core.Context]) –
- Return type:
NoReturn
- shell_complete(ctx, param, incomplete)#
Return a list of
CompletionItem
objects for the incomplete value. Most types do not provide completions, but some do, and this allows custom types to provide custom completions as well.- Parameters:
ctx (click.core.Context) – Invocation context for this command.
param (click.core.Parameter) – The parameter that is requesting completion.
incomplete (str) – Value being completed. May be empty.
- Return type:
List[click.shell_completion.CompletionItem]
New in version 8.0.
- palgen.application.util.K#
- palgen.application.util.V#
- class palgen.application.util.DictParam(dict=None, /, **kwargs)#
palgen.application.util.DictParam _collections_abc.Collection _collections_abc.Collection _collections_abc.Container _collections_abc.Container _collections_abc.Collection->_collections_abc.Container _collections_abc.Iterable _collections_abc.Iterable _collections_abc.Collection->_collections_abc.Iterable _collections_abc.Sized _collections_abc.Sized _collections_abc.Collection->_collections_abc.Sized _collections_abc.Mapping _collections_abc.Mapping _collections_abc.Mapping->_collections_abc.Collection _collections_abc.MutableMapping _collections_abc.MutableMapping _collections_abc.MutableMapping->_collections_abc.Mapping abc.ABC abc.ABC click.types.ParamType click.types.ParamType collections.UserDict collections.UserDict collections.UserDict->_collections_abc.MutableMapping palgen.application.util.DictParam palgen.application.util.DictParam palgen.application.util.DictParam palgen.application.util.DictParam->abc.ABC palgen.application.util.DictParam->click.types.ParamType palgen.application.util.DictParam->collections.UserDict Click friendly dict proxy. Can be used like a parameterized generic. ie:
DictParam[str, int] will check all keys for type :code:`str
and all values for typeint
- name = 'dict'#
- __slots__ = ()#
- __abc_tpflags__#
- __reversed__#
- convert(value, param, ctx)#
Convert the value to the correct type. This is not called if the value is
None
(the missing value).This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.
The
param
andctx
arguments may beNone
in certain situations, such as when converting prompt input.If the value cannot be converted, call
fail()
with a descriptive message.- Parameters:
value – The value to convert.
param – The parameter that is using this type to convert its value. May be
None
.ctx – The current context that arrived at this value. May be
None
.
- classmethod new(key, value)#
- classmethod __class_getitem__(item)#
- to_info_dict()#
Gather information that could be useful for a tool generating user-facing documentation.
Use
click.Context.to_info_dict()
to traverse the entire CLI structure.New in version 8.0.
- Return type:
Dict[str, Any]
- __call__(value, param=None, ctx=None)#
- Parameters:
value (Any) –
param (Optional[click.core.Parameter]) –
ctx (Optional[click.core.Context]) –
- Return type:
Any
- get_metavar(param)#
Returns the metavar default for this param if it provides one.
- Parameters:
param (click.core.Parameter) –
- Return type:
Optional[str]
- get_missing_message(param)#
Optionally might return extra information about a missing parameter.
New in version 2.0.
- Parameters:
param (click.core.Parameter) –
- Return type:
Optional[str]
- split_envvar_value(rv)#
Given a value from an environment variable this splits it up into small chunks depending on the defined envvar list splitter.
If the splitter is set to None, which means that whitespace splits, then leading and trailing whitespace is ignored. Otherwise, leading and trailing splitters usually lead to empty items being included.
- fail(message, param=None, ctx=None)#
Helper method to fail with an invalid value message.
- Parameters:
message (str) –
param (Optional[click.core.Parameter]) –
ctx (Optional[click.core.Context]) –
- Return type:
NoReturn
- shell_complete(ctx, param, incomplete)#
Return a list of
CompletionItem
objects for the incomplete value. Most types do not provide completions, but some do, and this allows custom types to provide custom completions as well.- Parameters:
ctx (click.core.Context) – Invocation context for this command.
param (click.core.Parameter) – The parameter that is requesting completion.
incomplete (str) – Value being completed. May be empty.
- Return type:
List[click.shell_completion.CompletionItem]
New in version 8.0.
- __len__()#
- __getitem__(key)#
- __setitem__(key, item)#
- __delitem__(key)#
- __iter__()#
- __contains__(key)#
- __repr__()#
Return repr(self).
- __or__(other)#
- __ror__(other)#
- __ior__(other)#
- __copy__()#
- copy()#
- classmethod fromkeys(iterable, value=None)#
- pop(key, default=__marker)#
D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem()#
D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.
- clear()#
D.clear() -> None. Remove all items from D.
- update(other=(), /, **kwds)#
D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
- setdefault(key, default=None)#
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
- get(key, default=None)#
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- keys()#
D.keys() -> a set-like object providing a view on D’s keys
- items()#
D.items() -> a set-like object providing a view on D’s items
- values()#
D.values() -> an object providing a view on D’s values
- __eq__(other)#
Return self==value.
- classmethod __subclasshook__(C)#
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- palgen.application.util.extract_help(hint)#
Extracts help text from a variable annotated with an
Annotated[...]
with at least one string among the parameters.ie.
Annotated[int, "This takes a whole number"]
also supports unions and parameterized generics as parameters, ieAnnotated[int | str, "Takes a number or a string"]
Annotated[ListParam[int], "Takes a list of ints"]
- Parameters:
hint (
_type_
) – _description_- Returns:
_description_
- Return type:
- palgen.application.util.pydantic_to_click(cls)#
Converts a extension’s Settings schema to click arguments.
To make an argument optional annotated with a union of the desired type and
None
or utilizetyping.Optional
.Attributes annotated with
bool
will haveis_flag
set, meaning they will be treated as flags.Help text is automatically extracted from attributes annotated with
Annotated[..., "help text"]
- palgen.application.util.strip_quotes(string)#