This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def augment_data(data, schema): | |
'''add missing, extras and junk data''' | |
flattented_schema = flatten_schema(schema) | |
key_combinations = get_all_key_combinations(data, flattented_schema) | |
full_schema = make_full_schema(data, schema) | |
new_data = copy.copy(data) | |
## fill junk and extras |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def package_extras_save(extra_dicts, obj, context): | |
allow_partial_update = context.get("allow_partial_update", False) | |
if extra_dicts is None and allow_partial_update: | |
return | |
model = context["model"] | |
session = context["session"] | |
extras_list = obj.extras_list | |
old_extras = dict((extra.key, extra) for extra in extras_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"comment": "This is an example of using the Distribution field to identify a number of resources related to a dataset. See also http://project-open-data.github.io/schema/#expanded-fields", | |
"distribution": [ | |
{ | |
"accessURL": "https://api.data.gov/unicorns", | |
"format": "application/json" | |
}, | |
{ | |
"accessURL": "https://static.data.gov/coolfile.csv", | |
"format": "text/csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def harvesters_info_show(context,data_dict): | |
check_access('harvesters_info_show',context,data_dict) | |
available_harvesters = [] | |
for harvester in PluginImplementations(IHarvester): | |
info = harvester.info() | |
if not info or 'name' not in info: | |
log.error('Harvester %r does not provide the harvester name in the info response' % str(harvester)) | |
continue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def default_create_package_schema(): | |
schema = { | |
'__before': [duplicate_extras_key, ignore], | |
'id': [empty], | |
'revision_id': [ignore], | |
'name': [not_empty, unicode, name_validator, package_name_validator], | |
'title': [if_empty_same_as("name"), unicode], | |
'author': [ignore_missing, unicode], | |
'author_email': [ignore_missing, unicode], | |
'maintainer': [ignore_missing, unicode], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if show_organizations_selector %} | |
{% set existing_org = data.owner_org %} | |
<div class="control-group"> | |
<label for="field-organizations" class="control-label">{{ _('Organization') }}</label> | |
<div class="controls"> | |
<select id="field-organizations" name="owner_org" data-module="autocomplete"> | |
<option value="" {% if not selected_org and data.id %} selected="selected" {% endif %}>{{ _('Select an organization...') }}</option> | |
{% for organization in organizations_available %} | |
{# get out first org from users list only if there is not an existing org #} | |
{% set selected_org = (existing_org and existing_org == organization.id) or (not existing_org and not data.id and organization.id == organizations_available[0].id) %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ckanext.spatial.validation.validation as v | |
from lxml import etree | |
TEST_FILE = 'satellite-systems_dscovr.xml' | |
with open(TEST_FILE, 'r') as f: | |
xmlobj = etree.XML(f.read()) | |
validator = v.ISO19139NGDCSchema() | |
print(validator.is_valid(xmlobj)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
regular = "(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)" | |
irregular = "(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)" | |
grandfathered = "(" + irregular + "|" + regular + ")" | |
privateUse = "(x(-[A-Za-z0-9]{1,8})+)" | |
singleton = "[0-9A-WY-Za-wy-z]" | |
extension = "(" + singleton + "(-[A-Za-z0-9]{2,8})+)" | |
variant = "([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3})" | |
region = "([A-Za-z]{2}|[0-9]{3})" | |
script = "([A-Za-z]{4})" | |
extlang = "([A-Za-z]{3}(-[A-Za-z]{3}){0,2})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"title": "Data Catalog", | |
"description": "Version 1.0", | |
"contactPoint": "somebody important", | |
"keyword": ["catalog"], | |
"modified": "2013-05-09 06:00:00", | |
"publisher": "US Department of X", | |
"person": "Contact Person", | |
"mbox": "[email protected]", | |
"language": ["aav"], |
OlderNewer