upsies.utils.argtypes
CLI argument types
All types return normalized values and raise ValueError for invalid values.
A custom error message can be provided by raising
argparse.ArgumentTypeError.
Module Attributes
- upsies.utils.argtypes.ArgumentTypeError = <class 'argparse.ArgumentTypeError'>[source]
Exception that should be raised by any callable that is passed to
argparse.ArgumentParser.add_argument()as type if it gets an invalid value
Functions
- upsies.utils.argtypes.comma_separated(argtype)[source]
Multiple comma-separated values
- Parameters:
argtype – Any callable that returns a validated object for one of the comma-separated values or raises
ValueError,TypeErrororargparse.ArgumentTypeError- Returns:
Sequence of argtype return values
- upsies.utils.argtypes.episodes(value)[source]
Episodesinstance and episode title asstrIf no episode title is specified, the second return value is None.
- Example values:
"S03""S03E04""S03E04 The Episode Title"
- upsies.utils.argtypes.files_with_extension(extension, *, allow_no_hits=True)[source]
Return function that recursively searches a directory for files with extension
If the returned function gets a file path with the wanted extension, it is simply returned.
- Parameters:
extension (str) – Wanted file name extension (e.g. “png”)
allow_no_hits (bool) – Whether
argparse.ArgumentTypeErroris raised if no matching files are found
- upsies.utils.argtypes.imagehosts(value)[source]
Comma-separated list of names of image hosting services from
imagehosts
- upsies.utils.argtypes.integer(value, *, min=None, max=None)[source]
Natural number (
floatis rounded down)
- upsies.utils.argtypes.make_integer(*, min, max)[source]
Return function that takes a number and passes it to
integer()together with min and max
- upsies.utils.argtypes.one_of(values)[source]
Return function that returns an item of values or raises
argparse.ArgumentTypeError- Parameters:
values – Allowed values
- upsies.utils.argtypes.predb(value)[source]
PredbApiBaseinstance from a correspondingname
- upsies.utils.argtypes.regex(value)[source]
re.Patternobject
- upsies.utils.argtypes.release_year(value)[source]
ReleaseYearinstance
- upsies.utils.argtypes.webdb_id(webdb_name)[source]
Return function that finds a web DB ID in a string, e.g. an URL
- Parameters:
webdb_name (str) – Name of a web DB, e.g. “imdb”
The returned function takes any object and passes it to
get_id_from_text().