예제 #1
0
class ExtensibleElement(WsdlElement):
    """
    :param extended:
    """

    extended: List[object] = array_any_element()

    @property
    def extended_elements(self) -> Iterator[AnyElement]:
        yield from (ext for ext in self.extended
                    if isinstance(ext, AnyElement))
예제 #2
0
class Appinfo(ElementBase):
    """
    Model representation of a schema xs:appinfo element.

    :param lang: language
    :param source: anyURI
    :param attributes: any attributes with non-schema namespace
    """
    class Meta:
        mixed = True

    source: Optional[str] = attribute()
    elements: Array[object] = array_any_element()
    any_attribute: Optional["AnyAttribute"] = element(name="anyAttribute")
예제 #3
0
class Documentation(ElementBase):
    """
    Model representation of a schema xs:documentation element.

    :param lang: language
    :param source: anyURI
    :param elements: ({any})*
    :param attributes: any attributes with non-schema namespace
    """

    lang: Optional[str] = attribute()
    source: Optional[str] = attribute()
    elements: Array[object] = array_any_element(mixed=True)
    attributes: Optional["AnyAttribute"] = element()

    def tostring(self) -> Optional[str]:
        xml = docstring_serializer.render(Docstring(self.elements)).split(
            "\n", 1)
        return textwrap.dedent(clean_html(xml[1])[5:-7]).strip()
예제 #4
0
class Documentation(ElementBase):
    """
    Model representation of a schema xs:documentation element.

    :param lang: language
    :param source: anyURI
    :param elements: ({any})*
    :param attributes: any attributes with non-schema namespace
    """

    lang: Optional[str] = attribute()
    source: Optional[str] = attribute()
    elements: Array[object] = array_any_element(mixed=True)
    attributes: Optional["AnyAttribute"] = element()

    def tostring(self) -> Optional[str]:
        obj = Docstring(self.elements)
        ns_map = {None: "http://www.w3.org/1999/xhtml"}
        xml = docstring_serializer.render(obj, ns_map=ns_map)
        start = xml.find(">") + 1
        end = xml.rfind("<")
        return textwrap.dedent(xml[start:end]).strip()
예제 #5
0
class Documentation:
    """
    :params elements:
    """

    elements: List[object] = array_any_element()
예제 #6
0
class Restriction(AnnotationBase):
    """
    Model representation of a schema xs:restriction element.

    :param base: QName
    :param group:
    :param all:
    :param choice:
    :param sequence:
    :param open_content:
    :param attributes:
    :param attribute_groups:
    :param enumerations:
    :param asserts:
    :param assertions:
    :param any_element:
    :param min_exclusive:
    :param min_inclusive:
    :param min_length:
    :param max_exclusive:
    :param max_inclusive:
    :param max_length:
    :param total_digits:
    :param fraction_digits:
    :param length:
    :param white_space:
    :param patterns:
    :param explicit_timezone:
    :param simple_type:
    """

    base: Optional[str] = attribute()
    group: Optional[Group] = element()
    all: Optional[All] = element()
    choice: Optional[Choice] = element()
    sequence: Optional[Sequence] = element()
    open_content: Optional[OpenContent] = element(name="openContent")
    attributes: Array[Attribute] = array_element(name="attribute")
    attribute_groups: Array[AttributeGroup] = array_element(
        name="attributeGroup")
    enumerations: Array[Enumeration] = array_element(name="enumeration")
    asserts: Array[Assertion] = array_element(name="assert")
    assertions: Array[Assertion] = array_element(name="assertion")
    any_element: Array[object] = array_any_element()
    min_exclusive: Optional[MinExclusive] = element(name="minExclusive")
    min_inclusive: Optional[MinInclusive] = element(name="minInclusive")
    min_length: Optional[MinLength] = element(name="minLength")
    max_exclusive: Optional[MaxExclusive] = element(name="maxExclusive")
    max_inclusive: Optional[MaxInclusive] = element(name="maxInclusive")
    max_length: Optional[MaxLength] = element(name="maxLength")
    total_digits: Optional[TotalDigits] = element(name="totalDigits")
    fraction_digits: Optional[FractionDigits] = element(name="fractionDigits")
    length: Optional[Length] = element()
    white_space: Optional[WhiteSpace] = element(name="whiteSpace")
    patterns: Array[Pattern] = array_element(name="pattern")
    explicit_timezone: Optional[ExplicitTimezone] = element(
        name="explicitTimezone")
    simple_type: Optional[SimpleType] = element(name="simpleType")

    @property
    def real_type(self) -> str:
        if self.simple_type:
            return self.simple_type.real_type
        if self.enumerations:
            return ""
        if self.base:
            return self.base

        return ""

    @property
    def real_name(self) -> str:
        return "value"

    @property
    def extensions(self) -> Iterator[str]:
        if self.base:
            yield self.base

    def get_restrictions(self) -> Dict[str, Anything]:
        restrictions = {}
        if self.simple_type:
            restrictions.update(self.simple_type.get_restrictions())

        keys = (
            "min_exclusive",
            "min_inclusive",
            "min_length",
            "max_exclusive",
            "max_inclusive",
            "max_length",
            "total_digits",
            "fraction_digits",
            "length",
            "white_space",
            "explicit_timezone",
        )
        restrictions.update({
            key: getattr(self, key).value
            for key in keys if getattr(self, key) is not None
        })

        if self.patterns:
            restrictions["pattern"] = "|".join(
                [pattern.value for pattern in self.patterns])

        if self.base and self.base in self.token_types:
            restrictions["tokens"] = True

        return restrictions
예제 #7
0
class Docstring:
    elements: Array[object] = array_any_element()
예제 #8
0
class Docstring:
    class Meta:
        namespace = "http://www.w3.org/1999/xhtml"

    elements: Array[object] = array_any_element()