[Git][debian-gis-team/pywps][upstream] New upstream version 4.2.9

Bas Couwenberg gitlab at salsa.debian.org
Sat Dec 12 06:25:05 GMT 2020



Bas Couwenberg pushed to branch upstream at Debian GIS Project / pywps


Commits:
63f29e3b by Bas Couwenberg at 2020-12-12T07:14:59+01:00
New upstream version 4.2.9
- - - - -


10 changed files:

- VERSION.txt
- debian/changelog
- pywps/__init__.py
- pywps/app/Service.py
- pywps/app/WPSRequest.py
- pywps/inout/basic.py
- pywps/inout/inputs.py
- pywps/templates/1.0.0/execute/main.xml
- tests/test_execute.py
- tests/test_inout.py


Changes:

=====================================
VERSION.txt
=====================================
@@ -1 +1 @@
-4.2.8
+4.2.9


=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+pywps (4.2.9) trusty; urgency=medium
+
+  * fix bbox (#551, #552)
+  * fix CDATA tag in json serialisation (#555)
+
+ -- Carsten Ehbrecht <ehbrecht at dkrz.de>  Fri, 11 Dec 2020 18:00:00 +0000
+
 pywps (4.2.8) trusty; urgency=medium
 
   * update scheduler with drmaa config (#547).


=====================================
pywps/__init__.py
=====================================
@@ -9,7 +9,7 @@ import os
 
 from lxml.builder import ElementMaker
 
-__version__ = '4.2.8'
+__version__ = '4.2.9'
 
 LOGGER = logging.getLogger('PYWPS')
 LOGGER.debug('setting core variables')


=====================================
pywps/app/Service.py
=====================================
@@ -270,10 +270,12 @@ class Service(object):
 
         outinputs = deque(maxlen=source.max_occurs)
 
-        for datainput in inputs:
+        for inpt in inputs:
             newinpt = source.clone()
-            newinpt.data = [datainput.minx, datainput.miny,
-                            datainput.maxx, datainput.maxy]
+            newinpt.data = inpt.get('data')
+            LOGGER.debug(f'newinpt bbox data={newinpt.data}')
+            newinpt.crs = inpt.get('crs')
+            newinpt.dimensions = inpt.get('dimensions')
             outinputs.append(newinpt)
 
         if len(outinputs) < source.min_occurs:


=====================================
pywps/app/WPSRequest.py
=====================================
@@ -450,10 +450,15 @@ def get_inputs_from_xml(doc):
         bbox_datas = xpath_ns(input_el, './wps:Data/wps:BoundingBoxData')
         if bbox_datas:
             for bbox_data in bbox_datas:
-                bbox_data_el = bbox_data
-                bbox = BoundingBox(bbox_data_el)
-                the_inputs[identifier].append(bbox)
-                LOGGER.debug("parse bbox: {},{},{},{}".format(bbox.minx, bbox.miny, bbox.maxx, bbox.maxy))
+                bbox = BoundingBox(bbox_data)
+                LOGGER.debug("parse bbox: minx={}, miny={}, maxx={},maxy={}".format(
+                    bbox.minx, bbox.miny, bbox.maxx, bbox.maxy))
+                inpt = {}
+                inpt['identifier'] = identifier_el.text
+                inpt['data'] = [bbox.minx, bbox.miny, bbox.maxx, bbox.maxy]
+                inpt['crs'] = bbox.crs
+                inpt['dimensions'] = bbox.dimensions
+                the_inputs[identifier].append(inpt)
     return the_inputs
 
 


=====================================
pywps/inout/basic.py
=====================================
@@ -677,22 +677,34 @@ class BasicBoundingBox(object):
     """
 
     def __init__(self, crss=None, dimensions=2):
+        self._data = None
         self.crss = crss or ['epsg:4326']
         self.crs = self.crss[0]
         self.dimensions = dimensions
 
+    @property
+    def data(self):
+        return self._data
+
+    @data.setter
+    def data(self, value):
+        if isinstance(value, list):
+            self._data = [float(number) for number in value]
+        elif isinstance(value, str):
+            self._data = [float(number) for number in value.split(',')[:4]]
+        else:
+            self._data = None
+
     @property
     def ll(self):
-        data = getattr(self, 'data', None)
-        if data:
-            return data[:2]
+        if self.data:
+            return self.data[:2]
         return []
 
     @property
     def ur(self):
-        data = getattr(self, 'data', None)
-        if data:
-            return data[2:]
+        if self.data:
+            return self.data[2:]
         return []
 
 


=====================================
pywps/inout/inputs.py
=====================================
@@ -3,6 +3,7 @@
 # licensed under MIT, Please consult LICENSE.txt for details     #
 ##################################################################
 
+import re
 import lxml.etree as etree
 import six
 
@@ -14,6 +15,8 @@ from copy import deepcopy
 from pywps.validator.mode import MODE
 from pywps.inout.literaltypes import AnyValue, NoValue, ValuesReference, AllowedValue
 
+CDATA_PATTERN = re.compile(r'<!\[CDATA\[(.*?)\]\]>')
+
 
 class BoundingBoxInput(basic.BBoxInput):
 
@@ -214,7 +217,12 @@ class ComplexInput(basic.ComplexInput):
         elif json_input.get('href'):
             instance.url = json_input['href']
         elif json_input.get('data'):
-            instance.data = json_input['data']
+            data = json_input['data']
+            # remove cdata tag if it exists (issue #553)
+            match = CDATA_PATTERN.match(data)
+            if match:
+                data = match.group(1)
+            instance.data = data
 
         return instance
 


=====================================
pywps/templates/1.0.0/execute/main.xml
=====================================
@@ -48,17 +48,10 @@
 			</wps:Data>
             {% elif input.type == "bbox" %}
 			<wps:Data>
-                {% if input.crs == "EPSG:4326" %}
-                <ows:WGS84BoundingBox dimensions="{{ input.dimensions }}">
+                <wps:BoundingBoxData crs="{{ input.crs }}" dimensions="{{ input.dimensions }}">
                     <ows:LowerCorner>{% for c in input.ll %} {{ c }} {% endfor %}</ows:LowerCorner>
                     <ows:UpperCorner>{% for c in input.ur %} {{ c }} {% endfor %}</ows:UpperCorner>
-                </ows:WGS84BoundingBox>
-                {% else %}
-                <ows:BoundingBox crs="{{ input.crs }}" dimensions="{{ input.dimensions }}">
-                    <ows:LowerCorner>{% for c in input.ll %} {{ c }} {% endfor %}</ows:LowerCorner>
-                    <ows:UpperCorner>{% for c in input.ur %} {{ c }} {% endfor %}</ows:UpperCorner>
-                </ows:BoundingBox>
-                {% endif %}
+                </wps:BoundingBoxData>
 			</wps:Data>
             {% elif input.type == "reference" %}
             <wps:Reference xlink:href="{{ input.href }}" method="{{ input.method }}" mimeType="{{ input.mimetype }}" encoding="{{ input.encoding }}" schema="{{ input.schema }}"/>
@@ -102,17 +95,10 @@
 			</wps:Data>
             {% elif output.type == "bbox" %}
 			<wps:Data>
-                    {% if output.crs == "EPSG:4326" %}
-                    <ows:WGS84BoundingBox dimensions="{{ output.dimensions }}">
-                        <ows:LowerCorner>{% for c in output.ll %} {{ c }} {% endfor %}</ows:LowerCorner>
-                        <ows:UpperCorner>{% for c in output.ur %} {{ c }} {% endfor %}</ows:UpperCorner>
-                    </ows:WGS84BoundingBox>
-                    {% else %}
-                    <ows:BoundingBox crs="{{ output.crs }}" dimensions="{{ output.dimensions }}">
+                    <wps:BoundingBoxData crs="{{ output.crs }}" dimensions="{{ output.dimensions }}">
                         <ows:LowerCorner>{% for c in output.ll %} {{ c }} {% endfor %}</ows:LowerCorner>
                         <ows:UpperCorner>{% for c in output.ur %} {{ c }} {% endfor %}</ows:UpperCorner>
-                    </ows:BoundingBox>
-                    {% endif %}
+                    </wps:BoundingBoxData>
 			</wps:Data>
             {% endif %}
 		</wps:Output>


=====================================
tests/test_execute.py
=====================================
@@ -105,7 +105,7 @@ def create_bbox_process():
         coords = request.inputs['mybbox'][0].data
         assert isinstance(coords, list)
         assert len(coords) == 4
-        assert coords[0] == '15'
+        assert coords[0] == 15.0
         response.outputs['outbbox'].data = coords
         return response
 
@@ -459,8 +459,8 @@ class ExecuteTest(unittest.TestCase):
                 WPS.Input(
                     OWS.Identifier('mybbox'),
                     WPS.Data(WPS.BoundingBoxData(
-                        OWS.LowerCorner('15 50'),
-                        OWS.UpperCorner('16 51'),
+                        OWS.LowerCorner('15.0 50.0'),
+                        OWS.UpperCorner('16.0 51.0'),
                     ))
                 )
             ),
@@ -475,13 +475,13 @@ class ExecuteTest(unittest.TestCase):
             output,
             './ows:Identifier')[0].text)
 
-        lower_corner = xpath_ns(output, './wps:Data/ows:WGS84BoundingBox/ows:LowerCorner')[0].text
+        lower_corner = xpath_ns(output, './wps:Data/wps:BoundingBoxData/ows:LowerCorner')[0].text
         lower_corner = lower_corner.strip().replace('  ', ' ')
-        self.assertEqual('15 50', lower_corner)
+        self.assertEqual('15.0 50.0', lower_corner)
 
-        upper_corner = xpath_ns(output, './wps:Data/ows:WGS84BoundingBox/ows:UpperCorner')[0].text
+        upper_corner = xpath_ns(output, './wps:Data/wps:BoundingBoxData/ows:UpperCorner')[0].text
         upper_corner = upper_corner.strip().replace('  ', ' ')
-        self.assertEqual('16 51', upper_corner)
+        self.assertEqual('16.0 51.0', upper_corner)
 
     def test_output_response_dataType(self):
         client = client_for(Service(processes=[create_greeter()]))


=====================================
tests/test_inout.py
=====================================
@@ -288,9 +288,10 @@ class SerializationComplexInputTest(unittest.TestCase):
     def test_complex_input_data(self):
         complex = self.make_complex_input()
         complex.data = "some data"
+        # the data is enclosed by a CDATA tag in json
+        assert complex.json['data'] == '<![CDATA[some data]]>'
+        # dump to json and load it again
         complex2 = inout.inputs.ComplexInput.from_json(complex.json)
-        # the data is enclosed by a CDATA tag
-        complex._data = u'<![CDATA[{}]]>'.format(complex.data)
         # it's expected that the file path changed
         complex._file = complex2.file
 
@@ -299,14 +300,14 @@ class SerializationComplexInputTest(unittest.TestCase):
 
     def test_complex_input_stream(self):
         complex = self.make_complex_input()
-        complex.stream = StringIO("some data")
+        complex.stream = StringIO("{'name': 'test', 'input1': ']]'}")
+        # the data is enclosed by a CDATA tag in json
+        assert complex.json['data'] == "<![CDATA[{'name': 'test', 'input1': ']]'}]]>"
+        # dump to json and load it again
         complex2 = inout.inputs.ComplexInput.from_json(complex.json)
-
         # the serialized stream becomes a data type
         # we hard-code it for the testing comparison
         complex.prop = 'data'
-        # the data is enclosed by a CDATA tag
-        complex._data = u'<![CDATA[{}]]>'.format(complex.data)
         # it's expected that the file path changed
         complex._file = complex2.file
 
@@ -381,18 +382,18 @@ class SerializationBoundingBoxInputTest(unittest.TestCase):
 
     def make_bbox_input(self):
         bbox = inout.inputs.BoundingBoxInput(
-            identifier="complexinput",
-            title='MyComplex',
+            identifier="bbox",
+            title='BBox',
             crss=['epsg:3857', 'epsg:4326'],
             abstract="some description",
             keywords=['kw1', 'kw2'],
             dimensions=2,
             workdir=self.tmp_dir,
-            metadata=[Metadata("special data")],
+            metadata=[Metadata("bbox")],
             min_occurs=2,
             max_occurs=5,
             mode=MODE.NONE,
-            default="something else",
+            default="0,50,20,70",
             default_type=SOURCE_TYPE.DATA,
         )
         bbox.as_reference = False
@@ -411,7 +412,6 @@ class SerializationBoundingBoxInputTest(unittest.TestCase):
         self.assertEqual(bbox_1.max_occurs, bbox_2.max_occurs)
         self.assertEqual(bbox_1.valid_mode, bbox_2.valid_mode)
         self.assertEqual(bbox_1.as_reference, bbox_2.as_reference)
-
         self.assertEqual(bbox_1.ll, bbox_2.ll)
         self.assertEqual(bbox_1.ur, bbox_2.ur)
 
@@ -683,8 +683,8 @@ class LiteralOutputTest(unittest.TestCase):
     def setUp(self):
 
         self.literal_output = inout.outputs.LiteralOutput(
-            "literaloutput", 
-            data_type="integer", 
+            "literaloutput",
+            data_type="integer",
             title="Literal Output",
             translations={"fr-CA": {"title": "Mon output", "abstract": "Une description"}},
         )
@@ -715,8 +715,8 @@ class BBoxInputTest(unittest.TestCase):
     def setUp(self):
 
         self.bbox_input = inout.inputs.BoundingBoxInput(
-            "bboxinput", 
-            title="BBox input", 
+            "bboxinput",
+            title="BBox input",
             dimensions=2,
             translations={"fr-CA": {"title": "Mon input", "abstract": "Une description"}},
         )



View it on GitLab: https://salsa.debian.org/debian-gis-team/pywps/-/commit/63f29e3ba717d71f892885d23d76d4941926533d

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/pywps/-/commit/63f29e3ba717d71f892885d23d76d4941926533d
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20201212/8a6acfce/attachment-0001.html>


More information about the Pkg-grass-devel mailing list