How to use the pycsw.util.getqattr 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 / fgdc / fgdc.py View on Github external
keywords = etree.SubElement(idinfo, 'keywords')
            theme = etree.SubElement(keywords, 'theme')
            for v in val.split(','):
                etree.SubElement(theme, 'themekey').text = v

        # accessconstraints
        val = util.getqattr(recobj, queryables['fgdc:AccessConstraints']['dbcol']) or ''
        etree.SubElement(idinfo, 'accconst').text = val

        # abstract
        descript = etree.SubElement(idinfo, 'descript')
        val = util.getqattr(recobj, queryables['fgdc:Abstract']['dbcol']) or ''
        etree.SubElement(descript, 'abstract').text = val

        # time
        datebegin = util.getqattr(recobj, queryables['fgdc:BeginDate']['dbcol'])
        dateend = util.getqattr(recobj, queryables['fgdc:EndDate']['dbcol'])
        if all([datebegin, dateend]):
            timeperd = etree.SubElement(idinfo, 'timeperd')
            timeinfo = etree.SubElement(timeperd, 'timeinfo')
            rngdates = etree.SubElement(timeinfo, 'timeinfo')
            begdate = etree.SubElement(rngdates, 'begdate').text = datebegin
            enddate = etree.SubElement(rngdates, 'enddate').text = dateend

        # bbox extent
        val = util.getqattr(recobj, queryables['fgdc:Envelope']['dbcol'])
        bboxel = write_extent(val)
        if bboxel is not None:
            idinfo.append(bboxel)

        # contributor
        val = util.getqattr(recobj, queryables['fgdc:Contributor']['dbcol']) or ''
github geopython / pycsw / pycsw / plugins / profiles / fgdc / fgdc.py View on Github external
etree.SubElement(digtinfo, 'formname').text = val
        etree.SubElement(citeinfo, 'geoform').text = val

        # source
        lineage = etree.SubElement(node, 'lineage')
        srcinfo = etree.SubElement(lineage, 'srcinfo')
        srccite = etree.SubElement(srcinfo, 'srccite')
        sciteinfo = etree.SubElement(srccite, 'citeinfo')
        val = util.getqattr(recobj, queryables['fgdc:Source']['dbcol']) or ''
        etree.SubElement(sciteinfo, 'title').text = val

        val = util.getqattr(recobj, queryables['fgdc:Relation']['dbcol']) or ''
        etree.SubElement(citeinfo, 'onlink').text = val

        # links
        rlinks = util.getqattr(recobj, self.context.md_core_model['mappings']['pycsw:Links'])
        if rlinks:
            for link in rlinks.split('^'):
                linkset = link.split(',')
                etree.SubElement(citeinfo, 'onlink', type=linkset[2]).text = linkset[-1]

        # metd
        metainfo = etree.SubElement(node, 'metainfo')
        val = util.getqattr(recobj, queryables['fgdc:Modified']['dbcol']) or ''
        etree.SubElement(metainfo, 'metd').text = val

        return node
github geopython / pycsw / pycsw / plugins / profiles / atom / atom.py View on Github external
if typename == 'csw:Record':  # transform csw:Record -> atom:entry model mappings
            util.transform_mappings(queryables, self.repository['mappings']['csw:Record'])

        node = etree.Element(util.nspath_eval('atom:entry', self.namespaces))
        node.attrib[util.nspath_eval('xsi:schemaLocation', self.context.namespaces)] = \
        '%s %s?service=CSW&version=2.0.2&request=DescribeRecord&typename=atom:entry' % (self.namespaces['atom'], self.url)

        # author
        val = util.getqattr(result, queryables['atom:author']['dbcol'])
         
        if val:
            etree.SubElement(node, util.nspath_eval('atom:author', self.namespaces)).text = util.getqattr(result, queryables['atom:author']['dbcol'])

        # category
        val = util.getqattr(result, queryables['atom:category']['dbcol'])

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


        for qval in ['contributor', 'id']:
            val = util.getqattr(result, queryables['atom:%s' % qval]['dbcol'])
            if val:
                etree.SubElement(node, util.nspath_eval('atom:%s' % qval, self.namespaces)).text = util.getqattr(result, queryables['atom:%s' % qval]['dbcol'])

        rlinks = util.getqattr(result, self.context.md_core_model['mappings']['pycsw:Links'])
        if rlinks:
            for link in rlinks.split('^'):
                linkset = link.split(',')
github geopython / pycsw / pycsw / plugins / profiles / atom / atom.py View on Github external
rlinks = util.getqattr(result, self.context.md_core_model['mappings']['pycsw:Links'])
        if rlinks:
            for link in rlinks.split('^'):
                linkset = link.split(',')
           
                url2 = etree.SubElement(node, util.nspath_eval('atom:link', self.namespaces), href=linkset[-1], type=linkset[2], title=linkset[1])

        etree.SubElement(node, util.nspath_eval('atom:link', self.namespaces), href='%s?service=CSW&version=2.0.2&request=GetRepositoryItem&id=%s' % (self.url, util.getqattr(result, queryables['atom:id']['dbcol'])))

        for qval in ['published', 'rights', 'source', 'summary', 'title', 'updated']:
            val = util.getqattr(result, queryables['atom:%s' % qval]['dbcol'])
            if val:
                etree.SubElement(node, util.nspath_eval('atom:%s' % qval, self.namespaces)).text = util.getqattr(result, queryables['atom:%s' % qval]['dbcol'])

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

        return node
github dbca-wa / oim-cms / catalogue / views.py View on Github external
etree.SubElement(record,
            util.nspath_eval('dc:identifier', self.context.namespaces)).text = \
            util.getqattr(recobj,
            self.context.md_core_model['mappings']['pycsw:Identifier'])

            for i in ['dc:title', 'dc:type']:
                val = util.getqattr(recobj, queryables[i]['dbcol'])
                if not val:
                    val = ''
                etree.SubElement(record, util.nspath_eval(i,
                self.context.namespaces)).text = val

            if self.kvp['elementsetname'] in ['summary', 'full']:
                # add summary elements
                keywords = util.getqattr(recobj, queryables['dc:subject']['dbcol'])
                if keywords is not None:
                    for keyword in keywords.split(','):
                        etree.SubElement(record,
                        util.nspath_eval('dc:subject',
                        self.context.namespaces)).text = keyword

                val = util.getqattr(recobj, queryables['dc:format']['dbcol'])
                if val:
                    etree.SubElement(record,
                    util.nspath_eval('dc:format',
                    self.context.namespaces)).text = val

                # links
                rlinks = util.getqattr(recobj,
                self.context.md_core_model['mappings']['pycsw:Links'])
github dbca-wa / oim-cms / catalogue / views.py View on Github external
self.context.namespaces)).text = value
        elif 'elementsetname' in self.kvp:
            if (self.kvp['elementsetname'] == 'full' and
            util.getqattr(recobj, self.context.md_core_model['mappings']\
            ['pycsw:Typename']) == 'csw:Record' and
            util.getqattr(recobj, self.context.md_core_model['mappings']\
            ['pycsw:Schema']) == 'http://www.opengis.net/cat/csw/2.0.2' and
            util.getqattr(recobj, self.context.md_core_model['mappings']\
            ['pycsw:Type']) != 'service'):
                # dump record as is and exit
                return etree.fromstring(util.getqattr(recobj,
                self.context.md_core_model['mappings']['pycsw:XML']), self.context.parser)

            etree.SubElement(record,
            util.nspath_eval('dc:identifier', self.context.namespaces)).text = \
            util.getqattr(recobj,
            self.context.md_core_model['mappings']['pycsw:Identifier'])

            for i in ['dc:title', 'dc:type']:
                val = util.getqattr(recobj, queryables[i]['dbcol'])
                if not val:
                    val = ''
                etree.SubElement(record, util.nspath_eval(i,
                self.context.namespaces)).text = val

            if self.kvp['elementsetname'] in ['summary', 'full']:
                # add summary elements
                keywords = util.getqattr(recobj, queryables['dc:subject']['dbcol'])
                if keywords is not None:
                    for keyword in keywords.split(','):
                        etree.SubElement(record,
                        util.nspath_eval('dc:subject',
github geopython / pycsw / pycsw / plugins / profiles / atom / atom.py View on Github external
if val:
            etree.SubElement(node, util.nspath_eval('atom:author', self.namespaces)).text = util.getqattr(result, queryables['atom:author']['dbcol'])

        # category
        val = util.getqattr(result, queryables['atom:category']['dbcol'])

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


        for qval in ['contributor', 'id']:
            val = util.getqattr(result, queryables['atom:%s' % qval]['dbcol'])
            if val:
                etree.SubElement(node, util.nspath_eval('atom:%s' % qval, self.namespaces)).text = util.getqattr(result, queryables['atom:%s' % qval]['dbcol'])

        rlinks = util.getqattr(result, self.context.md_core_model['mappings']['pycsw:Links'])
        if rlinks:
            for link in rlinks.split('^'):
                linkset = link.split(',')
           
                url2 = etree.SubElement(node, util.nspath_eval('atom:link', self.namespaces), href=linkset[-1], type=linkset[2], title=linkset[1])

        etree.SubElement(node, util.nspath_eval('atom:link', self.namespaces), href='%s?service=CSW&version=2.0.2&request=GetRepositoryItem&id=%s' % (self.url, util.getqattr(result, queryables['atom:id']['dbcol'])))

        for qval in ['published', 'rights', 'source', 'summary', 'title', 'updated']:
            val = util.getqattr(result, queryables['atom:%s' % qval]['dbcol'])
            if val:
                etree.SubElement(node, util.nspath_eval('atom:%s' % qval, self.namespaces)).text = util.getqattr(result, queryables['atom:%s' % qval]['dbcol'])

        # bbox extent
github geopython / pycsw / pycsw / plugins / profiles / atom / atom.py View on Github external
def write_record(self, result, esn, outputschema, queryables):
        ''' Return csw:SearchResults child as lxml.etree.Element '''

        typename = util.getqattr(result, self.context.md_core_model['mappings']['pycsw:Typename'])

        if esn == 'full' and typename == 'atom:entry':
            # dump record as is and exit
            return etree.fromstring(util.getqattr(result, self.context.md_core_model['mappings']['pycsw:XML']))

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

        node = etree.Element(util.nspath_eval('atom:entry', self.namespaces))
        node.attrib[util.nspath_eval('xsi:schemaLocation', self.context.namespaces)] = \
        '%s %s?service=CSW&version=2.0.2&request=DescribeRecord&typename=atom:entry' % (self.namespaces['atom'], self.url)

        # author
        val = util.getqattr(result, queryables['atom:author']['dbcol'])
         
        if val:
            etree.SubElement(node, util.nspath_eval('atom:author', self.namespaces)).text = util.getqattr(result, queryables['atom:author']['dbcol'])

        # category
        val = util.getqattr(result, queryables['atom:category']['dbcol'])
github geopython / pycsw / pycsw / plugins / profiles / dif / dif.py View on Github external
def write_record(self, result, esn, outputschema, queryables):
        ''' Return csw:SearchResults child as lxml.etree.Element '''

        typename = util.getqattr(result, self.context.md_core_model['mappings']['pycsw:Typename'])

        if esn == 'full' and typename == 'dif:DIF':
            # dump record as is and exit
            return etree.fromstring(util.getqattr(result, self.context.md_core_model['mappings']['pycsw:XML']))

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

        node = etree.Element(util.nspath_eval('dif:DIF', self.namespaces))
        node.attrib[util.nspath_eval('xsi:schemaLocation', self.context.namespaces)] = \
        '%s http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/dif.xsd' % self.namespace

        # identifier
        etree.SubElement(node, util.nspath_eval('dif:Entry_ID', self.namespaces)).text = util.getqattr(result, queryables['dif:Identifier']['dbcol'])

        # title
        val = util.getqattr(result, queryables['dif:Entry_Title']['dbcol'])
        if not val:
            val = ''
        etree.SubElement(node, util.nspath_eval('dif:Entry_Title', self.namespaces)).text = val
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')