How to use the pycsw.util.nspath_eval function in pycsw

To help you get started, we’ve selected a few pycsw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geopython / pycsw / pycsw / plugins / profiles / dif / dif.py View on Github external
val = util.getqattr(result, queryables['dif:Data_Presentation_Form']['dbcol'])
        etree.SubElement(citation, util.nspath_eval('dif:Data_Presentation_Form', self.namespaces)).text = val

        # iso topic category
        val = util.getqattr(result, queryables['dif:ISO_Topic_Category']['dbcol'])
        etree.SubElement(node, util.nspath_eval('dif:ISO_Topic_Category', self.namespaces)).text = val

        # keywords
        val = util.getqattr(result, queryables['dif:Keyword']['dbcol'])

        if val:
            for kw in val.split(','):
                etree.SubElement(node, util.nspath_eval('dif:Keyword', self.namespaces)).text = kw

        # temporal
        temporal = etree.SubElement(node, util.nspath_eval('dif:Temporal_Coverage', self.namespaces))
        val = util.getqattr(result, queryables['dif:Start_Date']['dbcol'])
        val2 = util.getqattr(result, queryables['dif:Stop_Date']['dbcol'])
        etree.SubElement(temporal, util.nspath_eval('dif:Start_Date', self.namespaces)).text = val 
        etree.SubElement(temporal, util.nspath_eval('dif:End_Date', self.namespaces)).text = val2

        # bbox extent
        val = util.getqattr(result, queryables['dif:Spatial_Coverage']['dbcol'])
        bboxel = write_extent(val, self.namespaces)
        if bboxel is not None:
            node.append(bboxel)

        # access constraints
        val = util.getqattr(result, queryables['dif:Access_Constraints']['dbcol'])
        etree.SubElement(node, util.nspath_eval('dif:Access_Constraints', self.namespaces)).text = val

        # language
github geopython / pycsw / pycsw / plugins / profiles / atom / atom.py View on Github external
def write_extent(bbox, nsmap):
    ''' Generate BBOX extent '''

    from shapely.wkt import loads

    if bbox is not None:
        if bbox.find('SRID') != -1:  # it's EWKT; chop off 'SRID=\d+;'
            bbox2 = loads(bbox.split(';')[-1])
        else:
            bbox2 = loads(bbox)
        where = etree.Element(util.nspath_eval('georss:where', nsmap))
        polygon = etree.SubElement(where, util.nspath_eval('gml:Polygon', nsmap), srsName='urn:x-ogc:def:crs:EPSG:6.11:4326')
        exterior = etree.SubElement(polygon, util.nspath_eval('gml:exterior', nsmap))
        lring = etree.SubElement(exterior, util.nspath_eval('gml:LinearRing', nsmap))
        poslist = etree.SubElement(lring, util.nspath_eval('gml:posList', nsmap)).text = \
        ' '.join(['%s %s' % (str(i[1]), str(i[0])) for i in list(bbox2.exterior.coords)])

        return where
    return None
github geopython / pycsw / pycsw / gml.py View on Github external
def _get_envelope(self):
        """Parse gml:Envelope"""

        tmp = self._exml.find(util.nspath_eval('gml:Envelope/gml:lowerCorner',
                                               self.nsmap))
        if tmp is None:
            raise RuntimeError('Invalid gml:Envelope geometry.\
                               Missing gml:lowerCorner')
        else:
            lower_left = tmp.text

        tmp = self._exml.find(util.nspath_eval('gml:Envelope/gml:upperCorner',
                                               self.nsmap))
        if tmp is None:
            raise RuntimeError('Invalid gml:Envelope geometry.\
                               Missing gml:upperCorner')
        else:
            upper_right = tmp.text

        llmin = lower_left.split()
github geopython / pycsw / pycsw / plugins / profiles / atom / atom.py View on Github external
def write_extent(bbox, nsmap):
    ''' Generate BBOX extent '''

    from shapely.wkt import loads

    if bbox is not None:
        if bbox.find('SRID') != -1:  # it's EWKT; chop off 'SRID=\d+;'
            bbox2 = loads(bbox.split(';')[-1])
        else:
            bbox2 = loads(bbox)
        where = etree.Element(util.nspath_eval('georss:where', nsmap))
        polygon = etree.SubElement(where, util.nspath_eval('gml:Polygon', nsmap), srsName='urn:x-ogc:def:crs:EPSG:6.11:4326')
        exterior = etree.SubElement(polygon, util.nspath_eval('gml:exterior', nsmap))
        lring = etree.SubElement(exterior, util.nspath_eval('gml:LinearRing', nsmap))
        poslist = etree.SubElement(lring, util.nspath_eval('gml:posList', nsmap)).text = \
        ' '.join(['%s %s' % (str(i[1]), str(i[0])) for i in list(bbox2.exterior.coords)])

        return where
    return None
github geopython / pycsw / pycsw / plugins / profiles / dif / dif.py View on Github external
# creator
        val = util.getqattr(result, queryables['dif:Dataset_Creator']['dbcol'])
        etree.SubElement(citation, util.nspath_eval('dif:Dataset_Creator', self.namespaces)).text = val

        # date
        val = util.getqattr(result, queryables['dif:Dataset_Release_Date']['dbcol'])
        etree.SubElement(citation, util.nspath_eval('dif:Dataset_Release_Date', self.namespaces)).text = val

        # publisher
        val = util.getqattr(result, queryables['dif:Dataset_Publisher']['dbcol'])
        etree.SubElement(citation, util.nspath_eval('dif:Dataset_Publisher', self.namespaces)).text = val

        # format
        val = util.getqattr(result, queryables['dif:Data_Presentation_Form']['dbcol'])
        etree.SubElement(citation, util.nspath_eval('dif:Data_Presentation_Form', self.namespaces)).text = val

        # iso topic category
        val = util.getqattr(result, queryables['dif:ISO_Topic_Category']['dbcol'])
        etree.SubElement(node, util.nspath_eval('dif:ISO_Topic_Category', self.namespaces)).text = val

        # keywords
        val = util.getqattr(result, queryables['dif:Keyword']['dbcol'])

        if val:
            for kw in val.split(','):
                etree.SubElement(node, util.nspath_eval('dif:Keyword', self.namespaces)).text = kw

        # temporal
        temporal = etree.SubElement(node, util.nspath_eval('dif:Temporal_Coverage', self.namespaces))
        val = util.getqattr(result, queryables['dif:Start_Date']['dbcol'])
        val2 = util.getqattr(result, queryables['dif:Stop_Date']['dbcol'])
github geopython / pycsw / pycsw / plugins / profiles / atom / atom.py View on Github external
def write_extent(bbox, nsmap):
    ''' Generate BBOX extent '''

    from shapely.wkt import loads

    if bbox is not None:
        if bbox.find('SRID') != -1:  # it's EWKT; chop off 'SRID=\d+;'
            bbox2 = loads(bbox.split(';')[-1])
        else:
            bbox2 = loads(bbox)
        where = etree.Element(util.nspath_eval('georss:where', nsmap))
        polygon = etree.SubElement(where, util.nspath_eval('gml:Polygon', nsmap), srsName='urn:x-ogc:def:crs:EPSG:6.11:4326')
        exterior = etree.SubElement(polygon, util.nspath_eval('gml:exterior', nsmap))
        lring = etree.SubElement(exterior, util.nspath_eval('gml:LinearRing', nsmap))
        poslist = etree.SubElement(lring, util.nspath_eval('gml:posList', nsmap)).text = \
        ' '.join(['%s %s' % (str(i[1]), str(i[0])) for i in list(bbox2.exterior.coords)])

        return where
    return None
github geopython / pycsw / pycsw / plugins / profiles / dif / dif.py View on Github external
def write_extent(bbox, nsmap):
    ''' Generate BBOX extent '''

    from shapely.wkt import loads

    if bbox is not None:
        if bbox.find('SRID') != -1:  # it's EWKT; chop off 'SRID=\d+;'
            bbox2 = loads(bbox.split(';')[-1]).envelope.bounds
        else:
            bbox2 = loads(bbox).envelope.bounds
        extent = etree.Element(util.nspath_eval('dif:Spatial_Coverage', nsmap))
        etree.SubElement(extent, util.nspath_eval('dif:Southernmost_Latitude', nsmap)).text = str(bbox2[1])
        etree.SubElement(extent, util.nspath_eval('dif:Northernmost_Latitude', nsmap)).text = str(bbox2[3])
        etree.SubElement(extent, util.nspath_eval('dif:Westernmost_Longitude', nsmap)).text = str(bbox2[0])
        etree.SubElement(extent, util.nspath_eval('dif:Easternmost_Longitude', nsmap)).text = str(bbox2[2])
        return extent
    return None
github geopython / pycsw / pycsw / plugins / profiles / fgdc / fgdc.py View on Github external
def write_record(self, recobj, esn, outputschema, queryables):
        ''' Return csw:SearchResults child as lxml.etree.Element '''
        typename = util.getqattr(recobj, self.context.md_core_model['mappings']['pycsw:Typename'])
        if esn == 'full' and typename == 'fgdc:metadata':
            # dump record as is and exit
            return etree.fromstring(util.getqattr(recobj, self.context.md_core_model['mappings']['pycsw:XML']))

        if typename == 'csw:Record':
            # transform csw:Record -> fgdc:metadata model mappings
            util.transform_mappings(queryables,
            self.repository['mappings']['csw:Record'])

        node = etree.Element('metadata')
        node.attrib[util.nspath_eval('xsi:noNamespaceSchemaLocation', self.context.namespaces)] = \
        'http://www.fgdc.gov/metadata/fgdc-std-001-1998.xsd'

        idinfo = etree.SubElement(node, 'idinfo')
        # identifier
        etree.SubElement(idinfo, 'datasetid').text = util.getqattr(recobj, queryables['fgdc:Identifier']['dbcol'])

        citation = etree.SubElement(idinfo, 'citation')
        citeinfo = etree.SubElement(citation, 'citeinfo')

        # title
        val = util.getqattr(recobj, queryables['fgdc:Title']['dbcol'])
        etree.SubElement(citeinfo, 'title').text = val

        # publisher
        publinfo = etree.SubElement(citeinfo, 'publinfo')
        val = util.getqattr(recobj, queryables['fgdc:Publisher']['dbcol']) or ''
github geopython / pycsw / pycsw / cql.py View on Github external
if tmp_list:
        LOGGER.debug('Logical operator found (AND/OR)')
    else:
        tmp_list.append(cql)

    for t in tmp_list:
        filters.append(_parse_condition(t))

    root = etree.Element(util.nspath_eval('ogc:Filter', namespaces))

    if logical_op is not None:
        root.append(logical_op)

    for flt in filters:
        condition = etree.Element(util.nspath_eval(flt[0], namespaces))

        etree.SubElement(
            condition,
            util.nspath_eval('ogc:PropertyName', namespaces)).text = flt[1]

        etree.SubElement(
            condition,
            util.nspath_eval('ogc:Literal', namespaces)).text = flt[2]

        if logical_op is not None:
            logical_op.append(condition)
        else:
            root.append(condition)

    LOGGER.debug('Resulting OGC Filter: %s',
                 etree.tostring(root, pretty_print=1))
github geopython / pycsw / pycsw / cql.py View on Github external
root = etree.Element(util.nspath_eval('ogc:Filter', namespaces))

    if logical_op is not None:
        root.append(logical_op)

    for flt in filters:
        condition = etree.Element(util.nspath_eval(flt[0], namespaces))

        etree.SubElement(
            condition,
            util.nspath_eval('ogc:PropertyName', namespaces)).text = flt[1]

        etree.SubElement(
            condition,
            util.nspath_eval('ogc:Literal', namespaces)).text = flt[2]

        if logical_op is not None:
            logical_op.append(condition)
        else:
            root.append(condition)

    LOGGER.debug('Resulting OGC Filter: %s',
                 etree.tostring(root, pretty_print=1))

    return root