def get_default_gmd_vector_spatial_schema(): return { 'topology_level': [im, _sub('gmd_code_string')], 'geometric_objects': get_default_gmd_geo_object_schema(), '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_spatial_schema(): return { 'vector': [im, _sub('gmd_vector_spatial')], 'grid': [im, _sub('gmd_grid_spatial')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_vertical_element_schema(): return { 'minimum_value': [ne, get_validator('spc_float_validator')], 'maximum_value': [ne, get_validator('spc_float_validator')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_dqt_scope_schema(): return { 'level': [ne, _sub('gmd_code_string')], 'extent': [im, _sub('gmd_extent')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_code_string_schema(): return { 'code_list': [ne], 'code_list_value': [ne], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_identifier_schema(): return { 'authority': [im, _sub('gmd_citation')], 'code': [ne, str], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_taxonomic_coverage_schema(): return { 'general_taxonomic_coverage': [get_validator('ignore_empty'), unicode], 'taxonomic_classification': get_default_taxonomic_class_schema(), '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_range_dimension_schema(): return { 'sequence_identifier': [im, str], 'descriptor': [im, str], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_geo_object_schema(): return { 'geometric_object_type': [ne, _sub('gmd_code_string')], 'geometric_object_count': [im, get_validator('int_validator')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_geo_dimension_schema(): return { 'dimension_name': [ne, _sub('gmd_code_string')], 'dimension_size': [ne, get_validator('int_validator')], 'resolution': [im, get_validator('spc_float_validator')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_locale_schema(): return { 'language_code': [ne, _sub('gmd_code_string')], 'country': [im, _sub('gmd_code_string')], 'character_encoding': [ne, _sub('gmd_code_string')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_series_schema(): return { 'name': [im, str], 'issue_identification': [im, str], 'page': [im, str], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_graphic_schema(): return { 'file_name': [ne, str], 'file_description': [im, str], 'file_type': [im, str], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_distributor_schema(): return { 'distributor_contact': [ne, _sub('gmd_cited_responsible_party')], 'distribution_order_process': get_default_gmd_order_process_schema(), 'distributor_transfer_options': get_default_gmd_transfer_schema(), '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_coverage_description_schema(): return { 'attribute_description': [ne, str], 'content_type': [ne, _sub('gmd_code_string')], 'dimension': get_default_gmd_range_dimension_schema(), '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_lineage_schema(): return { 'statement': [im, str], 'process_step': get_default_gmd_lineage_process_step_schema(), 'source': get_default_gmd_lineage_source_schema(), '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_taxonomic_class_schema(): return { 'taxon_rank_name': [get_validator('ignore_empty'), unicode_safe], 'taxon_rank_value': [get_validator('not_empty'), unicode_safe], 'common_name': [get_validator('ignore_empty'), unicode_safe], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_geo_element_schema(): return { 'extent_type_code': [im, get_validator('boolean_validator')], 'bounding_box': [im, _sub('gmd_bounding_box')], 'geographic_identifier': [im, _sub('gmd_identifier')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_extent_schema(): return { 'description': [im, str], 'geographic_element': [im, _sub('gmd_geo_element')], 'vertical_element': [im, _sub('gmd_vertical_element')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_data_quality_schema(): return { 'scope': [ne, _sub('gmd_dqt_scope')], 'report': get_default_gmd_dqt_report_schema(), 'lineage': [im, _sub('gmd_lineage')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_transfer_schema(): return { 'units_of_distribution': [im, str], 'transfer_size': [im, get_validator('spc_float_validator')], 'on_line': get_default_gmd_online_resource_schema(), 'off_line': [im, _sub('gmd_offline_resource')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_aggregation_schema(): return { 'aggregate_data_set_name': [im, _sub('gmd_citation')], 'aggregate_data_set_identifier': [im, _sub('gmd_identifier')], 'association_type': [ne, _sub('gmd_code_string')], 'initiative_type': [im, _sub('gmd_code_string')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_metadata_extension_schema(): return { 'extension_on_line_resource': [im, _sub('gmd_online_resource')], 'extended_element_information': [ get_validator('spc_list_of')(_sub('gmd_extended_element')), im ], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def recalculate_next_update_due_date(flattened_data, update_frequency, errors, context): days = get_update_frequencies().get(update_frequency, 0) # Recalculate the next_update_due always against today's date today = dt.datetime.now(h.get_display_timezone()) due_date = today + dt.timedelta(days=days) flattened_data[('next_update_due', )] = due_date.date().isoformat() get_validator('convert_to_extras')(('next_update_due', ), flattened_data, errors, context)
def get_default_gmd_cited_responsible_party_schema(): return { 'individual_name': [ne, str], 'organisation_name': [im, str], 'position_name': [im, str], 'contact_info': [im, _sub('gmd_contact')], 'role': [ne, _sub('gmd_code_string')], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_contact_schema(): return { 'phone': [im, _sub('gmd_phone')], 'address': [im, _sub('gmd_address')], 'online_resource': [im, _sub('gmd_online_resource')], 'hours_of_service': [im, str], 'contact_instructions': [im, str], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_lineage_source_schema(): return { 'description': [im, str], 'scale_denominator': [im, get_validator('int_validator')], 'source_reference_system': [im, _sub('gmd_identifier')], 'source_citation': [im, _sub('gmd_citation')], 'source_extent': get_validator('spc_list_of')(_sub('gmd_extent')), '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_geographic_coverage_schema(): return { 'geographic_description': [get_validator('not_empty'), unicode_safe], 'bounding_coordinates': [ get_validator('not_empty'), get_validator('construct_sub_schema')('bounding_coordinates') ], '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_extended_element_schema(): return { 'name': [ne, str], 'short_name': [im, str], 'domain_code': [im, get_validator('int_validator')], 'definition': [ne, str], 'obligation': [im, str], 'condition': [im, str], 'data_type': [im, _sub('gmd_code_string')], 'maximum_occurrence': [im, str], 'domain_value': [im, str], 'parent_entity': [ ne, get_validator('spc_to_json'), get_validator('convert_to_json_if_string'), get_validator('list_of_strings') ], 'rule': [ne, str], 'rationale': [ im, get_validator('spc_to_json'), get_validator('convert_to_json_if_string'), get_validator('list_of_strings') ], 'source': get_default_gmd_cited_responsible_party_schema(), '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_default_gmd_base_identification_schema(): return { 'citation': [ne, _sub('gmd_citation')], 'abstract': [ne, str], 'purpose': [im, str], 'credit': [ im, get_validator('spc_to_json'), get_validator('convert_to_json_if_string'), get_validator('list_of_strings') ], 'status': get_default_gmd_code_string_schema(), 'point_of_contact': get_default_gmd_cited_responsible_party_schema(), 'resource_maintenance': [ get_validator('spc_list_of')(_sub('gmd_maintenance')) ], 'graphic_overview': get_default_gmd_graphic_schema(), 'resource_format': get_default_gmd_format_schema(), 'descriptive_keywords': get_default_gmd_keywords_schema(), 'resource_specific_usage': get_default_gmd_usage_schema(), 'resource_constraints': [ im, get_validator('spc_to_json'), get_validator('convert_to_json_if_string'), get_validator('list_of_strings') ], 'aggregation_info': get_default_gmd_aggregation_schema(), '__extras': [get_validator('ignore')], '__junk': [get_validator('ignore')], }
def get_validator_or_converter(name): """ Get a validator or converter by name """ if name == 'unicode': return unicode try: v = get_validator(name) return v except UnknownValidator: pass raise SchemingException('validator/converter not found: %r' % name)
scheming_dataset_schema_show, scheming_group_schema_list, scheming_group_schema_show, scheming_organization_schema_list, scheming_organization_schema_show ) from ckanext.scheming.converters import ( convert_from_extras_group, convert_to_json_if_date, convert_to_json_if_datetime ) import os import inspect ignore_missing = get_validator('ignore_missing') not_empty = get_validator('not_empty') convert_to_extras = get_converter('convert_to_extras') convert_from_extras = get_converter('convert_from_extras') DEFAULT_PRESETS = 'ckanext.scheming:presets.json' import logging log = logging.getLogger(__name__) class _SchemingMixin(object): """ Store single plugin instances in class variable 'instance' All plugins below need helpers and template directories, but we should
render, request, response, abort, get_action, check_access, get_validator, Invalid, aslist, ) from ckanapi import LocalCKAN, NotAuthorized, ValidationError from ckanext.recombinant.datatypes import canonicalize int_validator = get_validator('int_validator') ottawa_tz = timezone('America/Montreal') class IntentionalServerError(Exception): pass class CanadaController(BaseController): def home(self): if not c.user: h.redirect_to(controller='user', action='login') is_new = not h.check_access('package_create') if is_new:
import json import ckanext.scheming.helpers as sh import ckan.lib.navl.dictization_functions as df from ckanext.scheming.validation import scheming_validator from ckantoolkit import _, get_validator import logging logger = logging.getLogger(__name__) StopOnError = df.StopOnError missing = df.missing not_empty = get_validator('not_empty') def composite_not_empty_subfield(key, subfield_label, value, errors): ''' Function equivalent to ckan.lib.navl.validators.not_empty but for subfields (custom message including subfield) ''' if not value or value is missing: errors[key].append(_('Missing value at required subfield ' + subfield_label)) raise StopOnError @scheming_validator def composite_group2json(field, schema): def validator(key, data, errors, context): value = "" for name,text in data.iteritems():
from logging import getLogger import ckantoolkit as toolkit from ckan.common import json from ckan import plugins as p import ckan.lib.helpers as h try: from ckan.lib.datapreview import on_same_domain except ImportError: from ckan.lib.datapreview import _on_same_domain as on_same_domain ignore_empty = toolkit.get_validator('ignore_empty') boolean_validator = toolkit.get_validator('boolean_validator') log = getLogger(__name__) GEOVIEW_FORMATS = ['kml', 'geojson', 'gml', 'wms', 'wfs', 'esrigeojson', 'gft', 'arcgis_rest', 'wmts', 'esri rest'] def get_proxified_service_url(data_dict): ''' :param data_dict: contains a resource and package dict :type data_dict: dictionary ''' controller = \ 'ckanext.geoview.controllers.service_proxy:ServiceProxyController'