Skip to content

Commit

Permalink
Re-implement /schema/plugins refs
Browse files Browse the repository at this point in the history
  • Loading branch information
gazpachoking committed Mar 1, 2013
1 parent af68b51 commit 1d764c1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
11 changes: 10 additions & 1 deletion flexget/config_schema.py
Expand Up @@ -11,13 +11,22 @@


def register_schema(path, schema):
"""
Register `schema` to be available at `path` for $refs
:param path: Path to make schema available
:param schema: The schema, or function which returns the schema
"""
schema_paths[path] = schema


def resolve_local(uri):
parsed = urlparse.urlparse(uri)
if parsed.path in schema_paths:
return schema_paths[parsed.path]
schema = schema_paths[parsed.path]
if callable(schema):
return schema(**dict(urlparse.parse_qsl(parsed.query)))
return schema
raise jsonschema.RefResolutionError("%s could not be resolved" % uri)


Expand Down
3 changes: 3 additions & 0 deletions flexget/plugin.py
Expand Up @@ -483,6 +483,9 @@ def plugin_schemas(**kwargs):
'additionalProperties': False}


config_schema.register_schema('/schema/plugins', plugin_schemas)


def get_plugins_by_phase(phase):
"""
.. deprecated:: 1.0.3328
Expand Down
4 changes: 2 additions & 2 deletions flexget/plugins/input/discover.py
Expand Up @@ -24,8 +24,8 @@ class Discover(object):
schema = {
'type': 'object',
'properties': {
'what': {'type': 'array', 'items': plugin_schemas(phase='input')},
'from': {'type': 'array', 'items': plugin_schemas(group='search')},
'what': {'type': 'array', 'items': {'$ref': '/schema/plugins?phase=input'}},
'from': {'type': 'array', 'items': {'$ref': '/schema/plugins?group=search'}},
'type': {'type': 'string', 'enum': ['any', 'normal', 'exact', 'movies']},
},
'additionalProperties': False
Expand Down
2 changes: 1 addition & 1 deletion flexget/plugins/input/inputs.py
Expand Up @@ -18,7 +18,7 @@ class PluginInputs(object):

schema = {
'type': 'array',
'items': plugin_schemas(phase='input')
'items': {'$ref': '/schema/plugins?phase=input'}
}

def on_task_input(self, task, config):
Expand Down

0 comments on commit 1d764c1

Please sign in to comment.