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.bool_or_none(value)[source]

Convert value to Bool or None if value is None

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, TypeError or argparse.ArgumentTypeError

Returns:

Sequence of argtype return values

upsies.utils.argtypes.content(value)[source]

Existing path to release file(s)

upsies.utils.argtypes.episodes(value)[source]

Episodes instance and episode title as str

If no episode title is specified, the second return value is None.

Example values:
  • "S03"

  • "S03E04"

  • "S03E04 The Episode Title"

upsies.utils.argtypes.existing_path(value)[source]

Path to existing path

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.ArgumentTypeError is raised if no matching files are found

upsies.utils.argtypes.imagehost(value)[source]

Name of a image hosting service from imagehosts

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 (float is rounded down)

Parameters:
  • min (int) – Minimum value

  • max (int) – Maximum value

upsies.utils.argtypes.make_integer(*, min, max)[source]

Return function that takes a number and passes it to integer() together with min and max

Parameters:
  • min (int) – Minimum number of screenshots

  • max (int) – Maximum number of screenshots

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]

PredbApiBase instance from a corresponding name

upsies.utils.argtypes.predb_name(value)[source]

Name of a scene release database from predbs

upsies.utils.argtypes.regex(value)[source]

re.Pattern object

upsies.utils.argtypes.release(value)[source]

Same as content(), but doesn’t have to exist

upsies.utils.argtypes.release_year(value)[source]

ReleaseYear instance

upsies.utils.argtypes.subtitle(value)[source]

Subtitle instance from language code

upsies.utils.argtypes.timestamp(value)[source]

Turn value into types.Timestamp

upsies.utils.argtypes.tracker(value)[source]

Name of a tracker from trackers

upsies.utils.argtypes.webdb(value)[source]

Name of a movie/series database from webdbs

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().