![]() |
Qucs-S S-parameter Viewer & RF Synthesis Tools
|


Public Member Functions | |
| None | __init__ (self, cabc.Sequence[str]|None param_decls=None, types.ParamType|t.Any|None type=None, bool required=False, t.Any|t.Callable[[], t.Any]|None default=UNSET, t.Callable[[Context, Parameter, t.Any], t.Any]|None callback=None, int|None nargs=None, bool multiple=False, str|None metavar=None, bool expose_value=True, bool is_eager=False, str|cabc.Sequence[str]|None envvar=None, t.Callable[[Context, Parameter, str], list[CompletionItem]|list[str]]|None shell_complete=None, bool|str deprecated=False) |
| dict[str, t.Any] | to_info_dict (self) |
| str | __repr__ (self) |
| str | human_readable_name (self) |
| str | make_metavar (self, Context ctx) |
| t.Any|None | get_default (self, Context ctx, t.Literal[True] call=True) |
| t.Any|t.Callable[[], t.Any]|None | get_default (self, Context ctx, bool call=...) |
| t.Any|t.Callable[[], t.Any]|None | get_default (self, Context ctx, bool call=True) |
| None | add_to_parser (self, _OptionParser parser, Context ctx) |
| tuple[t.Any, ParameterSource] | consume_value (self, Context ctx, cabc.Mapping[str, t.Any] opts) |
| t.Any | type_cast_value (self, Context ctx, t.Any value) |
| bool | value_is_missing (self, t.Any value) |
| t.Any | process_value (self, Context ctx, t.Any value) |
| str|None | resolve_envvar_value (self, Context ctx) |
| str|cabc.Sequence[str]|None | value_from_envvar (self, Context ctx) |
| tuple[t.Any, list[str]] | handle_parse_result (self, Context ctx, cabc.Mapping[str, t.Any] opts, list[str] args) |
| tuple[str, str]|None | get_help_record (self, Context ctx) |
| list[str] | get_usage_pieces (self, Context ctx) |
| str | get_error_hint (self, Context ctx) |
| list[CompletionItem] | shell_complete (self, Context ctx, str incomplete) |
Public Attributes | |
| name | |
| opts | |
| secondary_opts | |
| required | |
| callback | |
| nargs | |
| multiple | |
| expose_value | |
| is_eager | |
| metavar | |
| envvar | |
| deprecated | |
| param_type_name | |
Static Public Attributes | |
| str | param_type_name = "parameter" |
Protected Member Functions | |
| tuple[str|None, list[str], list[str]] | _parse_decls (self, cabc.Sequence[str] decls, bool expose_value) |
Protected Attributes | |
| _custom_shell_complete | |
A parameter to a command comes in two versions: they are either
:class:`Option`\s or :class:`Argument`\s. Other subclasses are currently
not supported by design as some of the internals for parsing are
intentionally not finalized.
Some settings are supported by both options and arguments.
:param param_decls: the parameter declarations for this option or
argument. This is a list of flags or argument
names.
:param type: the type that should be used. Either a :class:`ParamType`
or a Python type. The latter is converted into the former
automatically if supported.
:param required: controls if this is optional or not.
:param default: the default value if omitted. This can also be a callable,
in which case it's invoked when the default is needed
without any arguments.
:param callback: A function to further process or validate the value
after type conversion. It is called as ``f(ctx, param, value)``
and must return the value. It is called for all sources,
including prompts.
:param nargs: the number of arguments to match. If not ``1`` the return
value is a tuple instead of single value. The default for
nargs is ``1`` (except if the type is a tuple, then it's
the arity of the tuple). If ``nargs=-1``, all remaining
parameters are collected.
:param metavar: how the value is represented in the help page.
:param expose_value: if this is `True` then the value is passed onwards
to the command callback and stored on the context,
otherwise it's skipped.
:param is_eager: eager values are processed before non eager ones. This
should not be set for arguments or it will inverse the
order of processing.
:param envvar: environment variable(s) that are used to provide a default value for
this parameter. This can be a string or a sequence of strings. If a sequence is
given, only the first non-empty environment variable is used for the parameter.
:param shell_complete: A function that returns custom shell
completions. Used instead of the param's type completion if
given. Takes ``ctx, param, incomplete`` and must return a list
of :class:`~click.shell_completion.CompletionItem` or a list of
strings.
:param deprecated: If ``True`` or non-empty string, issues a message
indicating that the argument is deprecated and highlights
its deprecation in --help. The message can be customized
by using a string as the value. A deprecated parameter
cannot be required, a ValueError will be raised otherwise.
.. versionchanged:: 8.2.0
Introduction of ``deprecated``.
.. versionchanged:: 8.2
Adding duplicate parameter names to a :class:`~click.core.Command` will
result in a ``UserWarning`` being shown.
.. versionchanged:: 8.2
Adding duplicate parameter names to a :class:`~click.core.Command` will
result in a ``UserWarning`` being shown.
.. versionchanged:: 8.0
``process_value`` validates required parameters and bounded
``nargs``, and invokes the parameter callback before returning
the value. This allows the callback to validate prompts.
``full_process_value`` is removed.
.. versionchanged:: 8.0
``autocompletion`` is renamed to ``shell_complete`` and has new
semantics described above. The old name is deprecated and will
be removed in 8.1, until then it will be wrapped to match the
new requirements.
.. versionchanged:: 8.0
For ``multiple=True, nargs>1``, the default must be a list of
tuples.
.. versionchanged:: 8.0
Setting a default is no longer required for ``nargs>1``, it will
default to ``None``. ``multiple=True`` or ``nargs=-1`` will
default to ``()``.
.. versionchanged:: 7.1
Empty environment variables are ignored rather than taking the
empty string value. This makes it possible for scripts to clear
variables if they can't unset them.
.. versionchanged:: 2.0
Changed signature for parameter callback to also be passed the
parameter. The old callback format will still work, but it will
raise a warning to give you a chance to migrate the code easier.
| tuple[t.Any, ParameterSource] click.core.Parameter.consume_value | ( | self, | |
| Context | ctx, | ||
| cabc.Mapping[str, t.Any] | opts | ||
| ) |
Returns the parameter value produced by the parser. If the parser did not produce a value from user input, the value is either sourced from the environment variable, the default map, or the parameter's default value. In that order of precedence. If no value is found, an internal sentinel value is returned. :meta private:
Reimplemented in click.core.Option.
| t.Any | t.Callable[[], t.Any] | None click.core.Parameter.get_default | ( | self, | |
| Context | ctx, | ||
| bool | call = True |
||
| ) |
Get the default for the parameter. Tries
:meth:`Context.lookup_default` first, then the local default.
:param ctx: Current context.
:param call: If the default is a callable, call it. Disable to
return the callable instead.
.. versionchanged:: 8.0.2
Type casting is no longer performed when getting a default.
.. versionchanged:: 8.0.1
Type casting can fail in resilient parsing mode. Invalid
defaults will not prevent showing help text.
.. versionchanged:: 8.0
Looks at ``ctx.default_map`` first.
.. versionchanged:: 8.0
Added the ``call`` parameter.
| str click.core.Parameter.get_error_hint | ( | self, | |
| Context | ctx | ||
| ) |
Get a stringified version of the param for use in error messages to indicate which param caused the error.
Reimplemented in click.core.Option, and click.core.Argument.
| tuple[t.Any, list[str]] click.core.Parameter.handle_parse_result | ( | self, | |
| Context | ctx, | ||
| cabc.Mapping[str, t.Any] | opts, | ||
| list[str] | args | ||
| ) |
Process the value produced by the parser from user input. Always process the value through the Parameter's :attr:`type`, wherever it comes from. If the parameter is deprecated, this method warn the user about it. But only if the value has been explicitly set by the user (and as such, is not coming from a default). :meta private:
| str click.core.Parameter.human_readable_name | ( | self | ) |
Returns the human readable name of this parameter. This is the same as the name for options, but the metavar for arguments.
Reimplemented in click.core.Argument.
| t.Any click.core.Parameter.process_value | ( | self, | |
| Context | ctx, | ||
| t.Any | value | ||
| ) |
Process the value of this parameter: 1. Type cast the value using :meth:`type_cast_value`. 2. Check if the value is missing (see: :meth:`value_is_missing`), and raise :exc:`MissingParameter` if it is required. 3. If a :attr:`callback` is set, call it to have the value replaced by the result of the callback. If the value was not set, the callback receive ``None``. This keep the legacy behavior as it was before the introduction of the :attr:`UNSET` sentinel. :meta private:
Reimplemented in click.core.Option.
| str | None click.core.Parameter.resolve_envvar_value | ( | self, | |
| Context | ctx | ||
| ) |
Returns the value found in the environment variable(s) attached to this
parameter.
Environment variables values are `always returned as strings
<https://docs.python.org/3/library/os.html#os.environ>`_.
This method returns ``None`` if:
- the :attr:`envvar` property is not set on the :class:`Parameter`,
- the environment variable is not found in the environment,
- the variable is found in the environment but its value is empty (i.e. the
environment variable is present but has an empty string).
If :attr:`envvar` is setup with multiple environment variables,
then only the first non-empty value is returned.
.. caution::
The raw value extracted from the environment is not normalized and is
returned as-is. Any normalization or reconciliation is performed later by
the :class:`Parameter`'s :attr:`type`.
:meta private:
Reimplemented in click.core.Option.
| list[CompletionItem] click.core.Parameter.shell_complete | ( | self, | |
| Context | ctx, | ||
| str | incomplete | ||
| ) |
Return a list of completions for the incomplete value. If a ``shell_complete`` function was given during init, it is used. Otherwise, the :attr:`type` :meth:`~click.types.ParamType.shell_complete` function is used. :param ctx: Invocation context for this command. :param incomplete: Value being completed. May be empty. .. versionadded:: 8.0
| dict[str, t.Any] click.core.Parameter.to_info_dict | ( | self | ) |
Gather information that could be useful for a tool generating
user-facing documentation.
Use :meth:`click.Context.to_info_dict` to traverse the entire
CLI structure.
.. versionchanged:: 8.3.0
Returns ``None`` for the :attr:`default` if it was not set.
.. versionadded:: 8.0
Reimplemented in click.core.Option.
| t.Any click.core.Parameter.type_cast_value | ( | self, | |
| Context | ctx, | ||
| t.Any | value | ||
| ) |
Convert and validate a value against the parameter's :attr:`type`, :attr:`multiple`, and :attr:`nargs`.
| str | cabc.Sequence[str] | None click.core.Parameter.value_from_envvar | ( | self, | |
| Context | ctx | ||
| ) |
Process the raw environment variable string for this parameter. Returns the string as-is or splits it into a sequence of strings if the parameter is expecting multiple values (i.e. its :attr:`nargs` property is set to a value other than ``1``). :meta private:
Reimplemented in click.core.Option.
| bool click.core.Parameter.value_is_missing | ( | self, | |
| t.Any | value | ||
| ) |
A value is considered missing if: - it is :attr:`UNSET`, - or if it is an empty sequence while the parameter is suppose to have non-single value (i.e. :attr:`nargs` is not ``1`` or :attr:`multiple` is set). :meta private: