pic_scanner.helpers.filesystem

__init__.py

The filesystem module provides functions for working with the filesystem.

This module provides functions for checking if a path is valid, checking if a directory is valid, checking if a file is valid, provisioning a path, provisioning a list of paths, gathering files in a directory, and getting the abbreviation for a storage unit.

Functions:
check_path:

Check if a path is valid.

check_directory:

Check if a directory is valid.

check_file:

Check if a file is valid.

provision_path:

Provision a path.

provision_paths:

Provision a list of paths.

gather_files_in_dir:

Gather all files in a directory.

get_storage_unit_abbreviation:

Get the abbreviation for a storage unit.

Since:

1.0

Submodules

Functions

check_path(→ bool)

Check if a path is valid.

check_directory(→ bool)

Check if a directory is valid.

check_file(→ bool)

Check if a file is valid.

provision_path(→ pathlib.Path)

Provision a path.

Package Contents

pic_scanner.helpers.filesystem.check_path(path: str | pathlib.Path, do_not_expand: bool = False, do_not_resolve: bool = False, do_not_convert: bool = False, do_not_provision: bool = False) bool

Check if a path is valid.

This function checks if a path is valid. If the path is a string, it will be converted to a Path object. If the path is not expanded, it will be expanded. If the path is not resolved, it will be resolved. If the path is not converted to a string, it will be converted to a string. If the path is not provisioned, it will be provisioned.

Note

Provisioning a path involves converting it to a Path object, expanding it, and resolving it.

Parameters:
  • path (Union[str, Path]) – The path to check.

  • do_not_expand (bool) – A flag indicating whether to expand the path.

  • do_not_resolve (bool) – A flag indicating whether to resolve the path.

  • do_not_convert (bool) – A flag indicating whether to convert the path to a string.

  • do_not_provision (bool) – A flag indicating whether to provision the path.

Returns:

A flag indicating whether the path is valid.

Return type:

bool

pic_scanner.helpers.filesystem.check_directory(path: str | pathlib.Path, **kwargs) bool

Check if a directory is valid.

This function checks if a directory is valid. If the path is a string, it will be converted to a Path object. If the path is not expanded, it will be expanded. If the path is not resolved, it will be resolved. If the path is not converted to a string, it will be converted to a string. If the path is not provisioned, it will be provisioned.

Note

Provisioning a path involves converting it to a Path object, expanding it, and resolving it.

Parameters:
  • path (Union[str, Path]) – The directory to check.

  • **kwargs – Additional keyword arguments.

Returns:

A flag indicating whether the directory is valid.

Return type:

bool

pic_scanner.helpers.filesystem.check_file(path: str | pathlib.Path, **kwargs) bool

Check if a file is valid.

Parameters:

path (Union[str, Path]) – The file to check.

Returns:

A flag indicating whether the file is valid.

Return type:

bool

pic_scanner.helpers.filesystem.provision_path(path: str | pathlib.Path, do_not_expand: bool = False, do_not_resolve: bool = False, do_not_convert: bool = False) pathlib.Path

Provision a path.

Parameters:
  • path (str) – The path to provision.

  • do_not_convert (bool) – A flag indicating whether to convert the path to a string.

  • do_not_expand (bool) – A flag indicating whether to expand the path.

  • do_not_resolve (bool) – A flag indicating whether to resolve the path.

Returns:

The provisioned path.

Return type:

Path