class Path(ParamType):
The path type is similar to the File
type but it performs
different checks. First of all, instead of returning an open file
handle it returns just the filename. Secondly, it can perform various
basic checks about what the file or directory should be.
Parameters | |
exists | if set to true, the file or directory needs to exist for this value to be valid. If this is not required and a file does indeed not exist, then all further checks are silently skipped. |
file_okay | controls if a file is a possible value. |
dir_okay | controls if a directory is a possible value. |
writable | if true, a writable check is performed. |
readable | if true, a readable check is performed. |
resolve_path | if this is true, then the path is fully resolved before the value is passed onwards. This means that it's absolute and symlinks are resolved. It will not expand a tilde-prefix, as this is supposed to be done by the shell only. |
allow_dash | If this is set to True , a single dash to indicate
standard streams is permitted. |
path_type | Convert the incoming path value to this type. If
None, keep Python's default, which is str. Useful to
convert to pathlib.Path . |
Method | __init__ |
Undocumented |
Method | coerce_path_result |
Undocumented |
Method | convert |
Convert the value to the correct type. This is not called if the value is None (the missing value). |
Method | shell_complete |
Return a special completion marker that tells the completion system to use the shell to provide path completions for only directories or any paths. |
Method | to_info_dict |
Gather information that could be useful for a tool generating user-facing documentation. |
Instance Variable | allow_dash |
Undocumented |
Instance Variable | dir_okay |
Undocumented |
Instance Variable | exists |
Undocumented |
Instance Variable | file_okay |
Undocumented |
Instance Variable | name |
Undocumented |
Instance Variable | readable |
Undocumented |
Instance Variable | resolve_path |
Undocumented |
Instance Variable | type |
Undocumented |
Instance Variable | writable |
Undocumented |
Inherited from ParamType
:
Method | __call__ |
Undocumented |
Method | fail |
Helper method to fail with an invalid value message. |
Method | get_metavar |
Returns the metavar default for this param if it provides one. |
Method | get_missing_message |
Optionally might return extra information about a missing parameter. |
Method | split_envvar_value |
Given a value from an environment variable this splits it up into small chunks depending on the defined envvar list splitter. |
Class Variable | arity |
Undocumented |
Class Variable | envvar_list_splitter |
Undocumented |
Class Variable | is_composite |
Undocumented |
Undocumented
Parameters | |
exists:bool | Undocumented |
file_okay:bool | Undocumented |
dir_okay:bool | Undocumented |
writable:bool | Undocumented |
readable:bool | Undocumented |
resolve_path:bool | Undocumented |
allow_dash:bool | Undocumented |
path_type:t.Optional[ | Undocumented |
Undocumented
Parameters | |
rv:t.Any | Undocumented |
Returns | |
t.Any | Undocumented |
click.types.ParamType.convert
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 and ctx arguments may be None in certain situations, such as when converting prompt input.
If the value cannot be converted, call fail
with a
descriptive message.
Parameters | |
value:t.Any | The value to convert. |
param:t.Optional[ | The parameter that is using this type to convert its value. May be None. |
ctx:t.Optional[ | The current context that arrived at this value. May be None. |
Returns | |
t.Any | Undocumented |
click.types.ParamType.shell_complete
Return a special completion marker that tells the completion system to use the shell to provide path completions for only directories or any paths.
Parameters | |
ctx:Context | Invocation context for this command. |
param:Parameter | The parameter that is requesting completion. |
incomplete:str | Value being completed. May be empty. |
Returns | |
t.List[ | Undocumented |
click.types.ParamType.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.
Returns | |
t.Dict[ | Undocumented |