Пример #1
0
def _encode_format(frmt):
    elem = NIL("Format", NIL("MimeType", frmt.mime_type))
    if frmt.encoding is not None:
        elem.append(NIL("Encoding", frmt.encoding))
    if frmt.schema is not None:
        elem.append(NIL("Schema", frmt.schema))
    return elem
Пример #2
0
def _encode_format(frmt):
    """ Encode process description ComplexData format definition.
    The function returns Format element.
    """
    elem = NIL("Format", NIL("MimeType", frmt.mime_type))
    if frmt.encoding is not None:
        elem.append(NIL("Encoding", frmt.encoding))
    if frmt.schema is not None:
        elem.append(NIL("Schema", frmt.schema))
    return elem
Пример #3
0
def _encode_format(frmt):
    """ Encode process description ComplexData format definition.
    The function returns Format element.
    """
    elem = NIL("Format", NIL("MimeType", frmt.mime_type))
    if frmt.encoding is not None:
        elem.append(NIL("Encoding", frmt.encoding))
    if frmt.schema is not None:
        elem.append(NIL("Schema", frmt.schema))
    return elem
Пример #4
0
def _encode_literal(prm, is_input):
    """ Encode process description LiteralData (parameter definition) element.
    """
    dtype = prm.dtype
    elem = NIL("LiteralData" if is_input else "LiteralOutput")

    elem.append(
        OWS(
            "DataType", dtype.name, **{
                ns_ows("reference"):
                "http://www.w3.org/TR/xmlschema-2/#%s" % dtype.name,
            }))

    if prm.uoms:
        elem.append(
            NIL("UOMs", NIL("Default", OWS("UOM", prm.uoms[0])),
                NIL("Supported", *[OWS("UOM", u) for u in prm.uoms])))

    if is_input:
        elem.append(_encode_allowed_value(prm.allowed_values))

        if prm.default is not None:
            elem.append(NIL("DefaultValue", str(prm.default)))

    return elem
Пример #5
0
def encode_output_descr(prm):
    """ Encode process description Output element."""
    elem = NIL("Output", *_encode_param_common(prm))
    if isinstance(prm, LiteralData):
        elem.append(_encode_literal(prm, False))
    elif isinstance(prm, ComplexData):
        elem.append(_encode_complex(prm, False))
    elif isinstance(prm, BoundingBoxData):
        elem.append(_encode_bbox(prm, False))
    return elem
Пример #6
0
def encode_output_descr(prm):
    """ Encode process description Output element."""
    elem = NIL("Output", *_encode_param_common(prm))
    if isinstance(prm, LiteralData):
        elem.append(_encode_literal(prm, False))
    elif isinstance(prm, ComplexData):
        elem.append(_encode_complex(prm, False))
    elif isinstance(prm, BoundingBoxData):
        elem.append(_encode_bbox(prm, False))
    return elem
Пример #7
0
def encode_input_descr(prm):
    """ Encode process description input."""
    elem = NIL("Input", *_encode_param_common(prm))
    elem.attrib["minOccurs"] = ("1", "0")[bool(prm.is_optional)]
    elem.attrib["maxOccurs"] = "1"
    if isinstance(prm, LiteralData):
        elem.append(_encode_literal(prm, True))
    elif isinstance(prm, ComplexData):
        elem.append(_encode_complex(prm, True))
    elif isinstance(prm, BoundingBoxData):
        elem.append(_encode_bbox(prm, True))
    return elem
Пример #8
0
def _encode_literal(prm, is_input):
    dtype = prm.dtype
    elem = NIL("LiteralData" if is_input else "LiteralOutput")

    elem.append(OWS("DataType", dtype.name, **{
        ns_ows("reference"): "http://www.w3.org/TR/xmlschema-2/#%s"%dtype.name,
    }))

    if prm.uoms:
        elem.append(NIL("UOMs",
            NIL("Default", OWS("UOM", prm.uoms[0])),
            NIL("Supported", *[OWS("UOM", u) for u in prm.uoms])
        ))

    if is_input:
        elem.append(_encode_allowed_value(prm.allowed_values))

        if prm.default is not None:
            elem.append(NIL("DefaultValue", str(prm.default)))

    return elem
Пример #9
0
def encode_input_descr(prm):
    """ Encode process description Input element."""
    # Request input parameters are not visible from the process description.
    if isinstance(prm, RequestParameter):
        return None
    elem = NIL("Input", *_encode_param_common(prm))
    elem.attrib["minOccurs"] = ("1", "0")[bool(prm.is_optional)]
    elem.attrib["maxOccurs"] = "1"
    if isinstance(prm, LiteralData):
        elem.append(_encode_literal(prm, True))
    elif isinstance(prm, ComplexData):
        elem.append(_encode_complex(prm, True))
    elif isinstance(prm, BoundingBoxData):
        elem.append(_encode_bbox(prm, True))
    return elem
Пример #10
0
def encode_input_descr(prm):
    """ Encode process description Input element."""
    # Request input parameters are not visible from the process description.
    if isinstance(prm, RequestParameter):
        return None
    elem = NIL("Input", *_encode_param_common(prm))
    elem.attrib["minOccurs"] = ("1", "0")[bool(prm.is_optional)]
    elem.attrib["maxOccurs"] = "1"
    if isinstance(prm, LiteralData):
        elem.append(_encode_literal(prm, True))
    elif isinstance(prm, ComplexData):
        elem.append(_encode_complex(prm, True))
    elif isinstance(prm, BoundingBoxData):
        elem.append(_encode_bbox(prm, True))
    return elem