return update def _check_type(validator, types, instance, schema): """ Callback to check data type. Skips over null values. """ if instance is None: errors = [] else: errors = asdf_schema.validate_type(validator, types, instance, schema) return errors validator_callbacks = HashableDict(asdf_schema.YAML_VALIDATORS) validator_callbacks.update({'type': _check_type}) validator_context = AsdfFile() validator_resolver = validator_context.resolver def _check_value(value, schema): """ Perform the actual validation. """ if value is None: if schema.get('fits_required'): name = schema.get("fits_keyword") or schema.get("fits_hdu") raise jsonschema.ValidationError("%s is a required value" % name)
item, subschema, path=index, schema_path=index, ): yield error def _fits_type(validator, items, instance, schema): if instance in ('N/A', '#TODO', '', None): return return validators._validators.type_draft4(validator, items, instance, schema) FITS_VALIDATORS = HashableDict(asdf_schema.YAML_VALIDATORS) FITS_VALIDATORS.update({ 'fits_keyword': _fits_element_writer, 'ndim': _fits_array_writer, 'max_ndim': _fits_array_writer, 'datatype': _fits_array_writer, 'items': _fits_item_recurse, 'properties': _fits_comment_section_handler, 'type': _fits_type }) META_SCHEMA_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), 'metaschema')) FITS_SCHEMA_URL_MAPPING = resolver.Resolver(
else: # We don't do the index trick on "tuple validated" sequences for (index, item), subschema in zip(enumerate(instance), items): for error in validator.descend( item, subschema, path=index, schema_path=index, ): yield error def _fits_type(validator, items, instance, schema): if instance in ('N/A', '#TODO', '', None): return return validators._validators.type_draft4(validator, items, instance, schema) FITS_VALIDATORS = HashableDict(asdf_schema.YAML_VALIDATORS) FITS_VALIDATORS.update({ 'fits_keyword': _fits_element_writer, 'ndim': _fits_array_writer, 'max_ndim': _fits_array_writer, 'datatype': _fits_array_writer, 'items': _fits_item_recurse, 'properties': _fits_comment_section_handler, 'type': _fits_type }) META_SCHEMA_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), 'metaschema'))
return update def _check_type(validator, types, instance, schema): """ Callback to check data type. Skips over null values. """ if instance is None: errors = [] else: errors = asdf_schema.validate_type(validator, types, instance, schema) return errors validator_callbacks = HashableDict(asdf_schema.YAML_VALIDATORS) validator_callbacks.update({'type': _check_type}) def _check_value(value, schema): """ Perform the actual validation. """ if value is None: if schema.get('fits_required'): name = schema.get("fits_keyword") or schema.get("fits_hdu") raise jsonschema.ValidationError("%s is a required value" % name) else: validator_context = AsdfFile() validator_resolver = validator_context.resolver