MWPath#

class lsst.daf.butler.cli.utils.MWPath(exists: bool | None = None, file_okay: bool = True, dir_okay: bool = True, writable: bool = False, readable: bool = True, resolve_path: bool = False, allow_dash: bool = False, path_type: type | None = None)#

Bases: Path

Overrides click.Path to implement file-does-not-exist checking.

Changes the definition of exists so that True indicates the location (file or directory) must exist, False indicates the location must not exist, and None indicates that the file may exist or not. The standard definition for the click.Path exists parameter is that for True a location must exist, but False means it is not required to exist (not that it is required to not exist).

Parameters#

existsbool or None, optional

If True, the location (file or directory) indicated by the caller must exist. If False the location must not exist. If None, the location may exist or not.

file_okaybool, optional

Allow a file as a value.

dir_okaybool, optional

Allow a directory as a value.

writablebool, optional

If True, a writable check is performed.

readablebool, optional

If True, a readable check is performed.

resolve_pathbool, optional

Resolve the path.

allow_dashbool, optional

Allow single dash as value to mean a standard stream.

path_typetype or None, optional

Convert the incoming value to this type.

Notes#

All parameters other than exists come directly from click.Path.

Methods Summary

convert(value, param, ctx)

Convert values through types.

Methods Documentation

convert(value: str | PathLike[str], param: Parameter | None, ctx: Context | None) Any#

Convert values through types.

Called by click.ParamType to “convert values through types”. click.Path uses this step to verify Path conditions.

Parameters#

valuestr or os.PathLike

File path.

paramclick.Parameter

Parameters provided by Click.

ctxclick.Context

Context provided by Click.