• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.nspath_eval函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pycsw.core.util.nspath_eval函数的典型用法代码示例。如果您正苦于以下问题:Python nspath_eval函数的具体用法?Python nspath_eval怎么用?Python nspath_eval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了nspath_eval函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: write_keywords

def write_keywords(keywords, nsmap):
    """generate gmd:MD_Keywords construct"""
    md_keywords = etree.Element(util.nspath_eval('gmd:MD_Keywords', nsmap))
    for kw in keywords.split(','):
        keyword = etree.SubElement(md_keywords, util.nspath_eval('gmd:keyword', nsmap))
        etree.SubElement(keyword, util.nspath_eval('gco:CharacterString', nsmap)).text = kw
    return md_keywords
开发者ID:SNIMar-WP4,项目名称:pycsw,代码行数:7,代码来源:apiso.py


示例2: _get_envelope

    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()
        urmax = upper_right.split()

        if len(llmin) < 2 or len(urmax) < 2:
            raise RuntimeError('Invalid gml:Envelope geometry. \
            gml:lowerCorner and gml:upperCorner must hold at least x and y')

        if self.crs.axisorder == 'yx':
            self.wkt = util.bbox2wktpolygon('%s,%s,%s,%s' % (llmin[1],
                                            llmin[0], urmax[1], urmax[0]))
        else:
            self.wkt = util.bbox2wktpolygon('%s,%s,%s,%s' % (llmin[0],
                                            llmin[1], urmax[0], urmax[1]))
开发者ID:meilinger,项目名称:pycsw,代码行数:32,代码来源:gml3.py


示例3: gen_sitemap

def gen_sitemap(context, database, table, url, output_file):
    """generate an XML sitemap from all records in repository"""

    # get configuration and init repo connection
    repos = repository.Repository(database, context, table=table)

    # write out sitemap document
    urlset = etree.Element(util.nspath_eval("sitemap:urlset", context.namespaces), nsmap=context.namespaces)

    schema_loc = util.nspath_eval("xsi:schemaLocation", context.namespaces)

    urlset.attrib[schema_loc] = (
        "%s http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" % context.namespaces["sitemap"]
    )

    # get all records
    count, records = repos.query(constraint={}, maxrecords=99999999)

    LOGGER.info("Found %s records", count)

    for rec in records:
        url = etree.SubElement(urlset, util.nspath_eval("sitemap:url", context.namespaces))
        uri = "%s?service=CSW&version=2.0.2&request=GetRepositoryItem&id=%s" % (
            url,
            getattr(rec, context.md_core_model["mappings"]["pycsw:Identifier"]),
        )
        etree.SubElement(url, util.nspath_eval("sitemap:loc", context.namespaces)).text = uri

    # write to file
    LOGGER.info("Writing to %s", output_file)
    with open(output_file, "w") as ofile:
        ofile.write(etree.tostring(urlset, pretty_print=1, encoding="utf8", xml_declaration=1))
开发者ID:bukun,项目名称:pycsw,代码行数:32,代码来源:admin.py


示例4: get_schemacomponents

    def get_schemacomponents(self):
        ''' Return schema components as lxml.etree.Element list '''

        node1 = etree.Element(
        util.nspath_eval('csw:SchemaComponent', self.context.namespaces),
        schemaLanguage='XMLSCHEMA', targetNamespace=self.namespace,
        parentSchema='gmd.xsd')

        schema_file = os.path.join(self.context.pycsw_home, 'plugins',
                                   'profiles', 'apiso', 'schemas', 'ogc',
                                   'iso', '19139', '20060504', 'gmd',
                                   'identification.xsd')

        schema = etree.parse(schema_file, self.context.parser).getroot()

        node1.append(schema)

        node2 = etree.Element(
        util.nspath_eval('csw:SchemaComponent', self.context.namespaces),
        schemaLanguage='XMLSCHEMA', targetNamespace=self.namespace,
        parentSchema='gmd.xsd')

        schema_file = os.path.join(self.context.pycsw_home, 'plugins',
                                   'profiles', 'apiso', 'schemas', 'ogc',
                                   'iso', '19139', '20060504', 'srv',
                                   'serviceMetadata.xsd')

        schema = etree.parse(schema_file, self.context.parser).getroot()

        node2.append(schema)

        return [node1, node2]
开发者ID:SNIMar-WP4,项目名称:pycsw,代码行数:32,代码来源:apiso.py


示例5: _get_pt_freeurl

def _get_pt_freeurl(val, language):
    freeurl = etree.Element(util.nspath_eval('gm03:GM03_2_1Core.Core.PT_FreeURL', NAMESPACES))
    urlgroup = etree.SubElement(freeurl, util.nspath_eval('gm03:URLGroup', NAMESPACES))
    ptgroup = etree.SubElement(urlgroup, util.nspath_eval('gm03:GM03_2_1Core.Core.PT_URLGroup', NAMESPACES))
    if language:
        etree.SubElement(ptgroup, util.nspath_eval('gm03:language', NAMESPACES)).text = language
    etree.SubElement(ptgroup, util.nspath_eval('gm03:plainURL', NAMESPACES)).text = val

    return freeurl
开发者ID:raymondnijssen,项目名称:pycsw,代码行数:9,代码来源:gm03.py


示例6: _get_pt_freetext

def _get_pt_freetext(val, language):
    freetext = etree.Element(util.nspath_eval('gm03:GM03_2_1Core.Core.PT_FreeText', NAMESPACES))
    textgroup = etree.SubElement(freetext, util.nspath_eval('gm03:textGroup', NAMESPACES))
    ptgroup = etree.SubElement(textgroup, util.nspath_eval('gm03:GM03_2_1Core.Core.PT_Group', NAMESPACES))
    if language:
        etree.SubElement(ptgroup, util.nspath_eval('gm03:language', NAMESPACES)).text = language
    etree.SubElement(ptgroup, util.nspath_eval('gm03:plainText', NAMESPACES)).text = val

    return freetext
开发者ID:raymondnijssen,项目名称:pycsw,代码行数:9,代码来源:gm03.py


示例7: test_nspath_eval_invalid_element

def test_nspath_eval_invalid_element():
    with pytest.raises(RuntimeError):
        util.nspath_eval(
            xpath="ns1:tag1/ns2:ns3:tag2",
            nsmap={
                "ns1": "something",
                "ns2": "other",
                "ns3": "another",
            }
        )
开发者ID:PublicaMundi,项目名称:pycsw,代码行数:10,代码来源:test_util.py


示例8: _gen_soap_wrapper

    def _gen_soap_wrapper(self):
        """ Generate SOAP wrapper """
        LOGGER.debug("Writing SOAP wrapper.")
        node = etree.Element(
            util.nspath_eval("soapenv:Envelope", self.context.namespaces), nsmap=self.context.namespaces
        )

        schema_location_ns = util.nspath_eval("xsi:schemaLocation", self.context.namespaces)
        node.attrib[schema_location_ns] = "%s %s" % (
            self.context.namespaces["soapenv"],
            self.context.namespaces["soapenv"],
        )

        node2 = etree.SubElement(node, util.nspath_eval("soapenv:Body", self.context.namespaces))

        if self.exception:
            node3 = etree.SubElement(node2, util.nspath_eval("soapenv:Fault", self.context.namespaces))
            node4 = etree.SubElement(node3, util.nspath_eval("soapenv:Code", self.context.namespaces))

            etree.SubElement(node4, util.nspath_eval("soapenv:Value", self.context.namespaces)).text = "soap:Server"

            node4 = etree.SubElement(node3, util.nspath_eval("soapenv:Reason", self.context.namespaces))

            etree.SubElement(
                node4, util.nspath_eval("soapenv:Text", self.context.namespaces)
            ).text = "A server exception was encountered."

            node4 = etree.SubElement(node3, util.nspath_eval("soapenv:Detail", self.context.namespaces))
            node4.append(self.response)
        else:
            node2.append(self.response)

        self.response = node
开发者ID:SNIMar-WP4,项目名称:pycsw,代码行数:33,代码来源:server.py


示例9: _gen_soap_wrapper

    def _gen_soap_wrapper(self):
        ''' Generate SOAP wrapper '''
        LOGGER.debug('Writing SOAP wrapper.')
        node = etree.Element(util.nspath_eval('soapenv:Envelope',
        self.context.namespaces), nsmap=self.context.namespaces)

        node.attrib[util.nspath_eval('xsi:schemaLocation',
        self.context.namespaces)] = '%s %s' % \
        (self.context.namespaces['soapenv'], self.context.namespaces['soapenv'])

        node2 = etree.SubElement(node, util.nspath_eval('soapenv:Body',
        self.context.namespaces))

        if self.exception:
            node3 = etree.SubElement(node2, util.nspath_eval('soapenv:Fault',
                    self.context.namespaces))
            node4 = etree.SubElement(node3, util.nspath_eval('soapenv:Code',
                    self.context.namespaces))

            etree.SubElement(node4, util.nspath_eval('soapenv:Value',
            self.context.namespaces)).text = 'soap:Server'

            node4 = etree.SubElement(node3, util.nspath_eval('soapenv:Reason',
                    self.context.namespaces))

            etree.SubElement(node4, util.nspath_eval('soapenv:Text',
            self.context.namespaces)).text = 'A server exception was encountered.'

            node4 = etree.SubElement(node3, util.nspath_eval('soapenv:Detail',
                    self.context.namespaces))
            node4.append(self.response)
        else:
            node2.append(self.response)

        self.response = node
开发者ID:bstroebl,项目名称:pycsw,代码行数:35,代码来源:server.py


示例10: _write_date

def _write_date(dateval, datetypeval, nsmap):
    date1 = etree.Element(util.nspath_eval('gmd:date', nsmap))
    date2 = etree.SubElement(date1, util.nspath_eval('gmd:CI_Date', nsmap))
    date3 = etree.SubElement(date2, util.nspath_eval('gmd:date', nsmap))
    if dateval.find('T') != -1:
        dateel = 'gco:DateTime'
    else:
        dateel = 'gco:Date'
    etree.SubElement(date3, util.nspath_eval(dateel, nsmap)).text = dateval
    datetype = etree.SubElement(date2, util.nspath_eval('gmd:dateType', nsmap))
    datetype.append(_write_codelist_element('gmd:CI_DateTypeCode', datetypeval, nsmap))
    return date1
开发者ID:SNIMar-WP4,项目名称:pycsw,代码行数:12,代码来源:apiso.py


示例11: write_extent

def write_extent(bbox, nsmap):
    ''' Generate BBOX extent '''
    
    if bbox is not None:
        try:
            bbox2 = util.wkt2geom(bbox)
        except:
            return None
        bounding_box = etree.Element(util.nspath_eval('gm03:GM03_2_1Core.Core.EX_GeographicBoundingBox', NAMESPACES))
        etree.SubElement(bounding_box, util.nspath_eval('gm03:northBoundLatitude', nsmap)).text = str(bbox2[3])
        etree.SubElement(bounding_box, util.nspath_eval('gm03:southBoundLatitude', nsmap)).text = str(bbox2[1])
        etree.SubElement(bounding_box, util.nspath_eval('gm03:eastBoundLongitude', nsmap)).text = str(bbox2[0])
        etree.SubElement(bounding_box, util.nspath_eval('gm03:westBoundLongitude', nsmap)).text = str(bbox2[2])
        return bounding_box
    return None
开发者ID:raymondnijssen,项目名称:pycsw,代码行数:15,代码来源:gm03.py


示例12: write_extent

def write_extent(bbox, nsmap):
    ''' Generate BBOX extent '''

    if bbox is not None:
        try:
            bbox2 = util.wkt2geom(bbox)
        except:
            return None
        where = etree.Element(util.nspath_eval('georss:where', NAMESPACES))
        envelope = etree.SubElement(where, util.nspath_eval('gml:Envelope', nsmap), srsName='http://www.opengis.net/def/crs/EPSG/0/4326')
        etree.SubElement(envelope, util.nspath_eval('gml:lowerCorner', nsmap)).text = '%s %s' % (bbox2[1], bbox2[0])
        etree.SubElement(envelope, util.nspath_eval('gml:upperCorner', nsmap)).text = '%s %s' % (bbox2[3], bbox2[2])

        return where
    return None
开发者ID:GSA,项目名称:pycsw,代码行数:15,代码来源:atom.py


示例13: write_extent

def write_extent(bbox, nsmap):
    ''' Generate BBOX extent '''

    from shapely.wkt import loads

    if bbox is not None:
        try:
            bbox2 = util.wkt2geom(bbox)
        except:
            return None
        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
开发者ID:GSA,项目名称:pycsw,代码行数:17,代码来源:dif.py


示例14: test_nspath_eval

def test_nspath_eval(xpath_expression, expected):
    nsmap = {
        "ns1": "something",
        "ns2": "other",
        "ns3": "another",
    }
    result = util.nspath_eval(xpath_expression, nsmap)
    assert result == expected
开发者ID:PublicaMundi,项目名称:pycsw,代码行数:8,代码来源:test_util.py


示例15: cql2fes1

def cql2fes1(cql, namespaces):
    """transforms Common Query Language (CQL) query into OGC fes1 syntax"""

    filters = []
    tmp_list = []
    logical_op = None

    LOGGER.debug('CQL: %s', cql)

    if ' or ' in cql:
        logical_op = etree.Element(util.nspath_eval('ogc:Or', namespaces))
        tmp_list = cql.split(' or ')
    elif ' OR ' in cql:
        logical_op = etree.Element(util.nspath_eval('ogc:Or', namespaces))
        tmp_list = cql.split(' OR ')
    elif ' and ' in cql:
        logical_op = etree.Element(util.nspath_eval('ogc:And', namespaces))
        tmp_list = cql.split(' and ')
    elif ' AND ' in cql:
        logical_op = etree.Element(util.nspath_eval('ogc:And', namespaces))
        tmp_list = cql.split(' AND ')

    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))

    return root
开发者ID:PublicaMundi,项目名称:pycsw,代码行数:55,代码来源:cql.py


示例16: _csw2_2_os

    def _csw2_2_os(self):
        """CSW 2.0.2 Capabilities to OpenSearch Description"""

        if util.xmltag_split(self.exml.tag) == 'GetRecordsResponse':

            startindex = int(self.exml.xpath('//@nextRecord')[0]) - int(
                        self.exml.xpath('//@numberOfRecordsReturned')[0])
            if startindex < 1:
                startindex = 1

            node = etree.Element(util.nspath_eval('atom:feed',
                       self.context.namespaces), nsmap=self.namespaces)
            etree.SubElement(node, util.nspath_eval('atom:id',
                       self.context.namespaces)).text = self.cfg.get('server', 'url')
            etree.SubElement(node, util.nspath_eval('atom:title',
                       self.context.namespaces)).text = self.cfg.get('metadata:main',
                       'identification_title')
            #etree.SubElement(node, util.nspath_eval('atom:updated',
            #  self.context.namespaces)).text = self.exml.xpath('//@timestamp')[0]

            etree.SubElement(node, util.nspath_eval('os:totalResults',
                        self.context.namespaces)).text = self.exml.xpath(
                        '//@numberOfRecordsMatched')[0]
            etree.SubElement(node, util.nspath_eval('os:startIndex',
                        self.context.namespaces)).text = str(startindex)
            etree.SubElement(node, util.nspath_eval('os:itemsPerPage',
                        self.context.namespaces)).text = self.exml.xpath(
                        '//@numberOfRecordsReturned')[0]

            for rec in self.exml.xpath('//atom:entry',
                        namespaces=self.context.namespaces):
                node.append(rec)
        elif util.xmltag_split(self.exml.tag) == 'Capabilities':
            node = etree.Element('OpenSearchDescription', nsmap=self.namespaces)
            etree.SubElement(node, 'ShortName').text = self.exml.xpath('//ows:Title', namespaces=self.context.namespaces)[0].text
            etree.SubElement(node, 'LongName').text = self.exml.xpath('//ows:Title', namespaces=self.context.namespaces)[0].text
            etree.SubElement(node, 'Description').text = self.exml.xpath('//ows:Abstract', namespaces=self.context.namespaces)[0].text
            etree.SubElement(node, 'Tags').text = ' '.join(x.text for x in self.exml.xpath('//ows:Keyword', namespaces=self.context.namespaces))

            node1 = etree.SubElement(node, 'Url')
            node1.set('type', 'application/atom+xml')
            node1.set('method', 'get')
            node1.set('template', '%smode=opensearch&service=CSW&version=2.0.2&request=GetRecords&elementsetname=full&typenames=csw:Record&resulttype=results&q={searchTerms?}&bbox={geo:box?}&time={time:start?}/{time:end?}' % self.bind_url)

            node1 = etree.SubElement(node, 'Image')
            node1.set('type', 'image/vnd.microsoft.icon')
            node1.set('width', '16')
            node1.set('height', '16')
            node1.text = 'http://pycsw.org/img/favicon.ico'

            etree.SubElement(node, 'Developer').text = self.exml.xpath('//ows:IndividualName', namespaces=self.context.namespaces)[0].text
            etree.SubElement(node, 'Contact').text = self.exml.xpath('//ows:ElectronicMailAddress', namespaces=self.context.namespaces)[0].text
            etree.SubElement(node, 'Attribution').text = self.exml.xpath('//ows:ProviderName', namespaces=self.context.namespaces)[0].text
        elif util.xmltag_split(self.exml.tag) == 'ExceptionReport':
            node = self.exml
        else:  # return Description document
            node = etree.Element(util.nspath_eval('os:Description', self.context.namespaces))

        return node
开发者ID:SNIMar-WP4,项目名称:pycsw,代码行数:59,代码来源:opensearch.py


示例17: _write_codelist_element

def _write_codelist_element(codelist_element, codelist_value, nsmap):
    namespace, codelist = codelist_element.split(':')    

    element = etree.Element(util.nspath_eval(codelist_element, nsmap),
    codeSpace=CODESPACE, codeList='%s#%s' % (CODELIST, codelist),
    codeListValue=codelist_value)

    element.text = codelist_value

    return element
开发者ID:SNIMar-WP4,项目名称:pycsw,代码行数:10,代码来源:apiso.py


示例18: _get_linestring

    def _get_linestring(self):
        """Parse gml:LineString"""

        tmp = self._exml.find(util.nspath_eval('gml:LineString/gml:posList',
                                               self.nsmap))

        if tmp is None:
            raise RuntimeError('Invalid gml:LineString geometry.\
                               Missing gml:posList')
        else:
            self.wkt = 'LINESTRING(%s)' % _poslist2wkt(tmp.text,
                                                       self.crs.axisorder)
开发者ID:meilinger,项目名称:pycsw,代码行数:12,代码来源:gml3.py


示例19: _get_polygon

    def _get_polygon(self):
        """Parse gml:Polygon"""

        tmp = self._exml.find('.//%s' % util.nspath_eval('gml:posList',
                                                         self.nsmap))

        if tmp is None:
            raise RuntimeError('Invalid gml:LineString geometry.\
                               Missing gml:posList')
        else:
            self.wkt = 'POLYGON((%s))' % _poslist2wkt(tmp.text,
                                                      self.crs.axisorder)
开发者ID:meilinger,项目名称:pycsw,代码行数:12,代码来源:gml3.py


示例20: _get_point

    def _get_point(self):
        """Parse gml:Point"""

        tmp = self._exml.find(util.nspath_eval('gml:Point/gml:pos',
                                               self.nsmap))

        if tmp is None:
            raise RuntimeError('Invalid gml:Point geometry.  Missing gml:pos')
        else:
            xypoint = tmp.text.split()
            if self.crs.axisorder == 'yx':
                self.wkt = 'POINT(%s %s)' % (xypoint[1], xypoint[0])
            else:
                self.wkt = 'POINT(%s %s)' % (xypoint[0], xypoint[1])
开发者ID:meilinger,项目名称:pycsw,代码行数:14,代码来源:gml3.py



注:本文中的pycsw.core.util.nspath_eval函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.bbox2wktpolygon函数代码示例发布时间:2022-05-25
下一篇:
Python pycryptsetup.CryptSetup类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap