ows package¶
Subpackages¶
- ows.cis package
- ows.common package
- ows.gml package
- ows.swe package
- ows.wcs package
- Subpackages
- Submodules
- ows.wcs.types module
- ows.wms package
- ows.wps package
Submodules¶
ows.decoder module¶
This module provides base functionality for any other decoder class.
-
class
ows.decoder.BaseDecoder[source]¶ Bases:
object-
collect_params()[source]¶ Collect all parameters. This will collect all values which are computed using properties.
-
create_object(params: dict)[source]¶ Create the associated object for that decoder using the passed parameters.
-
object_class= None¶
-
-
class
ows.decoder.BaseParameter(type=None, num=1, default=<class 'ows.decoder.NO_DEFAULT'>, default_factory=None)[source]¶ Bases:
propertyAbstract base class for XML, KVP or any other kind of parameter.
-
locator¶
-
-
class
ows.decoder.Choice(*choices)[source]¶ Bases:
objectTries all given choices until one does return something.
-
class
ows.decoder.Concatenate(*choices, **kwargs)[source]¶ Bases:
objectHelper to concatenate the results of all sub-parameters to one.
-
exception
ows.decoder.DecodingException(message, locator=None)[source]¶ Bases:
ExceptionBase Exception class to be thrown whenever a decoding failed.
-
exception
ows.decoder.InvalidParameterException(message, locator=None)[source]¶ Bases:
ows.decoder.DecodingException-
code= 'InvalidParameterValue'¶
-
-
exception
ows.decoder.MissingParameterException(locator)[source]¶ Bases:
ows.decoder.DecodingExceptionException to be thrown, when a decoder could not read one parameter, where exactly one was required.
-
code= 'MissingParameterValue'¶
-
-
exception
ows.decoder.MissingParameterMultipleException(locator)[source]¶ Bases:
ows.decoder.DecodingExceptionException to be thrown, when a decoder could not read at least one parameter, where one ore more were required.
-
code= 'MissingParameterValue'¶
-
-
exception
ows.decoder.WrongMultiplicityException(locator, expected, result)[source]¶ Bases:
ows.decoder.DecodingExceptionDecoding Exception to be thrown when the multiplicity of a parameter did not match the expected count.
-
code= 'InvalidParameterValue'¶
-
-
class
ows.decoder.enum(values, case_sensitive=True)[source]¶ Bases:
objectHelper for parameters that are expected to be in a certain enumeration. A ValueError is raised if not.
-
class
ows.decoder.fixed(value, case_sensitive=True)[source]¶ Bases:
objectHelper for parameters that are expected to be have a fixed value and raises a ValueError if not.
-
ows.decoder.to_dict(decoder, dict_class=<class 'dict'>)[source]¶ Utility function to get a dictionary representation of the given decoder. This function invokes all decoder parameters and sets the dictionary fields accordingly
ows.exceptions module¶
-
exception
ows.exceptions.HTTPMethodNotAllowedError(msg, allowed_methods)[source]¶ Bases:
ExceptionThis exception is raised in case of a HTTP requires with unsupported HTTP method. This exception should always lead to the 405 Method not allowed HTTP error.
The constructor takes two arguments, the error message
mgsand the list of the accepted HTTP methodsallowed_methods.
-
exception
ows.exceptions.InvalidRequestException(msg, code=None, locator=None)[source]¶ Bases:
ExceptionThis exception indicates that the request was invalid and an exception report shall be returned to the client.
The constructor takes three arguments, namely
msg, the error message,code, the error code, andlocator, which is needed in OWS exception reports for indicating which part of the request produced the error.How exactly the exception reports are constructed is not defined by the exception, but by exception handlers.
-
exception
ows.exceptions.OperationNotSupportedException(message, operation=None)[source]¶ Bases:
ExceptionException to be thrown when some operations are not supported or disabled.
-
code= 'OperationNotSupported'¶
-
locator¶
-
-
exception
ows.exceptions.ServiceNotSupportedException(service)[source]¶ Bases:
ows.exceptions.OperationNotSupportedExceptionException to be thrown when a specific OWS service is not enabled.
ows.kvp module¶
This module contains facilities to help decoding KVP strings.
-
class
ows.kvp.Decoder(params)[source]¶ Bases:
ows.decoder.BaseDecoderBase class for KVP decoders.
Parameters: params – an instance of either dict,django.http.QueryDictorbasestring(which will be parsed usingcgi.parse_qs())Decoders should be used as such:
from ows import kvp, typelist class ExampleDecoder(kvp.Decoder): mandatory_param = kvp.Parameter(num=1) list_param = kvp.Parameter(type=typelist(separator=",")) multiple_param = kvp.Parameter("multi", num="+") optional_param = kvp.Parameter(num="?", default="default_value") decoder = ExampleDecoder( "mandatory_param=value" "&list_param=a,b,c" "&multi=a&multi=b&multi=c" ) print(decoder.mandatory_param) print(decoder.list_param) print(decoder.multiple_param) print(decoder.optional_param)
-
class
ows.kvp.DecoderMetaclass(name, bases, dct)[source]¶ Bases:
typeMetaclass for KVP Decoders to allow easy parameter declaration.
-
class
ows.kvp.MultiParameter(selector, num=1, default=None, locator=None)[source]¶ Bases:
ows.kvp.ParameterClass for selecting different KVP parameters at once.
Parameters: - selector – a function to determine if a key is used for the multi parameter selection
- num – defines how many times the key can be present; use any numeric value to set it to a fixed count, “*” for any number, “?” for zero or one time or “+” for one or more times
- default – the default value
- locator – override the locator in case of exceptions
-
class
ows.kvp.Parameter(key=None, type=None, num=1, default=<class 'ows.decoder.NO_DEFAULT'>, default_factory=None, locator=None)[source]¶ Bases:
ows.decoder.BaseParameterParameter for KVP values.
Parameters: - key – the lookup key; defaults to the property name of the
Decoder - type – the type to parse the raw value; by default the raw string is returned
- num – defines how many times the key can be present; use any numeric value to set it to a fixed count, “*” for any number, “?” for zero or one time or “+” for one or more times
- default – the default value
- default_factory – the default value factory
- locator – override the locator in case of exceptions
-
key= None¶
-
locator¶
- key – the lookup key; defaults to the property name of the
ows.registry module¶
ows.test module¶
ows.test_util module¶
ows.util module¶
-
class
ows.util.Result(value: Any, content_type: str = None)[source]¶ Bases:
object-
content_type= None¶
-
-
class
ows.util.Version(major: int, minor: int, patch: int = None)[source]¶ Bases:
object-
patch= None¶
-
-
ows.util.duration(td: datetime.timedelta) → str[source]¶ Encode a timedelta as an ISO 8601 duration string.
-
ows.util.isoformat(temporal: Union[datetime.datetime, datetime.date, ows.util.month, ows.util.year], zulu=True) → str[source]¶ Formats a datetime, date, month or year object to an ISO string. Timezone naive datetimes are treated as UTC Zulu. UTC Zulu is expressed with the proper ‘Z’ ending and not with the ‘+00:00’ offset declaration.
Parameters: Returns: an encoded string
-
class
ows.util.month(year: int, month: int)[source]¶ Bases:
object-
max= month(year=9999, month=12)¶
-
min= month(year=1, month=1)¶
-
-
ows.util.parse_temporal(value: str) → Union[datetime.datetime, datetime.date, ows.util.month, ows.util.year][source]¶ Parses a temporal value to either a datetime, date, month or year construct. Valid values are either
-
ows.util.temporal_bounds(temporal: Union[datetime.datetime, datetime.date, ows.util.month, ows.util.year]) → Tuple[datetime.datetime, datetime.datetime][source]¶ Calculates the effective temporal bounds of the passed temporal value.
ows.xml module¶
This module contains facilities to help decoding XML structures.
-
class
ows.xml.Decoder(tree)[source]¶ Bases:
ows.decoder.BaseDecoderBase class for XML Decoders.
param params: an instance of either lxml.etree.ElementTree, orbasestring(which will be parsed usinglxml.etree.fromstring())Decoders should be used as such:
from ows import xml, typelist class ExampleDecoder(xml.Decoder): namespaces = {"myns": "http://myns.org"} single = xml.Parameter("myns:single/text()", num=1) items = xml.Parameter("myns:collection/myns:item/text()", num="+") attr_a = xml.Parameter("myns:object/@attrA", num="?") attr_b = xml.Parameter("myns:object/@attrB", num="?", default="x") decoder = ExampleDecoder(''' <myns:root xmlns:myns="http://myns.org"> <myns:single>value</myns:single> <myns:collection> <myns:item>a</myns:item> <myns:item>b</myns:item> <myns:item>c</myns:item> </myns:collection> <myns:object attrA="value"/> </myns:root> ''') print(decoder.single) print(decoder.items) print(decoder.attr_a) print(decoder.attr_b)
-
namespaces= {}¶
-
-
class
ows.xml.ElementMaker[source]¶ Bases:
lxml.builder.ElementMakerSubclass of the original ElementMaker that automatically filters out None values in sub-elements and attributes.
-
class
ows.xml.NameSpace(uri: str, prefix=None, schema_location=None)[source]¶ Bases:
objectHelper object to ease the dealing with namespaces in both encoding and decoding.
Parameters: - uri – the namespace URI
- prefix – the namespace prefix
- schema_location – the schema location of this namespace
-
prefix¶
-
schema_location¶
-
uri¶
-
class
ows.xml.NameSpaceMap(*namespaces)[source]¶ Bases:
dictHelper object to ease the setup and management of namespace collections in both encoding and decoding. Can (and should) be passed as
namespacesattribute inows.xml.Decodersubclasses.Parameters: namespaces – a list of NameSpaceobjects.-
schema_locations¶
-
-
class
ows.xml.Parameter(selector, type=None, num=1, default=<class 'ows.decoder.NO_DEFAULT'>, default_factory=None, namespaces=None, locator=None)[source]¶ Bases:
ows.decoder.BaseParameterParameter for XML values.
Parameters: - selector – the node selector; if a string is passed it is interpreted as an XPath expression, a callable will be called with the root of the element tree and shall yield any number of node
- type – the type to parse the raw value; by default the raw string is returned
- num – defines how many times the key can be present; use any numeric value to set it to a fixed count, “*” for any number, “?” for zero or one time or “+” for one or more times
- default – the default value
- namespaces – any namespace necessary for the XPath expression;
defaults to the
Decodernamespaces. - locator – override the locator in case of exceptions
-
locator¶