diff options
author | kali <kali@leap.se> | 2013-01-31 09:10:08 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2013-01-31 09:10:08 +0900 |
commit | 16eb335f34628455ff273f650c48b1e1a73bde20 (patch) | |
tree | 9000da9f810264ede4b189ef34c065cad31cb223 | |
parent | fff2c771cc9c93cf566f586c3c033fed7266ea27 (diff) |
pep8
-rw-r--r-- | src/leap/base/jsonschema.py | 141 |
1 files changed, 70 insertions, 71 deletions
diff --git a/src/leap/base/jsonschema.py b/src/leap/base/jsonschema.py index 0732f0a2..56689b08 100644 --- a/src/leap/base/jsonschema.py +++ b/src/leap/base/jsonschema.py @@ -124,8 +124,8 @@ class Draft3Validator(object): """ DEFAULT_TYPES = { - "array" : list, "boolean" : bool, "integer" : int, "null" : type(None), - "number" : (int, float), "object" : dict, "string" : basestring, + "array": list, "boolean": bool, "integer": int, "null": type(None), + "number": (int, float), "object": dict, "string": basestring, } def __init__(self, schema, types=(), resolver=None): @@ -365,7 +365,7 @@ class Draft3Validator(object): def validate_disallow(self, disallow, instance, schema): for disallowed in _list(disallow): - if self.is_valid(instance, {"type" : [disallowed]}): + if self.is_valid(instance, {"type": [disallowed]}): yield ValidationError( "%r is disallowed for %r" % (disallowed, instance) ) @@ -384,85 +384,85 @@ class Draft3Validator(object): Draft3Validator.META_SCHEMA = { - "$schema" : "http://json-schema.org/draft-03/schema#", - "id" : "http://json-schema.org/draft-03/schema#", - "type" : "object", - - "properties" : { - "type" : { - "type" : ["string", "array"], - "items" : {"type" : ["string", {"$ref" : "#"}]}, - "uniqueItems" : True, - "default" : "any" + "$schema": "http://json-schema.org/draft-03/schema#", + "id": "http://json-schema.org/draft-03/schema#", + "type": "object", + + "properties": { + "type": { + "type": ["string", "array"], + "items": {"type": ["string", {"$ref": "#"}]}, + "uniqueItems": True, + "default": "any" }, - "properties" : { - "type" : "object", - "additionalProperties" : {"$ref" : "#", "type": "object"}, - "default" : {} + "properties": { + "type": "object", + "additionalProperties": {"$ref": "#", "type": "object"}, + "default": {} }, - "patternProperties" : { - "type" : "object", - "additionalProperties" : {"$ref" : "#"}, - "default" : {} + "patternProperties": { + "type": "object", + "additionalProperties": {"$ref": "#"}, + "default": {} }, - "additionalProperties" : { - "type" : [{"$ref" : "#"}, "boolean"], "default" : {} + "additionalProperties": { + "type": [{"$ref": "#"}, "boolean"], "default": {} }, - "items" : { - "type" : [{"$ref" : "#"}, "array"], - "items" : {"$ref" : "#"}, - "default" : {} + "items": { + "type": [{"$ref": "#"}, "array"], + "items": {"$ref": "#"}, + "default": {} }, - "additionalItems" : { - "type" : [{"$ref" : "#"}, "boolean"], "default" : {} + "additionalItems": { + "type": [{"$ref": "#"}, "boolean"], "default": {} }, - "required" : {"type" : "boolean", "default" : False}, - "dependencies" : { - "type" : ["string", "array", "object"], - "additionalProperties" : { - "type" : ["string", "array", {"$ref" : "#"}], - "items" : {"type" : "string"} + "required": {"type": "boolean", "default": False}, + "dependencies": { + "type": ["string", "array", "object"], + "additionalProperties": { + "type": ["string", "array", {"$ref": "#"}], + "items": {"type": "string"} }, - "default" : {} + "default": {} }, - "minimum" : {"type" : "number"}, - "maximum" : {"type" : "number"}, - "exclusiveMinimum" : {"type" : "boolean", "default" : False}, - "exclusiveMaximum" : {"type" : "boolean", "default" : False}, - "minItems" : {"type" : "integer", "minimum" : 0, "default" : 0}, - "maxItems" : {"type" : "integer", "minimum" : 0}, - "uniqueItems" : {"type" : "boolean", "default" : False}, - "pattern" : {"type" : "string", "format" : "regex"}, - "minLength" : {"type" : "integer", "minimum" : 0, "default" : 0}, - "maxLength" : {"type" : "integer"}, - "enum" : {"type" : "array", "minItems" : 1, "uniqueItems" : True}, - "default" : {"type" : "any"}, - "title" : {"type" : "string"}, - "description" : {"type" : "string"}, - "format" : {"type" : "string"}, - "maxDecimal" : {"type" : "number", "minimum" : 0}, - "divisibleBy" : { - "type" : "number", - "minimum" : 0, - "exclusiveMinimum" : True, - "default" : 1 + "minimum": {"type": "number"}, + "maximum": {"type": "number"}, + "exclusiveMinimum": {"type": "boolean", "default": False}, + "exclusiveMaximum": {"type": "boolean", "default": False}, + "minItems": {"type": "integer", "minimum": 0, "default": 0}, + "maxItems": {"type": "integer", "minimum": 0}, + "uniqueItems": {"type": "boolean", "default": False}, + "pattern": {"type": "string", "format": "regex"}, + "minLength": {"type": "integer", "minimum": 0, "default": 0}, + "maxLength": {"type": "integer"}, + "enum": {"type": "array", "minItems": 1, "uniqueItems": True}, + "default": {"type": "any"}, + "title": {"type": "string"}, + "description": {"type": "string"}, + "format": {"type": "string"}, + "maxDecimal": {"type": "number", "minimum": 0}, + "divisibleBy": { + "type": "number", + "minimum": 0, + "exclusiveMinimum": True, + "default": 1 }, - "disallow" : { - "type" : ["string", "array"], - "items" : {"type" : ["string", {"$ref" : "#"}]}, - "uniqueItems" : True + "disallow": { + "type": ["string", "array"], + "items": {"type": ["string", {"$ref": "#"}]}, + "uniqueItems": True }, - "extends" : { - "type" : [{"$ref" : "#"}, "array"], - "items" : {"$ref" : "#"}, - "default" : {} + "extends": { + "type": [{"$ref": "#"}, "array"], + "items": {"$ref": "#"}, + "default": {} }, - "id" : {"type" : "string", "format" : "uri"}, - "$ref" : {"type" : "string", "format" : "uri"}, - "$schema" : {"type" : "string", "format" : "uri"}, + "id": {"type": "string", "format": "uri"}, + "$ref": {"type": "string", "format": "uri"}, + "$schema": {"type": "string", "format": "uri"}, }, - "dependencies" : { - "exclusiveMinimum" : "minimum", "exclusiveMaximum" : "maximum" + "dependencies": { + "exclusiveMinimum": "minimum", "exclusiveMaximum": "maximum" }, } @@ -787,6 +787,5 @@ def validate(instance, schema, cls=Draft3Validator, *args, **kwargs): """ - cls.check_schema(schema) cls(schema, *args, **kwargs).validate(instance) |