Module: libs/utilities.py
- Purpose:
This module provides utility-based functionality for the project.
- Platform:
Linux/Windows | Python 3.10+
- Developer:
J Berendt
- Email:
- Comments:
n/a
- class Utilities[source]
Bases:
objectGeneral (cross-project) utility functions.
- static collect_files(path: str, ext: str, recursive: bool) list[source]
Collect all files for a given extension from a path.
- Parameters:
path (str) – Full path serving as the root for the search.
ext (str, optional) –
If the
pathargument refers to a directory, a specific file extension can be specified here. For example:ext = 'pdf'.If anything other than
'**'is provided, all alpha-characters are parsed from the string, and prefixed with*.. Meaning, if'.pdf'is passed, the characters'pdf'are parsed and prefixed with*.to create'*.pdf'. However, if'things.foo'is passed, the derived extension will be'*.thingsfoo'. Defaults to ‘**’, for a recursive search.recursive (bool) – Instruct the search to recurse into sub-directories.
- Returns:
The list of full file paths returned by the
globcall. Any directory-only paths are removed.- Return type:
list
- static ispdf(path: str) bool[source]
Test the file signature. Verify this is a valid PDF file.
- Parameters:
path (str) – Path to the file being tested.
- Returns:
True if this is a valid PDF file, otherwise False.
- Return type:
bool