flexget Package

flexget Package

flexget.__init__.main(args=None)

Main entry point for Command Line Interface

api Module

config_schema Module

class flexget.config_schema.RefResolver(*args, **kwargs)

Bases: jsonschema.validators.RefResolver

flexget.config_schema.get_schema()
flexget.config_schema.is_file(instance)
flexget.config_schema.is_interval(interval_string)
flexget.config_schema.is_path(instance)
flexget.config_schema.is_percent(percent_string)
flexget.config_schema.is_quality(instance)
flexget.config_schema.is_quality_req(instance)
flexget.config_schema.is_regex(instance)
flexget.config_schema.is_size(size_string)
flexget.config_schema.is_time(time_string)
flexget.config_schema.is_url(instance)
flexget.config_schema.one_or_more(schema)

Helper function to construct a schema that validates items matching schema or an array containing items matching schema.

flexget.config_schema.parse_interval(interval_string)

Takes an interval string from the config and turns it into a datetime.timedelta object.

flexget.config_schema.parse_percent(percent_input)

Takes a size string from the config and turns it into int(bytes).

flexget.config_schema.parse_size(size_input)

Takes a size string from the config and turns it into int(bytes).

flexget.config_schema.parse_time(time_string)

Parse a time string from the config into a datetime.time object.

flexget.config_schema.process_config(config, schema=None, set_defaults=True)

Validates the config, and sets defaults within it if set_defaults is set. If schema is not given, uses the root config schema.

Returns:A list with :class:`jsonschema.ValidationError`s if any
flexget.config_schema.register_config_key(key, schema, required=False)

Registers a valid root level key for the config.

Parameters:
  • key (string) – Name of the root level key being registered.
  • schema (dict) – Schema for the key.
  • required (bool) – Specify whether this is a mandatory key.
flexget.config_schema.register_schema(path, schema)

Register schema to be available at path for $refs

Parameters:
  • path – Path to make schema available
  • schema – The schema, or function which returns the schema
flexget.config_schema.resolve_ref(uri)

Finds and returns a schema pointed to by uri that has been registered in the register_schema function.

flexget.config_schema.select_child_errors(validator, errors)

Looks through subschema errors, if any subschema is determined to be the intended one, (based on ‘type’ keyword errors,) errors from its branch will be released instead of the parent error.

flexget.config_schema.set_error_message(error)

Create user facing error message from a jsonschema.ValidationError error

flexget.config_schema.validate_anyOf(validator, anyOf, instance, schema)
flexget.config_schema.validate_oneOf(validator, oneOf, instance, schema)
flexget.config_schema.validate_properties_w_defaults(validator, properties, instance, schema)

db_schema Module

class flexget.db_schema.Meta

Bases: type

Metaclass for objects returned by versioned_base factory

class flexget.db_schema.PluginSchema(plugin, version=0)

Bases: sqlalchemy.ext.declarative.api.Base

id
plugin
version
exception flexget.db_schema.UpgradeImpossible

Bases: exceptions.Exception

Exception to be thrown during a db upgrade function which will cause the old tables to be removed and recreated from the new model.

flexget.db_schema.after_table_create(event, target, bind, tables=None, **kw)

Sets the schema version to most recent for a plugin when it’s tables are freshly created.

flexget.db_schema.register_plugin_table(tablename, plugin, version)
flexget.db_schema.upgrade(plugin)

Used as a decorator to register a schema upgrade function.

The wrapped function will be passed the current schema version and a session object. The function should return the new version of the schema after the upgrade.

There is no need to commit the session, it will commit automatically if an upgraded schema version is returned.

Example:

from flexget import schema
@schema.upgrade('your_plugin')
def upgrade(ver, session):
     if ver == 2:
         # upgrade
         ver = 3
     return ver
flexget.db_schema.versioned_base(plugin, version)

Returns a class which can be used like Base, but automatically stores schema version when tables are created.

entry Module

class flexget.entry.Entry(*args, **kwargs)

Bases: flexget.utils.lazy_dict.LazyDict

Represents one item in task. Must have url and title fields.

Stores automatically original_url key, which is necessary because plugins (eg. urlrewriters) may change url into something else and otherwise that information would be lost.

Entry will also transparently convert all ascii strings into unicode and raises EntryUnicodeError if conversion fails on any value being set. Such failures are caught by Task and trigger abort().

accept(reason=None, **kwargs)
accepted
add_hook(action, func, **kwargs)

Add a hook for action to this entry.

Parameters:
  • action (string) – One of: ‘accept’, ‘reject’, ‘fail’, ‘complete’
  • func – Function to execute when event occurs
  • kwargs – Keyword arguments that should be passed to func
Raises:

ValueError when given an invalid action

complete(**kwargs)
fail(reason=None, **kwargs)
failed
isvalid()
Returns:True if entry is valid. Return False if this cannot be used.
Return type:bool
on_accept(func, **kwargs)

Register a function to be called when this entry is accepted.

Parameters:
  • func – The function to call
  • kwargs – Keyword arguments that should be passed to the registered function
on_complete(func, **kwargs)

Register a function to be called when a Task has finished processing this entry.

Parameters:
  • func – The function to call
  • kwargs – Keyword arguments that should be passed to the registered function
on_fail(func, **kwargs)

Register a function to be called when this entry is failed.

Parameters:
  • func – The function to call
  • kwargs – Keyword arguments that should be passed to the registered function
on_reject(func, **kwargs)

Register a function to be called when this entry is rejected.

Parameters:
  • func – The function to call
  • kwargs – Keyword arguments that should be passed to the registered function
reject(reason=None, **kwargs)
rejected
render(template)

Renders a template string based on fields in the entry.

Parameters:template (string) – A template string that uses jinja2 or python string replacement format.
Returns:The result of the rendering.
Return type:string
Raises RenderError:
 If there is a problem.
run_hooks(action, **kwargs)

Run hooks that have been registered for given action.

Parameters:
  • action – Name of action to run hooks for
  • kwargs – Keyword arguments that should be passed to the registered functions
safe_str()
take_snapshot(name)

Takes a snapshot of the entry under name. Snapshots can be accessed via snapshots. :param string name: Snapshot name

trace(message, operation=None, plugin=None)

Adds trace message to the entry which should contain useful information about why plugin did not operate on entry. Accept and Reject messages are added to trace automatically.

Parameters:
  • message (string) – Message to add into entry trace.
  • operation (string) – None, reject, accept or fail
  • plugin – Uses task.current_plugin by default, pass value to override
undecided
update_using_map(field_map, source_item, ignore_none=False)

Populates entry fields from a source object using a dictionary that maps from entry field names to attributes (or keys) in the source object.

Parameters:
  • field_map (dict) – A dictionary mapping entry field names to the attribute in source_item (or keys, if source_item is a dict)(nested attributes/dicts are also supported, separated by a dot,) or a function that takes source_item as an argument
  • source_item – Source of information to be used by the map
  • ignore_none – Ignore any None values, do not record it to the Entry
exception flexget.entry.EntryUnicodeError(key, value)

Bases: exceptions.Exception

This exception is thrown when trying to set non-unicode compatible field value to entry.

event Module

Provides small event framework

class flexget.event.Event(name, func, priority=128)

Bases: object

Represents one registered event.

flexget.event.add_event_handler(name, func, priority=128)
Parameters:
  • name (string) – Event name
  • func (function) – Function that acts as event handler
  • priority – Priority for this hook
Returns:

Event created

Return type:

Event

Raises Exception:
 

If func is already registered in an event

flexget.event.event(name, priority=128)

Register event to function with a decorator

flexget.event.fire_event(name, *args, **kwargs)

Trigger an event with name. If event is not hooked by anything nothing happens. If a function that hooks an event returns a value, it will replace the first argument when calling next function.

Parameters:
  • name – Name of event to be called
  • args – List of arguments passed to handler function
  • kwargs – Key Value arguments passed to handler function
flexget.event.get_events(name)
Parameters:name (String) – event name
Returns:List of Event for name ordered by priority
flexget.event.remove_event_handler(name, func)

Remove func from the handlers for event name.

flexget.event.remove_event_handlers(name)

Removes all handlers for given event name.

ipc Module

class flexget.ipc.ClientService(conn)

Bases: rpyc.core.service.Service

exposed_console(text)
exposed_version()
on_connect()

Make sure the client version matches our own.

class flexget.ipc.DaemonService(conn)

Bases: rpyc.core.service.Service

client_console(text)
client_out_stream
exposed_handle_cli(args)
exposed_version()
manager = None
class flexget.ipc.IPCClient(port, password)

Bases: object

close()
class flexget.ipc.IPCServer(manager, port=None)

Bases: threading.Thread

authenticator(sock)
run()
shutdown()
class flexget.ipc.RemoteStream(writer)

Bases: object

Used as a filelike to stream text to remote client. If client disconnects while this is in use, an error will be logged, but no exception raised.

write(data)

logger Module

class flexget.logger.FlexGetFormatter

Bases: logging.Formatter

Custom formatter that can handle both regular log records and those created by FlexGetLogger

flexget_fmt = u'%(asctime)-15s %(levelname)-8s %(name)-13s %(task)-15s %(message)s'
format(record)
class flexget.logger.FlexGetJsonFormatter

Bases: logging.Formatter

fields = [u'asctime', u'levelname', u'name', u'task', u'task_id', u'message']
format(record)
class flexget.logger.FlexGetLogger(name, level=0)

Bases: logging.Logger

Custom logger that adds trace and verbose logging methods, and contextual information to log records.

makeRecord(name, level, fn, lno, msg, args, exc_info, func=None, extra=None)
trace(msg, *args, **kwargs)

Log at TRACE level (more detailed than DEBUG).

verbose(msg, *args, **kwargs)

Log at VERBOSE level (displayed when FlexGet is run interactively.)

class flexget.logger.RollingBuffer

Bases: collections.deque

File-like that keeps a certain number of lines of text in memory.

write(line)
class flexget.logger.SessionFilter(session_id)

Bases: logging.Filter

filter(record)
flexget.logger.capture_output(*args, **kwds)

Context manager which captures all log and console output to given stream while in scope.

flexget.logger.console(text)

Print to console safely. Output is able to be captured by different streams in different contexts.

Any plugin wishing to output to the user’s console should use this function instead of print so that output can be redirected when FlexGet is invoked from another process.

flexget.logger.get_capture_loglevel()

If output is currently being redirected to a stream, returns declared loglevel for that stream.

flexget.logger.get_capture_stream()

If output is currently being redirected to a stream, returns that stream.

flexget.logger.get_level_no(level)
flexget.logger.initialize(unit_test=False)

Prepare logging.

flexget.logger.start(filename=None, filename_json=None, level=20, to_console=True, to_file=True)

After initialization, start file logging.

flexget.logger.task_logging(*args, **kwds)

Context manager which adds task information to log messages.

manager Module

class flexget.manager.Manager(args)

Bases: object

Manager class for FlexGet

Fires events:

  • manager.initialize

    The first time the manager is initialized, before config is loaded

  • manager.before_config_load

    Before the config file is loaded from disk

  • manager.before_config_validate

    When updating the config, before the validator is run on it

  • manager.config_updated

    After a configuration file has been loaded or changed (and validated) this event is fired

  • manager.startup

    After manager has been initialized. This is when application becomes ready to use, however no database lock is present, so the database must not be modified on this event.

  • manager.lock_acquired

    The manager does not always require a lock on startup, if one is requested, this event will run when it has been acquired successfully

  • manager.upgrade

    If any plugins have declared a newer schema version than exists in the database, this event will be fired to allow plugins to upgrade their tables

  • manager.shutdown_requested

    When shutdown has been requested. Any plugins which might add to execution queue should stop when this is fired.

  • manager.shutdown

    When the manager is exiting

  • manager.execute.completed

    If execution in current process was completed

  • manager.daemon.started

  • manager.daemon.completed

  • manager.db_cleanup

acquire_lock(*args, **kwds)
Parameters:event (bool) – If True, the ‘manager.lock_acquired’ event will be fired after a lock is obtained
check_ipc_info()

If a daemon has a lock on the database, return info to connect to IPC.

check_lock()

Returns True if there is a lock on the database.

config_changed()

Makes sure that all tasks will have the config_modified flag come out true on the next run. Useful when changing the db and all tasks need to be completely reprocessed.

crash_report()

This should be called when handling an unexpected exception. Will create a new log file containing the last 50 debug messages as well as the crash traceback.

daemon_command(options)

Handles the ‘daemon’ CLI command.

Fires events:

  • manager.daemon.started
  • manager.daemon.completed
Parameters:options – argparse options
daemonize()

Daemonizes the current process. Returns the new pid

db_cleanup(force=False)

Perform database cleanup if cleanup interval has been met.

Fires events:

  • manager.db_cleanup

    If interval was met. Gives session to do the cleanup as a parameter.

Parameters:force (bool) – Run the cleanup no matter whether the interval has been met.
execute(options=None, output=None, loglevel=None, priority=1)

Run all (can be limited with options) tasks from the config.

Parameters:
  • options – Either an argparse.Namespace instance, or a dict, containing options for execution
  • output – If a file-like object is specified here, log messages and stdout from the execution will be written to it.
  • priority – If there are other executions waiting to be run, they will be run in priority order, lowest first.
Returns:

a list of threading.Event instances which will be set when each respective task has finished running

execute_command(options)

Handles the ‘execute’ CLI command.

If there is already a task queue running in this process, adds the execution to the queue. If FlexGet is being invoked with this command, starts up a task queue and runs the execution.

Fires events:

  • manager.execute.started
  • manager.execute.completed
Parameters:options – argparse options
find_config(create=False)

Find the configuration file.

Parameters:create (bool) – If a config file is not found, and create is True, one will be created in the home folder
Raises:IOError when no config file could be found, and create is False.
handle_cli(options=None)

Dispatch a cli command to the appropriate function.

The manager should have a lock and be initialized before calling this method.

Parameters:options – argparse options for command. Defaults to options that manager was instantiated with.
has_lock
init_sqlalchemy()

Initialize SQLAlchemy

initialize()

Load plugins, database, and config. Also initializes (but does not start) the task queue and ipc server. This should only be called after obtaining a lock.

load_config()

Loads the config file from disk, validates and activates it.

Raises:ValueError if there is a problem loading the config file
options = None
release_lock()
save_config()

Dumps current config to yaml config file

setup_yaml()

Sets up the yaml loader to return unicode objects for strings by default

shutdown(finish_queue=True)

Request manager shutdown.

Parameters:finish_queue (bool) – Should scheduler finish the task queue
start()

Starting point when executing from commandline, dispatch execution to correct destination.

If there is a FlexGet process with an ipc server already running, the command will be sent there for execution and results will be streamed back. If not, this will attempt to obtain a lock, initialize the manager, and run the command here.

tasks

A list of tasks in the config

unit_test = False
update_config(config)

Provide a new config for the manager to use.

Raises:ValueError and rolls back to previous config if the provided config is not valid.
validate_config(config=None)

Check all root level keywords are valid. Config may be modified by before_config_validate hooks. Modified config will be returned.

Parameters:config – Config to check. If not provided, current manager config will be checked.
Raises:ValueError when config fails validation. There will be an errors attribute with the schema errors.
Returns:Final validated config.
write_lock(ipc_info=None)

options Module

class flexget.options.ArgumentParser(**kwargs)

Bases: argparse.ArgumentParser

Mimics the default argparse.ArgumentParser class, with a few distinctions, mostly to ease subparser usage:

  • If add_subparsers is called with the nested_namespaces kwarg, all subcommand options will be stored in a nested namespace based on the command name for the subparser
  • Adds the add_subparser method. After add_subparsers has been called, the add_subparser method can be used instead of the add_parser method of the object returned by the add_subparsers call.
  • add_subparser takes takes the parent_defaults argument, which will set/change the defaults for the parent parser when that subparser is selected.
  • The get_subparser method will get the ArgumentParser instance for an existing subparser on this parser
  • For any arguments defined both in this parser and one of its subparsers, the selected subparser default will override the main one.
  • Adds the set_post_defaults method. This works like the normal argparse set_defaults method, but all actions and subparsers will be run before any of these defaults are set.
  • Command shortening: If the command for a subparser is abbreviated unambiguously, it will still be accepted.
  • The add_argument nargs keyword argument supports a range of arguments, e.g. `“2-4”
  • If the raise_errors keyword argument to parse_args is True, a ParserError will be raised instead of sys.exit
  • If the file argument is given to parse_args, output will be printed there instead of sys.stdout or stderr
add_argument(*args, **kwargs)
add_subparser(name, **kwargs)

Adds a parser for a new subcommand and returns it.

Parameters:
  • name – Name of the subcommand
  • parent_defaults – Default argument values which should be supplied to the parent parser if this subparser is selected.
add_subparsers(**kwargs)
Parameters:nested_namespaces – If True, options from subparsers will appear in nested namespace under the subparser name.
error(msg)
file = None
get_subparser(name, default=<object object>)
parse_args(args=None, namespace=None, raise_errors=False, file=None)
Parameters:raise_errors – If this is true, errors will be raised as `ParserError`s instead of calling sys.exit
parse_known_args(args=None, namespace=None)
set_post_defaults(**kwargs)

Like set_defaults method, but these defaults will be defined after parsing instead of before.

class flexget.options.CoreArgumentParser(**kwargs)

Bases: flexget.options.ArgumentParser

The core argument parser, contains the manager arguments, command parsers, and plugin arguments.

Warning: Only gets plugin arguments if instantiated after plugins have been loaded.

add_subparsers(**kwargs)
parse_args(*args, **kwargs)
class flexget.options.CronAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)

Bases: argparse.Action

class flexget.options.DebugAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)

Bases: argparse.Action

class flexget.options.DebugTraceAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)

Bases: argparse.Action

class flexget.options.InjectAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)

Bases: argparse.Action

class flexget.options.NestedSubparserAction(*args, **kwargs)

Bases: argparse._SubParsersAction

add_parser(name, parent_defaults=None, **kwargs)
class flexget.options.ParseExtrasAction(option_strings, parser, help=None, metavar=None, dest=None, required=False)

Bases: argparse.Action

This action will take extra arguments, and parser them with a different parser.

exception flexget.options.ParserError(message, parser)

Bases: exceptions.Exception

class flexget.options.ScopedNamespace(**kwargs)

Bases: argparse.Namespace

class flexget.options.VersionAction(option_strings, version=None, dest='==SUPPRESS==', default='==SUPPRESS==', help="show program's version number and exit")

Bases: argparse._VersionAction

Action to print the current version. Also checks latest release revision.

flexget.options.get_parser(command=None)
flexget.options.register_command(command, callback, **kwargs)

Register a callback function to be executed when flexget is launched with the given command.

Parameters:
  • command – The command being defined.
  • callback – Callback function executed when this command is invoked from the CLI. Should take manager instance and parsed argparse namespace as parameters.
  • kwargs – Other keyword arguments will be passed to the arparse.ArgumentParser constructor
Returns:

An argparse.ArgumentParser instance ready to be configured with the options for this command.

flexget.options.required_length(nmin, nmax)

Generates a custom Action to validate an arbitrary range of arguments.

flexget.options.unicode_argv()

Like sys.argv, but decodes all arguments.

plugin Module

Plugin Loading & Management.

exception flexget.plugin.PluginWarning(value, logger=<flexget.logger.FlexGetLogger object>, **kwargs)

Bases: exceptions.Warning

exception flexget.plugin.PluginError(value, logger=<flexget.logger.FlexGetLogger object>, **kwargs)

Bases: exceptions.Exception

flexget.plugin.register_task_phase(name, before=None, after=None)

Adds a new task phase to the available phases.

flexget.plugin.get_plugin_by_name(name, issued_by=u'???')

Get plugin by name, preferred way since this structure may be changed at some point.

flexget.plugin.get_plugins_by_group(group)

Deprecated since version 1.0.3328: Use get_plugins() instead

Return an iterator over all plugins with in specified group.

flexget.plugin.get_plugin_keywords()

Return iterator over all plugin keywords.

flexget.plugin.get_plugins_by_phase(phase)

Deprecated since version 1.0.3328: Use get_plugins() instead

Return an iterator over all plugins that hook :phase:

flexget.plugin.get_phases_by_plugin(name)

Return all phases plugin :name: hooks

class flexget.plugin.internet(logger=None)

Bases: object

@internet decorator for plugin phase methods.

Catches all internet related exceptions and raises PluginError with relevant message. Task handles PluginErrors by aborting the task.

flexget.plugin.priority(value)

Priority decorator for phase methods

task Module

class flexget.task.EntryContainer(iterable=None)

Bases: list

Container for a list of entries, also contains accepted, rejected failed iterators over them.

accepted
entries
failed
rejected
undecided
class flexget.task.EntryIterator(entries, states)

Bases: object

An iterator over a subset of entries to emulate old task.accepted/rejected/failed/entries properties.

reverse()
sort(*args, **kwargs)
class flexget.task.Task(manager, name, config=None, options=None, output=None, loglevel=None, priority=None)

Bases: object

Represents one task in the configuration.

Fires events:

  • task.execute.before_plugin

    Before a plugin is about to be executed. Note that since this will also include all builtin plugins the amount of calls can be quite high

    parameters: task, keyword

  • task.execute.after_plugin

    After a plugin has been executed.

    parameters: task, keyword

  • task.execute.started

    Before a task starts execution

  • task.execute.completed

    After task execution has been completed

    parameters: task

abort(reason=u'Unknown', silent=False)

Abort this task execution, no more plugins will be executed except the abort handling ones.

accepted

Deprecated since version Use: API v3

all_entries

Deprecated since version Use: API v3

config_changed()

Sets config_modified flag to True for the remainder of this run. Used when the db changes, and all entries need to be reprocessed.

copy()
disable_phase(phase)

Disable phase from execution.

All disabled phases are re-enabled by Task._reset() after task execution has been completed.

Parameters:phase (string) – Name of phase
Raises ValueError:
 phase could not be found.
entries

Deprecated since version Use: API v3

execute(*args, **kw)

Executes the the task.

If enabled is False task is not executed. Certain options affect how execution is handled.

  • options.disable_phases is a list of phases that are not enabled for this execution.
  • options.inject is a list of Entry instances used instead of running input phase.
failed

Deprecated since version Use: API v3

find_entry(category=u'entries', **values)

Find and return Entry with given attributes from task or None

Parameters:
  • category (string) – entries, accepted, rejected or failed. Defaults to entries.
  • values – Key values of entries to be searched
Returns:

Entry or None

is_rerun
max_reruns = 5
plugins(phase=None)

Get currently enabled plugins.

Parameters:phase (string) – Optional, limits to plugins currently configured on given phase, sorted in phase order.
Returns:An iterator over configured flexget.plugin.PluginInfo instances enabled on this task.
rejected

Deprecated since version Use: API v3

rerun()

Immediately re-run the task after execute has completed, task can be re-run up to max_reruns times.

undecided

Deprecated since version Use: API v3

static validate_config(config)
exception flexget.task.TaskAbort(reason, silent=False)

Bases: exceptions.Exception

class flexget.task.TaskConfigHash(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Base

Stores the config hash for tasks so that we can tell if the config has changed since last run.

hash
id
task
flexget.task.register_config_key()
flexget.task.use_task_logging(func)

task_queue Module

class flexget.task_queue.TaskInfo(task)

Bases: object

aborted(reason)
finish(entries)
running
start()
class flexget.task_queue.TaskQueue

Bases: object

Task processing thread. Only executes one task at a time, if more are requested they are queued up and run in turn.

is_alive()
put(task)

Adds a task to be executed to the queue.

run()
shutdown(finish_queue=True)

Request shutdown.

Parameters:finish_queue (bool) – Should all tasks be finished before ending thread.
start()
wait()

Waits for the thread to exit. Allows abortion of task queue with ctrl-c

webserver Module

flexget.webserver.register_app(path, application)
flexget.webserver.register_config()
flexget.webserver.register_home(route)

Registers UI home page

flexget.webserver.setup_server(manager)

Sets up and starts/restarts the web service.

flexget.webserver.start_page()

Redirect user to registered UI home

flexget.webserver.stop_server(manager)

Sets up and starts/restarts the webui.

validator Module

Deprecated since version 1.1: Use config_schema instead

class flexget.validator.AnyValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.Validator

accept(value, **kwargs)
name = u'any'
class flexget.validator.BooleanValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.Validator

accept(name, **kwargs)
name = u'boolean'
class flexget.validator.ChoiceValidator(parent=None, **kwargs)

Bases: flexget.validator.Validator

accept(value, ignore_case=False)
Parameters:
  • value – accepted text, int or boolean
  • ignore_case (bool) – Whether case matters for text values
accept_choices(values, **kwargs)

Same as accept but with multiple values (list)

name = u'choice'
class flexget.validator.DecimalValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.Validator

accept(name, **kwargs)
name = u'decimal'
class flexget.validator.DictValidator(parent=None, **kwargs)

Bases: flexget.validator.Validator

accept(value, key=None, required=False, **kwargs)
Parameters:
  • value – validator name, instance or function that returns an instance, which validates the given key
  • key (string) – The dictionary key to accept
  • required (bool) – = Mark this key as required
Raises ValueError:
 

key was not specified

accept_any_key(value, **kwargs)

Accepts any leftover keys in dictionary, which will be validated with value

accept_valid_keys(value, key_type=None, key_validator=None, **kwargs)

Accepts keys that pass a given validator, and validates them using validator specified in value

Parameters:
  • value – Validator name, instance or function returning an instance that will be used to validate dict values.
  • key_type – Name of validator or list of names that determine which keys in this dict value will govern
  • key_validator (Validator) – A validator instance that will be used to determine which keys in the dict value will govern
Raises ValueError:
 

If both key_type and key_validator are specified.

name = u'dict'
reject_key(key, message=None)

Rejects a key

reject_keys(keys, message=None)

Reject list of keys

require_key(key)

Flag key as mandatory

class flexget.validator.EqualsValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.Validator

accept(value, **kwargs)
name = u'equals'
class flexget.validator.Errors

Bases: object

Create and hold validator error messages.

add(msg)

Add new error message to current path.

back_out_errors(num=1)

Remove last num errors from list

count()

Return number of errors.

path_add_level(value=u'?')

Adds level into error message path

path_remove_level()

Removes level from path by depth number

path_update_value(value)

Updates path level value

class flexget.validator.FileValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.TextValidator

name = u'file'
validate(data)
class flexget.validator.IntegerValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.Validator

accept(name, **kwargs)
name = u'integer'
class flexget.validator.IntervalValidator(parent=None, **kwargs)

Bases: flexget.validator.RegexpMatchValidator

name = u'interval'
class flexget.validator.ListValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.Validator

accept(value, **kwargs)
name = u'list'
class flexget.validator.NumberValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.Validator

accept(name, **kwargs)
name = u'number'
class flexget.validator.PathValidator(parent=None, allow_replacement=False, allow_missing=False, **kwargs)

Bases: flexget.validator.TextValidator

name = u'path'
class flexget.validator.QualityRequirementsValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.TextValidator

name = u'quality_requirements'
class flexget.validator.QualityValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.TextValidator

name = u'quality'
class flexget.validator.RegexpMatchValidator(parent=None, **kwargs)

Bases: flexget.validator.Validator

accept(regexp, **kwargs)
add_regexp(regexp_list, regexp)
name = u'regexp_match'
reject(regexp)
class flexget.validator.RegexpValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.Validator

accept(name, **kwargs)
name = u'regexp'
class flexget.validator.RootValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.Validator

accept(value, **kwargs)
name = u'root'
class flexget.validator.TextValidator(parent=None, message=None, **kwargs)

Bases: flexget.validator.Validator

accept(name, **kwargs)
name = u'text'
class flexget.validator.UrlValidator(parent=None, protocols=None, **kwargs)

Bases: flexget.validator.TextValidator

name = u'url'
class flexget.validator.Validator(parent=None, message=None, **kwargs)

Bases: object

accept(value, **kwargs)
add_parent(parent)
add_root_parent()
errors

Recursively return the Errors class from the root of the validator tree.

get_validator(value, **kwargs)

Returns a child validator of this one.

Parameters:
  • value – Can be a validator type string, an already created Validator instance, or a function that returns a validator instance.
  • kwargs – Keyword arguments are passed on to validator init if a new validator is created.
name = u'validator'
schema()
validate(value)

This is just to unit test backwards compatibility of json schema with old validators

flexget.validator.any_schema(schemas)

Creates a schema that will match any of the given schemas. Will not use anyOf if there is just one validator in the list, for simpler error messages.

flexget.validator.build_options_validator(options)
flexget.validator.complex_test()
flexget.validator.factory(name=u'root', **kwargs)

Factory method, returns validator instance.