本文整理汇总了Python中pywps.app.basic.xpath_ns函数的典型用法代码示例。如果您正苦于以下问题:Python xpath_ns函数的具体用法?Python xpath_ns怎么用?Python xpath_ns使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xpath_ns函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bbox
def test_bbox(self):
if not PY2:
self.skipTest('OWSlib not python 3 compatible')
client = client_for(Service(processes=[create_bbox_process()]))
request_doc = WPS.Execute(
OWS.Identifier('my_bbox_process'),
WPS.DataInputs(
WPS.Input(
OWS.Identifier('mybbox'),
WPS.Data(WPS.BoundingBoxData(
OWS.LowerCorner('15 50'),
OWS.UpperCorner('16 51'),
))
)
),
version='1.0.0'
)
resp = client.post_xml(doc=request_doc)
assert_response_success(resp)
[output] = xpath_ns(resp.xml, '/wps:ExecuteResponse'
'/wps:ProcessOutputs/Output')
self.assertEqual('outbbox', xpath_ns(output,
'./ows:Identifier')[0].text)
self.assertEqual('15 50', xpath_ns(output,
'./ows:BoundingBox/ows:LowerCorner')[0].text)
示例2: parse_post_execute
def parse_post_execute(doc):
"""Parse POST Execute request
"""
version = doc.attrib.get('version')
wpsrequest.check_and_set_version(version)
wpsrequest.operation = 'execute'
wpsrequest.identifier = xpath_ns(doc, './ows:Identifier')[0].text
wpsrequest.lineage = 'false'
wpsrequest.store_execute = 'false'
wpsrequest.status = 'false'
wpsrequest.inputs = get_inputs_from_xml(doc)
wpsrequest.outputs = get_output_from_xml(doc)
wpsrequest.raw = False
if xpath_ns(doc, '/wps:Execute/wps:ResponseForm/wps:RawDataOutput'):
wpsrequest.raw = True
# executeResponse XML will not be stored
wpsrequest.store_execute = 'false'
# check if response document tag has been set then retrieve
response_document = xpath_ns(doc, './wps:ResponseForm/wps:ResponseDocument')
if len(response_document) > 0:
wpsrequest.lineage = response_document[0].attrib.get('lineage', 'false')
wpsrequest.store_execute = response_document[0].attrib.get('storeExecuteResponse', 'false')
wpsrequest.status = response_document[0].attrib.get('status', 'false')
示例3: test_literal_allowed_values_input
def test_literal_allowed_values_input(self):
"""Test all around allowed_values
"""
literal = LiteralInput(
'foo',
'Foo',
data_type='integer',
uoms=['metre'],
allowed_values=(
1, 2, (5, 10), (12, 4, 24),
AllowedValue(
allowed_type=ALLOWEDVALUETYPE.RANGE,
minval=30,
maxval=33,
range_closure='closed-open')
)
)
doc = literal.describe_xml()
allowed_values = xpath_ns(doc, './LiteralData/ows:AllowedValues')
self.assertEqual(len(allowed_values), 1)
allowed_value = allowed_values[0]
values = xpath_ns(allowed_value, './ows:Value')
ranges = xpath_ns(allowed_value, './ows:Range')
self.assertEqual(len(values), 2)
self.assertEqual(len(ranges), 3)
示例4: test_format_class
def test_format_class(self):
"""Test pywps.formats.Format class
"""
frmt = Format('mimetype', schema='halloworld', encoding='asdf',
validate=self.validate)
self.assertEqual(frmt.mime_type, 'mimetype')
self.assertEqual(frmt.schema, 'halloworld')
self.assertEqual(frmt.encoding, 'asdf')
self.assertTrue(frmt.validate('the input', 1))
describeel = frmt.describe_xml()
self.assertEqual('Format', describeel.tag)
mimetype = xpath_ns(describeel, '/Format/MimeType')
encoding = xpath_ns(describeel, '/Format/Encoding')
schema = xpath_ns(describeel, '/Format/Schema')
self.assertTrue(mimetype)
self.assertTrue(encoding)
self.assertTrue(schema)
self.assertEqual(mimetype[0].text, 'mimetype')
self.assertEqual(encoding[0].text, 'asdf')
self.assertEqual(schema[0].text, 'halloworld')
frmt2 = get_format('GML')
self.assertFalse(frmt.same_as(frmt2))
示例5: get_output
def get_output(doc):
output = {}
for output_el in xpath_ns(doc, "/wps:ExecuteResponse" "/wps:ProcessOutputs/wps:Output"):
[identifier_el] = xpath_ns(output_el, "./ows:Identifier")
[value_el] = xpath_ns(output_el, "./wps:Data/wps:LiteralData")
output[identifier_el.text] = value_el.text
return output
示例6: test_complex_input_identifier
def test_complex_input_identifier(self):
complex_in = ComplexInput('foo', 'Complex foo', keywords=['kw1', 'kw2'], supported_formats=[Format('bar/baz')])
doc = complex_in.describe_xml()
self.assertEqual(doc.tag, E.Input().tag)
[identifier_el] = xpath_ns(doc, './ows:Identifier')
self.assertEqual(identifier_el.text, 'foo')
kws = xpath_ns(doc, './ows:Keywords/ows:Keyword')
self.assertEqual(len(kws), 2)
示例7: test_bbox_output
def test_bbox_output(self):
bbox = BoundingBoxOutput("bbox", "BBox foo", crss=["EPSG:4326"])
doc = bbox.describe_xml()
[outpt] = xpath_ns(doc, "/Output")
[default_crs] = xpath_ns(doc, "./BoundingBoxOutput/Default/CRS")
supported = xpath_ns(doc, "./BoundingBoxOutput/Supported/CRS")
assert default_crs.text == "EPSG:4326"
assert len(supported) == 1
示例8: test_literal_integer_input
def test_literal_integer_input(self):
literal = LiteralInput('foo', 'Literal foo', data_type='integer')
doc = literal.describe_xml()
assert doc.tag == E.Input().tag
[identifier_el] = xpath_ns(doc, './ows:Identifier')
assert identifier_el.text == 'foo'
[type_el] = xpath_ns(doc, './LiteralData/ows:DataType')
assert type_el.text == 'integer'
assert type_el.attrib['reference'] == XMLSCHEMA_2 + 'integer'
示例9: test_bbox_output
def test_bbox_output(self):
bbox = BoundingBoxOutput('bbox', 'BBox foo',
crss=["EPSG:4326"])
doc = bbox.describe_xml()
[outpt] = xpath_ns(doc, '/Output')
[default_crs] = xpath_ns(doc, './BoundingBoxOutput/Default/CRS')
supported = xpath_ns(doc, './BoundingBoxOutput/Supported/CRS')
assert default_crs.text == 'EPSG:4326'
assert len(supported) == 1
示例10: test_complex_output
def test_complex_output(self):
complexo = ComplexOutput("complex", "Complex foo", [Format("GML")])
doc = complexo.describe_xml()
[outpt] = xpath_ns(doc, "/Output")
[default] = xpath_ns(doc, "/Output/ComplexOutput/Default/Format/MimeType")
supported = xpath_ns(doc, "/Output/ComplexOutput/Supported/Format/MimeType")
assert default.text == "application/gml+xml"
assert len(supported) == 1
示例11: test_bbox_input
def test_bbox_input(self):
bbox = BoundingBoxInput("bbox", "BBox foo", crss=["EPSG:4326", "EPSG:3035"])
doc = bbox.describe_xml()
[inpt] = xpath_ns(doc, "/Input")
[default_crs] = xpath_ns(doc, "./BoundingBoxData/Default/CRS")
supported = xpath_ns(doc, "./BoundingBoxData/Supported/CRS")
assert inpt.attrib["minOccurs"] == "1"
assert default_crs.text == "EPSG:4326"
assert len(supported) == 2
示例12: test_complex_output
def test_complex_output(self):
complexo = ComplexOutput('complex', 'Complex foo', [Format('GML')])
doc = complexo.describe_xml()
[outpt] = xpath_ns(doc, '/Output')
[default] = xpath_ns(doc, '/Output/ComplexOutput/Default/Format/MimeType')
supported = xpath_ns(doc,
'/Output/ComplexOutput/Supported/Format/MimeType')
assert default.text == 'application/gml+xml'
assert len(supported) == 1
示例13: test_bbox_input
def test_bbox_input(self):
bbox = BoundingBoxInput('bbox', 'BBox foo',
crss=["EPSG:4326", "EPSG:3035"])
doc = bbox.describe_xml()
[inpt] = xpath_ns(doc, '/Input')
[default_crs] = xpath_ns(doc, './BoundingBoxData/Default/CRS')
supported = xpath_ns(doc, './BoundingBoxData/Supported/CRS')
self.assertEqual(inpt.attrib['minOccurs'], '1')
self.assertEqual(default_crs.text, 'EPSG:4326')
self.assertEqual(len(supported), 2)
示例14: get_describe_result
def get_describe_result(resp):
assert resp.status_code == 200
assert resp.headers['Content-Type'] == 'text/xml'
result = []
for desc_el in resp.xpath('/wps:ProcessDescriptions/ProcessDescription'):
[identifier_el] = xpath_ns(desc_el, './ows:Identifier')
inputs = []
metadata = []
for metadata_el in xpath_ns(desc_el, './ows:Metadata'):
metadata.append(metadata_el.attrib['{http://www.w3.org/1999/xlink}title'])
for input_el in xpath_ns(desc_el, './DataInputs/Input'):
[input_identifier_el] = xpath_ns(input_el, './ows:Identifier')
input_identifier = input_identifier_el.text
literal_data_el_list = xpath_ns(input_el, './LiteralData')
complex_data_el_list = xpath_ns(input_el, './ComplexData')
if literal_data_el_list:
[literal_data_el] = literal_data_el_list
[data_type_el] = xpath_ns(literal_data_el, './ows:DataType')
data_type = get_data_type(data_type_el)
inputs.append((input_identifier, 'literal', data_type))
elif complex_data_el_list:
[complex_data_el] = complex_data_el_list
formats = []
for format_el in xpath_ns(complex_data_el,
'./Supported/Format'):
[mimetype_el] = xpath_ns(format_el, './ows:MimeType')
formats.append({'mime_type': mimetype_el.text})
inputs.append((input_identifier, 'complex', formats))
else:
raise RuntimeError("Can't parse input description")
result.append(ProcessDescription(identifier_el.text, inputs, metadata))
return result
示例15: test_complex_input_default_and_supported
def test_complex_input_default_and_supported(self):
complex = ComplexInput('foo', 'Complex foo', allowed_formats=[Format('a/b'), Format('c/d')])
doc = complex.describe_xml()
[default_format] = xpath_ns(doc, './ComplexData/Default/Format')
[default_mime_el] = xpath_ns(default_format, './MimeType')
assert default_mime_el.text == 'a/b'
supported_mime_types = []
for supported_el in xpath_ns(doc, './ComplexData/Supported/Format'):
[mime_el] = xpath_ns(supported_el, './MimeType')
supported_mime_types.append(mime_el.text)
assert supported_mime_types == ['a/b', 'c/d']