-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Translation process. Configured language not recognized (#102)
* added Translation process for fr-CA and de-DE
- Loading branch information
Showing
8 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" | ||
Translation process to check WPS translations | ||
""" | ||
from pywps import Process, LiteralInput, LiteralOutput | ||
|
||
import logging | ||
LOGGER = logging.getLogger("PYWPS") | ||
|
||
|
||
class Translation(Process): | ||
def __init__(self): | ||
inputs = [ | ||
LiteralInput('input1', 'Input1 number', | ||
default='100', data_type='integer', | ||
translations={ | ||
"fr-CA": {"title": "Entrée #1", "abstract": "Entier #1"}, | ||
"de-DE": {"title": "Eingabe #1", "abstract": "Eingabe #1"}, | ||
}), | ||
] | ||
outputs = [ | ||
LiteralOutput('output1', 'Output1 add 1 result', | ||
data_type='string', | ||
translations={ | ||
"fr-CA": {"title": "Sortie #1", "abstract": "Chaîne de charactères"}, | ||
"de-DE": {"title": "Ausgabe #1", "abstract": "Ergebnis"} | ||
}), | ||
] | ||
|
||
super(Translation, self).__init__( | ||
self._handler, | ||
identifier='translation', | ||
title="Translated process", | ||
abstract="Process including translations in other languages.", | ||
version="1.0", | ||
inputs=inputs, | ||
outputs=outputs, | ||
store_supported=True, | ||
status_supported=True, | ||
keywords=["languages"], | ||
translations={ | ||
"fr-CA": {"title": "Processus traduit", | ||
"abstract": "Processus incluant des traductions", | ||
"keywords": ["langues"]}, | ||
"de-DE": {"title": "Mehrsprachiger Prozess", | ||
"abstract": "Prozess mit mehreren Sprachen.", | ||
"keywords": ["sprachen"]} | ||
} | ||
) | ||
|
||
@staticmethod | ||
def _handler(request, response): | ||
response.update_status('PyWPS Process started.', 0) | ||
|
||
LOGGER.debug("input1 %s", request.inputs['input1'][0].data) | ||
response.outputs['output1'].data = request.inputs['input1'][0].data + 1 | ||
|
||
response.update_status('PyWPS Process completed.', 100) | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pywps>=4.2.0<4.3 | ||
pywps>=4.2.4<4.3 | ||
jinja2 | ||
click | ||
psutil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[server] | ||
allowedinputpaths=/ | ||
language = en-US,fr-CA,de-DE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from pywps import Service | ||
from pywps.tests import assert_response_success | ||
|
||
from .common import client_for | ||
from emu.processes.wps_translation import Translation | ||
|
||
|
||
def test_wps_translation_describe_fr(): | ||
client = client_for(Service(processes=[Translation()])) | ||
resp = client.get( | ||
service='wps', request='DescribeProcess', version='1.0.0', | ||
identifier='translation', | ||
language="fr-CA") | ||
print(resp.data) | ||
title = resp.xpath_text( | ||
'/wps:ProcessDescriptions' | ||
'/ProcessDescription' | ||
'/ows:Title' | ||
) | ||
assert title == 'Processus traduit' | ||
|
||
|
||
def test_wps_translation_describe_de(): | ||
client = client_for(Service(processes=[Translation()])) | ||
resp = client.get( | ||
service='wps', request='DescribeProcess', version='1.0.0', | ||
identifier='translation', | ||
language="de-DE") | ||
print(resp.data) | ||
title = resp.xpath_text( | ||
'/wps:ProcessDescriptions' | ||
'/ProcessDescription' | ||
'/ows:Title' | ||
) | ||
assert title == 'Mehrsprachiger Prozess' | ||
|
||
|
||
def test_wps_translation_execute(): | ||
client = client_for(Service(processes=[Translation()])) | ||
datainputs = "input1=10" | ||
resp = client.get( | ||
service='wps', request='execute', version='1.0.0', | ||
identifier='translation', | ||
datainputs=datainputs, | ||
language="fr-CA") | ||
print(resp.data) | ||
assert_response_success(resp) | ||
|
||
outputs = list(resp.xpath('/wps:ExecuteResponse/wps:ProcessOutputs/wps:Output')[0]) | ||
assert outputs[1].text == "Sortie #1" |