Files Module
Custom file / path input handlers for Parameters
- author:
Doug Skrypa
- class cli_command_parser.inputs.files.FileInput(*, exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = <StatMode:ANY>, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True)[source]
-
- exists: InputParam[bool | None]
- expand: InputParam[bool]
- resolve: InputParam[bool]
- type: InputParam[StatMode]
- readable: InputParam[bool]
- writable: InputParam[bool]
- allow_dash: InputParam[bool]
- use_windows_fix: InputParam[bool]
- class cli_command_parser.inputs.files.Path(*, exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = <StatMode:ANY>, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True)[source]
-
- Parameters:
exists¶ – If set, then the provided path must already exist if True, or must not already exist if False. Default: existence is not checked.
expand¶ – Whether tilde (
~) should be expanded.resolve¶ – Whether the path should be fully resolved to its absolute path, with symlinks resolved, or not.
type¶ – To restrict the acceptable types of files/directories that are accepted, specify the
StatModethat matches the desired type. By default, any type is accepted. To accept specifically only regular files or directories, for example, usetype=StatMode.DIR | StatMode.FILE.readable¶ – If True, the path must be readable.
writable¶ – If True, the path must be writable.
allow_dash¶ – Allow a dash (
-) to be provided to indicate stdin/stdout (default: False).use_windows_fix¶ – If True (the default) and the program is running on Windows, then
fix_windows_path()will be called to fix issues caused by auto-completion via Git Bash.fix_default¶ – Whether default values should be normalized using
fix_default().
- class cli_command_parser.inputs.files.File(mode: OpenTextMode = 'r', *, exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Literal[True] = True, parents: Bool = False)[source]
- class cli_command_parser.inputs.files.File(mode: OpenBinaryMode, *, exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Literal[True] = True, parents: Bool = False)
- class cli_command_parser.inputs.files.File(mode: OpenTextMode = 'r', *, exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Literal[False], parents: Bool = False)
- class cli_command_parser.inputs.files.File(mode: OpenBinaryMode, *, exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Literal[False], parents: Bool = False)
- class cli_command_parser.inputs.files.File(mode: OpenAnyMode = 'r', *, exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Bool = True, parents: Bool = False)
Bases:
FileInput[T_co]- Parameters:
mode¶ – The mode in which the file should be opened. For more info, see
open().encoding¶ – The encoding to use when reading the file in text mode. Ignored if the parsed path is
-.errors¶ – Error handling when reading the file in text mode. Ignored if the parsed path is
-.lazy¶ – If True, a
FileWrapperwill be stored in the Parameter using this File, otherwise the file will be read immediately upon parsing of the path argument.parents¶ – If True and
modeimplies writing, then create parent directories as needed. Ignored otherwise.
- type: InputParam[StatMode]
- mode: InputParam[OpenAnyMode]
- encoding: InputParam[str | None]
- errors: InputParam[str | None]
- lazy: InputParam[bool]
- parents: InputParam[bool]
- class cli_command_parser.inputs.files.Serialized(serializer: AnySerializer[AnyStr], *, mode: OpenAnyMode = 'r', exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Literal[True] = True, parents: Bool = False)[source]
- class cli_command_parser.inputs.files.Serialized(serializer: AnySerializer, *, mode: OpenAnyMode = 'r', exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Literal[False], parents: Bool = False)
- class cli_command_parser.inputs.files.Serialized(serializer: AnySerializer, *, mode: OpenAnyMode = 'r', exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Bool = True, parents: Bool = False)
Bases:
File[T_co]- Parameters:
serializer¶ – Class or module that provides
load/dumpand/orloads/dumpsmethods/functions for deserialization and serialization, respectively. Expects them to follow the same interface as the json or pickle modules, withjson.loads(),json.dumps(),pickle.load(), etc.
- serializer: AnySerializer
- class cli_command_parser.inputs.files.Json(*, mode: OpenTextMode = 'r', wrap_errors: Bool = True, exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Literal[True] = True, parents: Bool = False)[source]
- class cli_command_parser.inputs.files.Json(*, mode: OpenTextMode = 'r', wrap_errors: Bool = True, exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Literal[False], parents: Bool = False)
- class cli_command_parser.inputs.files.Json(*, mode: OpenTextMode = 'r', wrap_errors: Bool = True, exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Bool = True, parents: Bool = False)
Bases:
Serialized[T_co]
- class cli_command_parser.inputs.files.Pickle(*, mode: OpenBinaryMode = 'rb', exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Literal[True] = True, parents: Bool = False)[source]
- class cli_command_parser.inputs.files.Pickle(*, mode: OpenBinaryMode = 'rb', exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Literal[False], parents: Bool = False)
- class cli_command_parser.inputs.files.Pickle(*, mode: OpenBinaryMode = 'rb', exists: Bool = None, expand: Bool = True, resolve: Bool = False, type: StatMode | str = StatMode.FILE, readable: Bool = False, writable: Bool = False, allow_dash: Bool = False, use_windows_fix: Bool = True, fix_default: Bool = True, encoding: OptStr = None, errors: OptStr = None, lazy: Bool = True, parents: Bool = False)
Bases:
Serialized[T_co]