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:
property
Abstract base class for XML, KVP or any other kind of parameter.
-
locator
¶
-
-
class
ows.decoder.
Choice
(*choices)[source]¶ Bases:
object
Tries all given choices until one does return something.
-
class
ows.decoder.
Concatenate
(*choices, **kwargs)[source]¶ Bases:
object
Helper to concatenate the results of all sub-parameters to one.
-
exception
ows.decoder.
DecodingException
(message, locator=None)[source]¶ Bases:
Exception
Base 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.DecodingException
Exception 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.DecodingException
Exception 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.DecodingException
Decoding 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:
object
Helper 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:
object
Helper 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:
Exception
This 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
mgs
and the list of the accepted HTTP methodsallowed_methods
.
-
exception
ows.exceptions.
InvalidRequestException
(msg, code=None, locator=None)[source]¶ Bases:
Exception
This 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:
Exception
Exception to be thrown when some operations are not supported or disabled.
-
code
= 'OperationNotSupported'¶
-
locator
¶
-
-
exception
ows.exceptions.
ServiceNotSupportedException
(service)[source]¶ Bases:
ows.exceptions.OperationNotSupportedException
Exception 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.BaseDecoder
Base class for KVP decoders.
Parameters: params – an instance of either dict
,django.http.QueryDict
orbasestring
(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:
type
Metaclass for KVP Decoders to allow easy parameter declaration.
-
class
ows.kvp.
MultiParameter
(selector, num=1, default=None, locator=None)[source]¶ Bases:
ows.kvp.Parameter
Class 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.BaseParameter
Parameter 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.BaseDecoder
Base 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.ElementMaker
Subclass 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:
object
Helper 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:
dict
Helper object to ease the setup and management of namespace collections in both encoding and decoding. Can (and should) be passed as
namespaces
attribute inows.xml.Decoder
subclasses.Parameters: namespaces – a list of NameSpace
objects.-
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.BaseParameter
Parameter 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
Decoder
namespaces. - locator – override the locator in case of exceptions
-
locator
¶