当前位置: 首页>>代码示例>>Python>>正文


Python util.nspath_eval函数代码示例

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


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


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