core.utils package¶
Submodules¶
core.utils.exceptions module¶
- exception core.utils.exceptions.CommandNotFound(message: str)¶
Bases:
Exception
- exception core.utils.exceptions.PathNotFound(message: str)¶
Bases:
Exception
core.utils.functions module¶
- core.utils.functions.extract_year(raw_text: str) str¶
Extracts a year (4 digits) from a text.
- Parameters:
raw_text (str) – The input text to search for a year.
- Returns:
The extracted year as a string, or “Unknown” if no valid year is found.
- Return type:
str
Example
>>> extract_year("The event happened in 2025.") '2025'
>>> extract_year("No year mentioned here.") 'Unknown'
- core.utils.functions.get_type_choice(param: str, valid_params: list[str]) str¶
Returns the folder type based on the parameter.
- Parameters:
param (str) – The input parameter that specifies the type.
valid_params (list[str]) – A list of valid parameters.
- Raises:
CommandNotFound – If param is “Unknown”.
ValueError – If param is not in valid_params.
- Returns:
The corresponding folder type (“Series”, “Movies”, or “unknown”).
- Return type:
str
- core.utils.functions.remove_ansi_escape_codes(log_entry: str) str¶
Removes ANSI escape codes (colors) from a string of text.
- Parameters:
log_entry (str) – The string containing ANSI escape codes.
- Returns:
The string with ANSI escape codes removed.
- Return type:
str
Example
>>> remove_ansi_escape_codes('[31mRed[0m') 'Red'
- core.utils.functions.sanitize_filename(filename: str) str¶
Replace any invalid Windows filename characters with an underscore.
- Parameters:
filename (str) – The filename to sanitize.
- Returns:
A sanitized filename with invalid characters replaced by underscores.
- Return type:
str
Example
>>> sanitize_filename("invalid|filename?.txt") 'invalid_filename_.txt'