def get_all_accessors(name_factory): for name, validator in validation.get_validators(): yield name_factory.get_name(name), validator yield (name_factory.get_list_of_name(name), validation.build_list_type_validator(validator))
def build_attr(name, attribute): if not isinstance(attribute, ValueTypeDefinition): return name, attribute return build_token(name, attribute) attributes = dict(build_attr(*item) for item in attributes.iteritems()) attributes['_tokens'] = tokens return attributes class Schema(object): __metaclass__ = SchemaMeta namespace = None def build_value_type(validator): return functools.partial(ValueTypeDefinition, validator) # Backwards compatible with staticconf 0.5.2 create_value_type = build_value_type for name, validator in validation.get_validators(): name = name or 'any' globals()[name] = build_value_type(validator) list_of_validator = validation.build_list_type_validator(validator) globals()['list_of_%s' % name] = build_value_type(list_of_validator)
def get_all_accessors(name_factory): for name, validator in validation.get_validators(): yield name_factory.get_name(name), validator yield (name_factory.get_list_of_name(name), validation.build_list_type_validator(validator))
attributes = dict( build_attr(*item) for item in six.iteritems(attributes)) attributes['_tokens'] = tokens return attributes @six.add_metaclass(SchemaMeta) class Schema(object): """Base class for configuration schemas, uses :class:`SchemaMeta`.""" namespace = None def build_value_type(validator): """A factory function to create a new schema type. :param validator: a function which accepts one argument and returns that value as the correct type. """ return functools.partial(ValueTypeDefinition, validator) # Backwards compatible with staticconf 0.5.2 create_value_type = build_value_type for name, validator in validation.get_validators(): name = name or 'any' globals()[name] = build_value_type(validator) list_of_validator = validation.build_list_type_validator(validator) globals()['list_of_%s' % name] = build_value_type(list_of_validator)