Skip to content

Utils

DataSources

Bases: str, Enum

Enumeration for various comic data sources.

This class defines a set of constants representing different sources of comic data. Each constant is a string that corresponds to a specific data source name.

ATTRIBUTE DESCRIPTION
COMIC_VINE

Represents the Comic Vine data source.

METRON

Represents the Metron data source.

GCD

Represents the Grand Comics Database data source.

KITSU

Represents the Kitsu data source.

MANGADEX

Represents the MangaDex data source.

MANGAUPDATES

Represents the MangaUpdates data source.

get_issue_id_from_note(note_txt: str) -> dict[str, str] | None

Extract the issue ID from a given note text based on specific keywords and formats.

This function identifies the source of the issue ID and returns it along with the ID itself.

PARAMETER DESCRIPTION
note_txt

The text from which to extract the issue ID.

TYPE: str

RETURNS DESCRIPTION
dict[str, str] | None

A dictionary containing the source and the issue ID if found, otherwise None.

Examples:

Python Console Session
>>> get_issue_id_from_note("metrontagger issue_id:12345")
{'source': 'Metron', 'id': '12345'}
Python Console Session
>>> get_issue_id_from_note("comictagger comic vine issue id 67890")
{'source': 'Comic Vine', 'id': '67890'}

get_recursive_filelist(path_list: list[Path]) -> list[Path]

Retrieve a list of comic files recursively from the provided paths.

PARAMETER DESCRIPTION
path_list

List of paths to search for files.

TYPE: list[Path]

RETURNS DESCRIPTION
list[Path]

A sorted list of comic files found in the provided paths.

Examples:

Python Console Session
>>> paths = [Path("/comics"), Path("/manga/series.cbz")]
>>> files = get_recursive_filelist(paths)
>>> len(files) > 0  # Returns True if comic files are found
True

list_to_string(list_of_strings: list[str]) -> str

Convert a list of strings into a single comma-separated string.

Strings containing commas are wrapped in double quotes to preserve structure.

PARAMETER DESCRIPTION
list_of_strings

The list of strings to convert.

TYPE: list[str]

RETURNS DESCRIPTION
str

The comma-separated string.

Examples:

Python Console Session
>>> list_to_string(["apple", "banana", "cherry"])
'apple, banana, cherry'
Python Console Session
>>> list_to_string(["item, with comma", "normal item"])
'"item, with comma", normal item'

remove_articles(text: str) -> str

Remove common articles and stop words from the input text.

PARAMETER DESCRIPTION
text

The text from which articles are to be removed.

TYPE: str

RETURNS DESCRIPTION
str

The text with articles removed.

Examples:

Python Console Session
>>> remove_articles("The Amazing Spider-Man")
'Amazing Spider-Man'
Python Console Session
>>> remove_articles("A tale of two cities")
'tale two cities'

unique_file(file_name: Path) -> Path

Generate a unique file name by appending a number in parentheses if the original exists.

PARAMETER DESCRIPTION
file_name

The original file name to make unique.

TYPE: Path

RETURNS DESCRIPTION
Path

The unique file name.

Examples:

Python Console Session
>>> original = Path("document.cbz")
>>> unique = unique_file(original)  # Returns "document (1).cbz" if original exists
>>> isinstance(unique, Path)
True