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
Exemple #2
0
 def test_literal_integer_input(self):
     literal = LiteralInput('foo', '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'
Exemple #3
0
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
Exemple #4
0
 def test_literal_integer_input(self):
     literal = LiteralInput('foo', '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'
Exemple #5
0
 def test_complex_input_default_and_supported(self):
     complex = ComplexInput('foo', [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, './ows: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, './ows:MimeType')
         supported_mime_types.append(mime_el.text)
     assert supported_mime_types == ['a/b', 'c/d']
Exemple #6
0
 def test_complex_input_default_and_supported(self):
     complex = ComplexInput('foo', [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, './ows: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, './ows:MimeType')
         supported_mime_types.append(mime_el.text)
     assert supported_mime_types == ['a/b', 'c/d']
Exemple #7
0
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 = []
        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))
    return result
Exemple #8
0
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 = []
        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))
    return result
Exemple #9
0
def feature_count(request, response):
    import lxml.etree
    from pywps.app import xpath_ns
    doc = lxml.etree.parse(request.inputs['layer'])
    feature_elements = xpath_ns(doc, '//gml:featureMember')
    response.outputs['count'] = str(len(feature_elements))
    return response
Exemple #10
0
def feature_count(request, response):
    import lxml.etree
    from pywps.app import xpath_ns
    doc = lxml.etree.parse(request.inputs['layer'])
    feature_elements = xpath_ns(doc, '//gml:featureMember')
    response.outputs['count'] =  str(len(feature_elements))
    return response
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'
                              '/wps:ProcessDescription'):
        [identifier_el] = xpath_ns(desc_el, './ows:Identifier')
        result.append((identifier_el.text,))
    return result
Exemple #12
0
 def test_complex_input_identifier(self):
     complex = ComplexInput('foo', [Format('bar/baz')])
     doc = complex.describe_xml()
     assert doc.tag == E.Input().tag
     [identifier_el] = xpath_ns(doc, './ows:Identifier')
     assert identifier_el.text == 'foo'
Exemple #13
0
 def test_complex_input_identifier(self):
     complex = ComplexInput('foo', [Format('bar/baz')])
     doc = complex.describe_xml()
     assert doc.tag == E.Input().tag
     [identifier_el] = xpath_ns(doc, './ows:Identifier')
     assert identifier_el.text == 'foo'