mediahandler.util.args

Module: mediahandler.util.args

Module contains:

class mediahandler.util.args.MHFilesAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)

Bases: argparse.Action

Custom files and folders validation action for argparse.

A child object of argparse.Action().

class mediahandler.util.args.MHMediaAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)

Bases: argparse.Action

Custom media validation action for argparse.

A child object of argparse.Action().

class mediahandler.util.args.MHParser(prog=None, usage=None, description=None, epilog=None, version=None, parents=, []formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True)

Bases: argparse.ArgumentParser

A child object of argparse.ArgumentParser().

Extends the following methods:
  • parse_known_args()
  • error()
  • print_help()
error(message)

Displays a simple help message via stdout before error messages.

Overrides the argparse.ArgumentParser() method.

parse_known_args(args=None, namespace=None)

Saves the array of args as ‘entered’ to the argparse.Namespace() object for use in the MHMediaAction() object. Removes the added values before returning the validated args.

Extends the argparse.ArgumentParser() method.

print_help(files=None)

Makes the printed help message look nicer by adding padding before and after the text and by adding the program’s title and version information in the header.

Extends the argparse.ArgumentParser() method.

class mediahandler.util.args.MHTypeAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)

Bases: argparse.Action

Custom media type validation action for argparse.

A child object of argparse.Action().

mediahandler.util.args.get_add_media_args(media, **kwargs)

Takes arguments passed in from the mediahandler.handler.add_media() function, formats them into an array, and sends them to get_parser() for validation.

Returns a dict of validated arguments from the MHParser object.

mediahandler.util.args.get_arguments(deluge=False)

Retrieves CLI arguments from the ‘addmedia’ script and uses get_parser() to validate them.

Returns the full file path to the config file in use and a dict of validated arguments from the MHParser object.

mediahandler.util.args.get_deluge_arguments()

Retrieves CLI arguments from the ‘addmedia-deluge’ script and uses get_deluge_parser() to validate them.

Returns the full file path to the config file in use and a dict of validated arguments from the MHParser object. Also removes the torrent from Deluge, if the user’s settings allow it.

mediahandler.util.args.get_deluge_parser()

Returns the custom MHParser object for mediahandler usage.

Sets up the MHParser object details and adds all of the arguments used by the mediahandler CLI ‘addmedia-deluge’ script.

mediahandler.util.args.get_parser()

Returns the custom MHParser object for mediahandler usage.

Sets up the MHParser object details and adds all of the arguments used by the mediahandler CLI ‘addmedia’ script.