pic_scanner.helpers
Subpackages
Submodules
Attributes
list: |
|
Functions
|
Determine if an object is a class. |
|
Determine if an object is an instance of a class. |
|
Get a list of picture files in a directory. |
|
Get a FileCollection object for a directory. |
Get the name of the calling function. |
Package Contents
- pic_scanner.helpers.IMAGE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.bmp', '.tiff']
list: A list of valid image extensions.
- pic_scanner.helpers.MAIN_MOD_LOGGER
- pic_scanner.helpers.MOD_LOGGER
- pic_scanner.helpers.excluded = []
- pic_scanner.helpers.is_class(obj)
Determine if an object is a class.
- Parameters:
obj – The object to check.
- Returns:
True if the object is a class; False otherwise.
- Return type:
bool
Example
>>> is_class(str) True >>> is_class('string') False
- pic_scanner.helpers.is_instance(obj)
Determine if an object is an instance of a class.
- Parameters:
obj – The object to check.
- Returns:
True if the object is an instance of a class; False otherwise.
- Return type:
bool
Example
>>> is_instance(str) False >>> is_instance('string') True
- pic_scanner.helpers.get_picture_files(directory: str | pathlib.Path, recursive: bool = False, do_not_provision: bool = False, exclude_dir_names: list[str] = None, **kwargs) list
Get a list of picture files in a directory.
This function searches a directory for picture files and returns a list of the picture files found. The search can be performed recursively and specific directories can be excluded from the search.
Note
Use of the exclude_dir_names parameter is case-insensitive, and directory-depth is not considered when excluding directories. If a nested directory contains an excluded directory name, the nested directory will be excluded.
- Parameters:
directory (str or Path) – The directory to search for picture files.
recursive (bool) – A flag indicating whether to search recursively.
do_not_provision (bool) – A flag indicating whether to provision the directory.
exclude_dir_names (list) – A list of directory names to exclude.
**kwargs – Additional keyword arguments.
- Returns:
A list of picture files in the directory.
- Return type:
list[Path]
Example
>>> get_picture_files('path/to/directory', recursive=True) [Path('path/to/directory/image1.jpg'), Path('path/to/directory/image2.jpg')]
- pic_scanner.helpers.get_file_collection(directory: str | pathlib.Path, recursive: bool = False, do_not_provision: bool = False, exclude_dir_names: list[str] = None, **kwargs) filesystem.classes.FileCollection
Get a FileCollection object for a directory.
This function searches a directory for picture files and returns a FileCollection object containing the picture files found. The search can be performed recursively and specific directories can be excluded from the search.
Note
Use of the exclude_dir_names parameter is case-insensitive, and directory-depth is not considered when excluding directories. If a nested directory contains an excluded directory name, the nested directory will be excluded.
- Parameters:
directory (str or Path) – The directory to search for picture files.
recursive (bool) – A flag indicating whether to search recursively.
do_not_provision (bool) – A flag indicating whether to provision the directory.
exclude_dir_names (list) – A list of directory names to exclude.
**kwargs – Additional keyword arguments.
- Returns:
A FileCollection object containing the picture files in the directory.
- Return type:
Example
>>> get_file_collection('path/to/directory', recursive=True) FileCollection(paths=[Path('path/to/directory/image1.jpg'), Path('path/to/directory/image2.jpg')])
- pic_scanner.helpers.get_caller_name()
Get the name of the calling function.
- Returns:
The name of the calling function.
- Return type:
str
Example
>>> get_caller_name() 'get_caller_name'