コード例 #1
0
def _transform_dcat(xml_dom):
    from lxml import etree

    xsl_file = reference_data.get_path('xsl/iso-19139-to-dcat-ap.xsl')
    result = None
    with open(xsl_file, 'r') as fp:
        # Transform using XSLT
        dcat_xslt = etree.parse(fp)
        dcat_transform = etree.XSLT(dcat_xslt)
        result = dcat_transform(xml_dom)
        result = unicode(result).encode('utf-8')

    return result
コード例 #2
0
def _transform_dcat(xml_dom):
    from lxml import etree

    xsl_file = reference_data.get_path('xsl/iso-19139-to-dcat-ap.xsl')
    result = None
    with open(xsl_file, 'r') as fp:
        # Transform using XSLT
        dcat_xslt = etree.parse(fp)
        dcat_transform = etree.XSLT(dcat_xslt)
        result = dcat_transform(xml_dom)
        result = unicode(result).encode('utf-8')

    return result
コード例 #3
0
    def to_xsd(self, wrap_into_schema=False, type_prefix='', annotate=False):
        '''Return the XSD document as an etree Element.
        '''

        # Note We do not support providing parts of it 
        assert wrap_into_schema

        xsd_file = reference_data.get_path('xsd/isotc211.org-2005/gmd/metadataEntity.xsd')

        xsd = None
        with open(xsd_file, 'r') as fp:
            xsd = etree.parse(fp)
        return xsd.getroot()
コード例 #4
0
    def to_xsd(self, wrap_into_schema=False, type_prefix='', annotate=False):
        '''Return the XSD document as an etree Element.
        '''

        # Note We do not support providing parts of it 
        assert wrap_into_schema

        xsd_file = reference_data.get_path('xsd/isotc211.org-2005/gmd/metadataEntity.xsd')

        xsd = None
        with open(xsd_file, 'r') as fp:
            xsd = etree.parse(fp)
        return xsd.getroot()
コード例 #5
0
import json
import re
import zope.interface
import zope.schema
from zope.schema.vocabulary import SimpleVocabulary

from ckanext.publicamundi import reference_data

_datafile = reference_data.get_path('language-codes-3b2.json')
_data = None

with open(_datafile, 'r') as fp:
    _data = json.load(fp)
fp.close()
del fp

_re_alpha2 = re.compile('^[a-z]{2,2}$')
_re_alpha3b = re.compile('^[a-z]{3,3}$')

class ILanguage(zope.interface.Interface):

    code = zope.schema.NativeStringLine(required=True)
    
    table = zope.schema.Choice(
        required = True,
        vocabulary = SimpleVocabulary.fromValues(('iso-639-1', 'iso-639-2')))

    name = zope.schema.TextLine(required=True)

@zope.interface.implementer(ILanguage)
class Language(object):
コード例 #6
0
    keys = filter(lambda t: vocabularies[t]['title'] == title,
                  vocabularies.keys())
    if keys:
        k = keys[0]
        return vocabularies[k]
    else:
        return None


def get_by_name(name):
    return vocabularies.get(name)


# Aliases

names = get_names

titles = get_titles

by_name = get_by_name

by_title = get_by_title

# Initialize - Load common vocabularies

from ckanext.publicamundi import reference_data

_update(reference_data.get_path('inspire-vocabularies.json'), name_prefix='')

_update(reference_data.get_path('language-codes.json'), name_prefix='')
コード例 #7
0
import json
import re
import zope.interface
import zope.schema
from zope.schema.vocabulary import SimpleVocabulary

from ckanext.publicamundi import reference_data

_datafile = reference_data.get_path('language-codes-3b2.json')
_data = None

with open(_datafile, 'r') as fp:
    _data = json.load(fp)
fp.close()
del fp

_re_alpha2 = re.compile('^[a-z]{2,2}$')
_re_alpha3b = re.compile('^[a-z]{3,3}$')


class ILanguage(zope.interface.Interface):

    code = zope.schema.NativeStringLine(required=True)

    table = zope.schema.Choice(required=True,
                               vocabulary=SimpleVocabulary.fromValues(
                                   ('iso-639-1', 'iso-639-2')))

    name = zope.schema.TextLine(required=True)

コード例 #8
0
        return vocabularies[k]
    else:
        return None

def get_by_name(name):
    return vocabularies.get(name)


# Aliases

names = get_names

titles = get_titles

by_name = get_by_name

by_title = get_by_title

# Initialize - Load common vocabularies

from ckanext.publicamundi import reference_data

_update(
    reference_data.get_path('inspire-vocabularies.json'), 
    name_prefix='')

_update(
    reference_data.get_path('language-codes.json'), 
    name_prefix='')