"""
Verify that the instances of the meta-model satisfy the invariants.
Here is an example how to verify an instance of :py:class:`aas_core3_2.types.Extension`:
.. code-block::
import aas_core3_2.types as our_types
import aas_core3_2.verification as our_verification
an_instance = our_types.Extension(
# ... some constructor arguments ...
)
for error in our_verification.verify(an_instance):
print(f"{error.cause} at: {error.path}")
"""
# This code has been automatically generated by aas-core-codegen.
# Do NOT edit or append.
import collections.abc
import math
import re
import struct
import sys
from typing import (
Any,
Callable,
Iterable,
Iterator,
List,
Mapping,
Optional,
Pattern,
Sequence,
Set,
Tuple,
Union,
)
if sys.version_info >= (3, 8):
from typing import Final
else:
from typing_extensions import Final
from aas_core3_2 import (
common as our_common,
constants as our_constants,
reporting as our_reporting,
types as our_types,
)
import aas_core3_2.jsonvalueverification as our_json_value_verification
PropertySegment = our_reporting.PropertySegment
IndexSegment = our_reporting.IndexSegment
KeySegment = our_reporting.KeySegment
Segment = our_reporting.Segment
Path = our_reporting.Path
Error = our_reporting.Error
# noinspection SpellCheckingInspection
def _construct_matches_id_short() -> Pattern[str]:
pattern = "^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9_]+$"
return re.compile(pattern)
_REGEX_MATCHES_ID_SHORT = _construct_matches_id_short()
[docs]def matches_id_short(text: str) -> bool:
"""Check that :paramref:`text` is a valid short ID."""
return _REGEX_MATCHES_ID_SHORT.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_version_type() -> Pattern[str]:
pattern = "^(0|[1-9][0-9]*)$"
return re.compile(pattern)
_REGEX_MATCHES_VERSION_TYPE = _construct_matches_version_type()
[docs]def matches_version_type(text: str) -> bool:
"""Check that :paramref:`text` is a valid version string."""
return _REGEX_MATCHES_VERSION_TYPE.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_revision_type() -> Pattern[str]:
pattern = "^(0|[1-9][0-9]*)$"
return re.compile(pattern)
_REGEX_MATCHES_REVISION_TYPE = _construct_matches_revision_type()
[docs]def matches_revision_type(text: str) -> bool:
"""Check that :paramref:`text` is a valid revision string."""
return _REGEX_MATCHES_REVISION_TYPE.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_date_time_utc() -> Pattern[str]:
digit = "[0-9]"
year_frag = f"-?(([1-9]{digit}{digit}{digit}+)|(0{digit}{digit}{digit}))"
month_frag = "((0[1-9])|(1[0-2]))"
day_frag = f"((0[1-9])|([12]{digit})|(3[01]))"
hour_frag = f"(([01]{digit})|(2[0-3]))"
minute_frag = f"[0-5]{digit}"
second_frag = f"([0-5]{digit})(\\.{digit}+)?"
end_of_day_frag = "24:00:00(\\.0+)?"
timezone_frag = "(Z|\\+00:00|-00:00)"
date_time_lexical_rep = f"{year_frag}-{month_frag}-{day_frag}T(({hour_frag}:{minute_frag}:{second_frag})|{end_of_day_frag}){timezone_frag}"
pattern = f"^{date_time_lexical_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_DATE_TIME_UTC = _construct_matches_xs_date_time_utc()
[docs]def matches_xs_date_time_utc(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:dateTime``.
The time zone must be fixed to UTC. We verify only that the ``text`` matches
a pre-defined pattern. We *do not* verify that the day of month is
correct nor do we check for leap seconds.
See: https://www.w3.org/TR/xmlschema-2/#dateTime
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_DATE_TIME_UTC.match(text) is not None
[docs]def is_xs_date_time_utc(text: str) -> bool:
"""
Check that :paramref:`text` is a ``xs:dateTime`` with time zone set to UTC.
The ``text`` is assumed to match a pre-defined pattern for ``xs:dateTime`` with
the time zone set to UTC. In this function, we check for days of month (e.g.,
February 29th).
See: https://www.w3.org/TR/xmlschema-2/#dateTime
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:dateTime`` in UTC
"""
return matches_xs_date_time_utc(text) and _is_prefix_valid_date(text)
# noinspection SpellCheckingInspection
def _construct_matches_mime_type() -> Pattern[str]:
tchar = "[!#$%&'*+\\-.^_`|~0-9a-zA-Z]"
token = f"({tchar})+"
type = f"{token}"
subtype = f"{token}"
ows = "[ \\t]*"
obs_text = "[\\x80-\\xff]"
qd_text = f"([\\t !#-\\[\\]-~]|{obs_text})"
quoted_pair = f"\\\\([\\t !-~]|{obs_text})"
quoted_string = f'"({qd_text}|{quoted_pair})*"'
parameter = f"{token}=({token}|{quoted_string})"
media_type = f"^{type}/{subtype}({ows};{ows}{parameter})*$"
return re.compile(media_type)
_REGEX_MATCHES_MIME_TYPE = _construct_matches_mime_type()
[docs]def matches_mime_type(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of MIME type.
The definition has been taken from:
https://www.rfc-editor.org/rfc/rfc7231#section-3.1.1.1,
https://www.rfc-editor.org/rfc/rfc7230#section-3.2.3 and
https://www.rfc-editor.org/rfc/rfc7230#section-3.2.6.
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_MIME_TYPE.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_rfc_2396() -> Pattern[str]:
alphanum = "[a-zA-Z0-9]"
mark = "[-_.!~*'()]"
unreserved = f"({alphanum}|{mark})"
hex = "([0-9]|[aA]|[bB]|[cC]|[dD]|[eE]|[fF]|[aA]|[bB]|[cC]|[dD]|[eE]|[fF])"
escaped = f"%{hex}{hex}"
pchar = f"({unreserved}|{escaped}|[:@&=+$,])"
param = f"({pchar})*"
segment = f"({pchar})*(;{param})*"
path_segments = f"{segment}(/{segment})*"
abs_path = f"/{path_segments}"
scheme = "[a-zA-Z][a-zA-Z0-9+\\-.]*"
userinfo = f"({unreserved}|{escaped}|[;:&=+$,])*"
domainlabel = f"({alphanum}|{alphanum}({alphanum}|-)*{alphanum})"
toplabel = f"([a-zA-Z]|[a-zA-Z]({alphanum}|-)*{alphanum})"
hostname = f"({domainlabel}\\.)*{toplabel}(\\.)?"
ipv4address = "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"
host = f"({hostname}|{ipv4address})"
port = "[0-9]*"
hostport = f"{host}(:{port})?"
server = f"(({userinfo}@)?{hostport})?"
reg_name = f"({unreserved}|{escaped}|[$,;:@&=+])+"
authority = f"({server}|{reg_name})"
net_path = f"//{authority}({abs_path})?"
reserved = "[;/?:@&=+$,]"
uric = f"({reserved}|{unreserved}|{escaped})"
query = f"({uric})*"
hier_part = f"({net_path}|{abs_path})(\\?{query})?"
uric_no_slash = f"({unreserved}|{escaped}|[;?:@&=+$,])"
opaque_part = f"{uric_no_slash}({uric})*"
absoluteuri = f"{scheme}:({hier_part}|{opaque_part})"
fragment = f"({uric})*"
rel_segment = f"({unreserved}|{escaped}|[;@&=+$,])+"
rel_path = f"{rel_segment}({abs_path})?"
relativeuri = f"({net_path}|{abs_path}|{rel_path})(\\?{query})?"
uri_reference = f"^({absoluteuri}|{relativeuri})?(#{fragment})?$"
return re.compile(uri_reference)
_REGEX_MATCHES_RFC_2396 = _construct_matches_rfc_2396()
[docs]def matches_rfc_2396(text: str) -> bool:
"""
Check that :paramref:`text` matches to the URI pattern defined in RFC 2396
The definition has been taken from:
https://datatracker.ietf.org/doc/html/rfc2396
Note that RFX 2396 alone is not enough for specifying ``xs:anyURI`` for
XSD version 1.0, as that specifies URI together with the amendment of
RFC 2732.
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_RFC_2396.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_bcp_47() -> Pattern[str]:
alphanum = "[a-zA-Z0-9]"
singleton = "[0-9A-WY-Za-wy-z]"
extension = f"{singleton}(-({alphanum}){{2,8}})+"
extlang = "[a-zA-Z]{3}(-[a-zA-Z]{3}){0,2}"
irregular = "(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)"
regular = "(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)"
grandfathered = f"({irregular}|{regular})"
language = f"([a-zA-Z]{{2,3}}(-{extlang})?|[a-zA-Z]{{4}}|[a-zA-Z]{{5,8}})"
script = "[a-zA-Z]{4}"
region = "([a-zA-Z]{2}|[0-9]{3})"
variant = f"(({alphanum}){{5,8}}|[0-9]({alphanum}){{3}})"
privateuse = f"[xX](-({alphanum}){{1,8}})+"
langtag = f"{language}(-{script})?(-{region})?(-{variant})*(-{extension})*(-{privateuse})?"
language_tag = f"({langtag}|{privateuse}|{grandfathered})"
pattern = f"^{language_tag}$"
return re.compile(pattern)
_REGEX_MATCHES_BCP_47 = _construct_matches_bcp_47()
[docs]def matches_bcp_47(text: str) -> bool:
"""
Check that :paramref:`text` is a valid BCP 47 language tag.
See: https://en.wikipedia.org/wiki/IETF_language_tag
"""
return _REGEX_MATCHES_BCP_47.match(text) is not None
[docs]def lang_strings_have_unique_languages(
lang_strings: Sequence[our_types.AbstractLangString],
) -> bool:
"""
Check that the :paramref:`lang_strings` do not have overlapping
:py:attr:`.types.AbstractLangString.language`'s
"""
language_set: Set[str] = set()
for lang_string in lang_strings:
if lang_string.language in language_set:
return False
language_set.add(lang_string.language)
return True
[docs]def qualifier_types_are_unique(qualifiers: Sequence[our_types.Qualifier]) -> bool:
"""
Check that :py:attr:`.types.Qualifier.type`'s of :paramref:`qualifiers` are unique.
:param qualifiers: to be checked
:return:
True if all :py:attr:`.types.Qualifier.type`'s are unique
"""
observed_types: Set[str] = set()
for qualifier in qualifiers:
if qualifier.type in observed_types:
return False
observed_types.add(qualifier.type)
return True
# noinspection SpellCheckingInspection
def _construct_matches_xml_serializable_string() -> Pattern[str]:
pattern = "^[\\x09\\x0a\\x0d\\x20-\\ud7ff\\ue000-\\ufffd\\U00010000-\\U0010ffff]*$"
return re.compile(pattern)
_REGEX_MATCHES_XML_SERIALIZABLE_STRING = _construct_matches_xml_serializable_string()
[docs]def matches_xml_serializable_string(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of the Constraint AASd-130.
Ensures that encoding is possible and interoperability between different
serializations is possible.
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XML_SERIALIZABLE_STRING.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_any_uri() -> Pattern[str]:
alphanum = "[a-zA-Z0-9]"
mark = "[-_.!~*'()]"
unreserved = f"({alphanum}|{mark})"
hex = "([0-9]|[aA]|[bB]|[cC]|[dD]|[eE]|[fF]|[aA]|[bB]|[cC]|[dD]|[eE]|[fF])"
escaped = f"%{hex}{hex}"
pchar = f"({unreserved}|{escaped}|[:@&=+$,])"
param = f"({pchar})*"
segment = f"({pchar})*(;{param})*"
path_segments = f"{segment}(/{segment})*"
abs_path = f"/{path_segments}"
scheme = "[a-zA-Z][a-zA-Z0-9+\\-.]*"
userinfo = f"({unreserved}|{escaped}|[;:&=+$,])*"
domainlabel = f"({alphanum}|{alphanum}({alphanum}|-)*{alphanum})"
toplabel = f"([a-zA-Z]|[a-zA-Z]({alphanum}|-)*{alphanum})"
hostname = f"({domainlabel}\\.)*{toplabel}(\\.)?"
ipv4address = "[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"
hex4 = "[0-9A-Fa-f]{1,4}"
hexseq = f"{hex4}(:{hex4})*"
hexpart = f"({hexseq}|{hexseq}::({hexseq})?|::({hexseq})?)"
ipv6address = f"{hexpart}(:{ipv4address})?"
ipv6reference = f"\\[{ipv6address}\\]"
host = f"({hostname}|{ipv4address}|{ipv6reference})"
port = "[0-9]*"
hostport = f"{host}(:{port})?"
server = f"(({userinfo}@)?{hostport})?"
reg_name = f"({unreserved}|{escaped}|[$,;:@&=+])+"
authority = f"({server}|{reg_name})"
net_path = f"//{authority}({abs_path})?"
reserved = "[;/?:@&=+$,\\[\\]]"
uric = f"({reserved}|{unreserved}|{escaped})"
query = f"({uric})*"
hier_part = f"({net_path}|{abs_path})(\\?{query})?"
uric_no_slash = f"({unreserved}|{escaped}|[;?:@&=+$,])"
opaque_part = f"{uric_no_slash}({uric})*"
absoluteuri = f"{scheme}:({hier_part}|{opaque_part})"
fragment = f"({uric})*"
rel_segment = f"({unreserved}|{escaped}|[;@&=+$,])+"
rel_path = f"{rel_segment}({abs_path})?"
relativeuri = f"({net_path}|{abs_path}|{rel_path})(\\?{query})?"
uri_reference = f"^({absoluteuri}|{relativeuri})?(#{fragment})?$"
return re.compile(uri_reference)
_REGEX_MATCHES_XS_ANY_URI = _construct_matches_xs_any_uri()
[docs]def matches_xs_any_uri(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:anyURI``.
See: https://www.w3.org/TR/xmlschema-2/#anyURI and
https://datatracker.ietf.org/doc/html/rfc2396 and
https://datatracker.ietf.org/doc/html/rfc2732
Note, that version 1.0 of the XSD specification defines ``xs:anyURI`` as
"defined by RFC 2396, as amended by RFC 2732". Therefore, we use a
pattern here that implements the amendments of RFC 2732. This should not
be confused with ``matches_RFC_2396``, which does not include those
amendments and is used in different parts of the specification.
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_ANY_URI.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_base_64_binary() -> Pattern[str]:
b04_char = "[AQgw]"
b04 = f"{b04_char}\\x20?"
b16_char = "[AEIMQUYcgkosw048]"
b16 = f"{b16_char}\\x20?"
b64_char = "[A-Za-z0-9+/]"
b64 = f"{b64_char}\\x20?"
b64quad = f"({b64}{b64}{b64}{b64})"
b64_final_quad = f"({b64}{b64}{b64}{b64_char})"
padded_8 = f"{b64}{b04}= ?="
padded_16 = f"{b64}{b64}{b16}="
b64final = f"({b64_final_quad}|{padded_16}|{padded_8})"
base64_binary = f"({b64quad}*{b64final})?"
pattern = f"^{base64_binary}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_BASE_64_BINARY = _construct_matches_xs_base_64_binary()
[docs]def matches_xs_base_64_binary(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:base64Binary``.
See: https://www.w3.org/TR/xmlschema-2/#base64Binary
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_BASE_64_BINARY.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_boolean() -> Pattern[str]:
pattern = "^(true|false|1|0)$"
return re.compile(pattern)
_REGEX_MATCHES_XS_BOOLEAN = _construct_matches_xs_boolean()
[docs]def matches_xs_boolean(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:boolean``.
See: https://www.w3.org/TR/xmlschema-2/#boolean
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_BOOLEAN.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_date() -> Pattern[str]:
digit = "[0-9]"
year_frag = f"-?(([1-9]{digit}{digit}{digit}+)|(0{digit}{digit}{digit}))"
month_frag = "((0[1-9])|(1[0-2]))"
day_frag = f"((0[1-9])|([12]{digit})|(3[01]))"
minute_frag = f"[0-5]{digit}"
timezone_frag = f"(Z|(\\+|-)((0{digit}|1[0-3]):{minute_frag}|14:00))"
date_lexical_rep = f"{year_frag}-{month_frag}-{day_frag}{timezone_frag}?"
pattern = f"^{date_lexical_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_DATE = _construct_matches_xs_date()
[docs]def matches_xs_date(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:date``.
See: https://www.w3.org/TR/xmlschema-2/#date
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_DATE.match(text) is not None
def _is_leap_year(year: str) -> bool:
"""
Check that the :paramref:`year` of an ``xs:date`` is a leap year.
The :paramref:`year` is expected to be given as text, *i.e.*, as digits with
an optional minus prefix, as the year can be arbitrarily large.
We consider the years B.C. to be one-off. See the note at
https://www.w3.org/TR/xmlschema-2/#dateTime: "'-0001' is the lexical
representation of the year 1 Before Common Era (1 BCE, sometimes written "1 BC")."
Hence, the year -1 in XML is the year 0 in astronomical years.
:param year: Text of the year to be checked
:return: True if the :paramref:`year` is a leap year
"""
remainder = our_common.parse_safe_int(year.lstrip("-")[-4:]) % 400
if year.startswith("-"):
remainder = (remainder + 399) % 400
return (remainder % 4) == (0) and (((remainder % 100) != (0) or remainder == 0))
def _is_day_of_month_valid(is_leap_year: bool, month: int, day: int) -> bool:
"""
Check that the :paramref:`day` exists in the :paramref:`month`.
:param is_leap_year: True if February has 29 days
:param month: Month of the year, starting with 1
:param day: Day of the month, starting with 1
:return:
True if the :paramref:`day` exists in the :paramref:`month`
"""
if month < 1 or month > 12 or day < 1:
return False
if month == 2:
if is_leap_year:
return day <= 29
return day <= 28
if month in (4, 6, 9, 11):
return day <= 30
return day <= 31
def _is_prefix_valid_date(text: str) -> bool:
"""
Check that the date at the start of :paramref:`text` is valid.
The :paramref:`text` is expected to start with a date matching the pattern
``-?YYYY-MM-DD``, where the year can have more than four digits. Whatever follows
the date, such as the time or the time zone, is ignored.
:param text: Text to be checked
:return:
True if the date at the start of :paramref:`text` is valid
"""
month_start = text.find("-", 1) + 1
year = text[: month_start - 1]
if year.lstrip("-").lstrip("0") == "":
return False
month = our_common.parse_safe_int(text[month_start : month_start + 2])
day = our_common.parse_safe_int(text[month_start + 3 : month_start + 5])
return _is_day_of_month_valid(_is_leap_year(year), month, day)
[docs]def is_xs_date(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:date``.
We check that the :paramref:`text` matches the pattern of ``xs:date``, and that
the day exists in the month (*e.g.*, February 29th only in leap years).
See: https://www.w3.org/TR/xmlschema-2/#date
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:date``
"""
return matches_xs_date(text) and _is_prefix_valid_date(text)
# noinspection SpellCheckingInspection
def _construct_matches_xs_date_time() -> Pattern[str]:
digit = "[0-9]"
year_frag = f"-?(([1-9]{digit}{digit}{digit}+)|(0{digit}{digit}{digit}))"
month_frag = "((0[1-9])|(1[0-2]))"
day_frag = f"((0[1-9])|([12]{digit})|(3[01]))"
hour_frag = f"(([01]{digit})|(2[0-3]))"
minute_frag = f"[0-5]{digit}"
second_frag = f"([0-5]{digit})(\\.{digit}+)?"
end_of_day_frag = "24:00:00(\\.0+)?"
timezone_frag = f"(Z|(\\+|-)((0{digit}|1[0-3]):{minute_frag}|14:00))"
date_time_lexical_rep = f"{year_frag}-{month_frag}-{day_frag}T(({hour_frag}:{minute_frag}:{second_frag})|{end_of_day_frag}){timezone_frag}?"
pattern = f"^{date_time_lexical_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_DATE_TIME = _construct_matches_xs_date_time()
[docs]def matches_xs_date_time(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:dateTime``.
See: https://www.w3.org/TR/xmlschema-2/#dateTime
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_DATE_TIME.match(text) is not None
[docs]def is_xs_date_time(text: str) -> bool:
"""
Check that :paramref:`text` is a ``xs:dateTime``.
The ``text`` is assumed to match a pre-defined pattern for ``xs:dateTime``.
In this function, we check for days of month (e.g., February 29th).
See: https://www.w3.org/TR/xmlschema-2/#dateTime
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:dateTime``
"""
return matches_xs_date_time(text) and _is_prefix_valid_date(text)
def _fraction_of_date_time_utc(text: str) -> str:
"""
Get the digits of the fraction of a second in :paramref:`text`.
The :paramref:`text` is expected to be a valid ``xs:dateTime`` with the time
zone fixed to UTC, *i.e.*, it ends with ``Z``, ``+00:00`` or ``-00:00``.
:param text: Date-time to be parsed
:return:
The digits after the decimal point, or an empty text if there are none
"""
point = text.find(".")
if point == -1:
return ""
if text.endswith("Z"):
return text[point + 1 : -1]
return text[point + 1 : -6]
def _is_next_day(text: str, next_text: str) -> bool:
"""
Check that the date of :paramref:`next_text` is the day after the date of
:paramref:`text`.
Both :paramref:`text` and :paramref:`next_text` are expected to start with
a valid date matching the pattern ``-?YYYY-MM-DD``, where the year can have
more than four digits, but has to fit into an integer. Whatever follows
the date, such as the time or the time zone, is ignored.
:param text: Text starting with the date to be incremented
:param next_text:
Text starting with the date expected to follow
:return:
True if the date of :paramref:`next_text` follows the date of
:paramref:`text`
"""
month_start = text.find("-", 1) + 1
next_month_start = next_text.find("-", 1) + 1
year_text = text[: month_start - 1]
year = our_common.parse_safe_int(year_text)
month = our_common.parse_safe_int(text[month_start : month_start + 2])
day = our_common.parse_safe_int(text[month_start + 3 : month_start + 5])
next_year = our_common.parse_safe_int(next_text[: next_month_start - 1])
next_month = our_common.parse_safe_int(
next_text[next_month_start : next_month_start + 2]
)
next_day = our_common.parse_safe_int(
next_text[next_month_start + 3 : next_month_start + 5]
)
if _is_day_of_month_valid(_is_leap_year(year_text), month, day + 1):
return year == next_year and month == next_month and (day + 1) == (next_day)
if next_day != 1:
return False
if month < 12:
return year == next_year and (month + 1) == (next_month)
return next_month == 1 and (
((next_year) == (year + 1) or ((year == -1 and next_year == 1)))
)
[docs]def date_time_utc_less(that: str, other: str) -> Optional[bool]:
"""
Check that the date-time :paramref:`that` is before :paramref:`other`.
We compare the years as integers, and the rest of the texts part by part as
strings, since the fraction of a second can be arbitrarily long.
We do not compare the years with more than 15 digits, as they do not safely fit
into an integer. Such years are valid in ``xs:dateTime``, but not realistic.
The end of a day, ``24:00:00``, is the same instant as the start of the next day,
see the note at https://www.w3.org/TR/xmlschema-2/#dateTime.
:param that: Date-time which is expected to come first
:param other: Date-time which is expected to come later
:return:
True if :paramref:`that` is before :paramref:`other`, False if not, and
None if either of them is not a valid ``xs:dateTime`` in UTC, or if
either of their years has more than 15 digits
"""
if not is_xs_date_time_utc(that) or (not is_xs_date_time_utc(other)):
return None
that_month_start = that.find("-", 1) + 1
other_month_start = other.find("-", 1) + 1
that_year_text = that[: that_month_start - 1]
other_year_text = other[: other_month_start - 1]
if len(that_year_text.lstrip("-")) > 15 or len(other_year_text.lstrip("-")) > 15:
return None
that_year = our_common.parse_safe_int(that_year_text)
other_year = our_common.parse_safe_int(other_year_text)
that_rest = that[that_month_start : that_month_start + 14]
other_rest = other[other_month_start : other_month_start + 14]
that_fraction = (_fraction_of_date_time_utc(that)).rstrip("0")
other_fraction = (_fraction_of_date_time_utc(other)).rstrip("0")
less = False
if that_year != other_year:
less = that_year < other_year
elif that_rest != other_rest:
less = that_rest < other_rest
else:
less = that_fraction < other_fraction
if (
less
and that[that_month_start + 6 : that_month_start + 8] == "24"
and other[other_month_start + 6 : other_month_start + 14] == "00:00:00"
and other_fraction == ""
):
return not _is_next_day(that, other)
return less
[docs]def date_time_utc_less_or_equal_or_invalid(that: str, other: str) -> bool:
"""
Check that the date-time :paramref:`that` is before or at the same instant as
:paramref:`other`, unless either of them is invalid.
The invalid date-times are reported by the invariants of
``DateTimeUTC``, so that we do not report them twice.
See :py:func:`date_time_utc_less`.
:param that:
Date-time which is expected to come first or at the same instant
:param other:
Date-time which is expected to come later or at the same instant
:return:
True if :paramref:`that` is before or at the same instant as
:paramref:`other`, or if either of them is not a valid ``xs:dateTime``
in UTC
"""
other_less = date_time_utc_less(other, that)
if other_less is None:
return True
return not other_less
# noinspection SpellCheckingInspection
def _construct_matches_xs_decimal() -> Pattern[str]:
digit = "[0-9]"
unsigned_no_decimal_pt_numeral = f"{digit}+"
no_decimal_pt_numeral = f"(\\+|-)?{unsigned_no_decimal_pt_numeral}"
frac_frag = f"{digit}+"
unsigned_decimal_pt_numeral = (
f"({unsigned_no_decimal_pt_numeral}\\.{frac_frag}|\\.{frac_frag})"
)
decimal_pt_numeral = f"(\\+|-)?{unsigned_decimal_pt_numeral}"
decimal_lexical_rep = f"({decimal_pt_numeral}|{no_decimal_pt_numeral})"
pattern = f"^{decimal_lexical_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_DECIMAL = _construct_matches_xs_decimal()
[docs]def matches_xs_decimal(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:decimal``.
See: https://www.w3.org/TR/xmlschema-2/#decimal
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_DECIMAL.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_double() -> Pattern[str]:
double_rep = (
"((\\+|-)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([Ee](\\+|-)?[0-9]+)?|-?INF|NaN)"
)
pattern = f"^{double_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_DOUBLE = _construct_matches_xs_double()
[docs]def matches_xs_double(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:double``.
See: https://www.w3.org/TR/xmlschema-2/#double
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_DOUBLE.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_duration() -> Pattern[str]:
duration_rep = "-?P((([0-9]+Y([0-9]+M)?([0-9]+D)?|([0-9]+M)([0-9]+D)?|([0-9]+D))(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S)))?)|(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S))))"
pattern = f"^{duration_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_DURATION = _construct_matches_xs_duration()
[docs]def matches_xs_duration(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:duration``.
See: https://www.w3.org/TR/xmlschema-2/#duration
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_DURATION.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_float() -> Pattern[str]:
float_rep = (
"((\\+|-)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([Ee](\\+|-)?[0-9]+)?|-?INF|NaN)"
)
pattern = f"^{float_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_FLOAT = _construct_matches_xs_float()
[docs]def matches_xs_float(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:float``.
See: https://www.w3.org/TR/xmlschema-2/#float
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_FLOAT.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_g_day() -> Pattern[str]:
g_day_lexical_rep = (
"---(0[1-9]|[12][0-9]|3[01])(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"
)
pattern = f"^{g_day_lexical_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_G_DAY = _construct_matches_xs_g_day()
[docs]def matches_xs_g_day(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:gDay``.
See: https://www.w3.org/TR/xmlschema-2/#gDay
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_G_DAY.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_g_month() -> Pattern[str]:
g_month_lexical_rep = (
"--(0[1-9]|1[0-2])(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"
)
pattern = f"^{g_month_lexical_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_G_MONTH = _construct_matches_xs_g_month()
[docs]def matches_xs_g_month(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:gMonth``.
See: https://www.w3.org/TR/xmlschema-2/#gMonth
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_G_MONTH.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_g_month_day() -> Pattern[str]:
g_month_day_rep = "--(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"
pattern = f"^{g_month_day_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_G_MONTH_DAY = _construct_matches_xs_g_month_day()
[docs]def matches_xs_g_month_day(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:gMonthDay``.
See: https://www.w3.org/TR/xmlschema-2/#gMonthDay
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_G_MONTH_DAY.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_g_year() -> Pattern[str]:
g_year_rep = (
"-?([1-9][0-9]{3,}|0[0-9]{3})(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"
)
pattern = f"^{g_year_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_G_YEAR = _construct_matches_xs_g_year()
[docs]def matches_xs_g_year(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:gYear``.
See: https://www.w3.org/TR/xmlschema-2/#gYear
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_G_YEAR.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_g_year_month() -> Pattern[str]:
g_year_month_rep = "-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"
pattern = f"^{g_year_month_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_G_YEAR_MONTH = _construct_matches_xs_g_year_month()
[docs]def matches_xs_g_year_month(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:gYearMonth``.
See: https://www.w3.org/TR/xmlschema-2/#gYearMonth
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_G_YEAR_MONTH.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_hex_binary() -> Pattern[str]:
hex_binary = "([0-9a-fA-F]{2})*"
pattern = f"^{hex_binary}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_HEX_BINARY = _construct_matches_xs_hex_binary()
[docs]def matches_xs_hex_binary(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:hexBinary``.
See: https://www.w3.org/TR/xmlschema-2/#hexBinary
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_HEX_BINARY.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_time() -> Pattern[str]:
time_rep = "(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?|(24:00:00(\\.0+)?))(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"
pattern = f"^{time_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_TIME = _construct_matches_xs_time()
[docs]def matches_xs_time(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:time``.
See: https://www.w3.org/TR/xmlschema-2/#time
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_TIME.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_integer() -> Pattern[str]:
integer_rep = "[-+]?[0-9]+"
pattern = f"^{integer_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_INTEGER = _construct_matches_xs_integer()
[docs]def matches_xs_integer(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:integer``.
See: https://www.w3.org/TR/xmlschema-2/#integer
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_INTEGER.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_long() -> Pattern[str]:
long_rep = "[-+]?0*[0-9]{1,20}"
pattern = f"^{long_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_LONG = _construct_matches_xs_long()
[docs]def matches_xs_long(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:long``.
See: https://www.w3.org/TR/xmlschema-2/#long
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_LONG.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_int() -> Pattern[str]:
int_rep = "[-+]?0*[0-9]{1,10}"
pattern = f"^{int_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_INT = _construct_matches_xs_int()
[docs]def matches_xs_int(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:int``.
See: https://www.w3.org/TR/xmlschema-2/#int
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_INT.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_short() -> Pattern[str]:
short_rep = "[-+]?0*[0-9]{1,5}"
pattern = f"^{short_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_SHORT = _construct_matches_xs_short()
[docs]def matches_xs_short(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:short``.
See: https://www.w3.org/TR/xmlschema-2/#short
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_SHORT.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_byte() -> Pattern[str]:
byte_rep = "[-+]?0*[0-9]{1,3}"
pattern = f"^{byte_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_BYTE = _construct_matches_xs_byte()
[docs]def matches_xs_byte(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:byte``.
See: https://www.w3.org/TR/xmlschema-2/#byte
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_BYTE.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_non_negative_integer() -> Pattern[str]:
non_negative_integer_rep = "(-0|\\+?[0-9]+)"
pattern = f"^{non_negative_integer_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_NON_NEGATIVE_INTEGER = _construct_matches_xs_non_negative_integer()
[docs]def matches_xs_non_negative_integer(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:nonNegativeInteger``.
See: https://www.w3.org/TR/xmlschema-2/#nonNegativeInteger
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_NON_NEGATIVE_INTEGER.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_positive_integer() -> Pattern[str]:
positive_integer_rep = "\\+?0*[1-9][0-9]*"
pattern = f"^{positive_integer_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_POSITIVE_INTEGER = _construct_matches_xs_positive_integer()
[docs]def matches_xs_positive_integer(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:positiveInteger``.
See: https://www.w3.org/TR/xmlschema-2/#positiveInteger
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_POSITIVE_INTEGER.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_unsigned_long() -> Pattern[str]:
unsigned_long_rep = "(-0|\\+?0*[0-9]{1,20})"
pattern = f"^{unsigned_long_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_UNSIGNED_LONG = _construct_matches_xs_unsigned_long()
[docs]def matches_xs_unsigned_long(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:unsignedLong``.
See: https://www.w3.org/TR/xmlschema-2/#unsignedLong
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_UNSIGNED_LONG.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_unsigned_int() -> Pattern[str]:
unsigned_int_rep = "(-0|\\+?0*[0-9]{1,10})"
pattern = f"^{unsigned_int_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_UNSIGNED_INT = _construct_matches_xs_unsigned_int()
[docs]def matches_xs_unsigned_int(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:unsignedInt``.
See: https://www.w3.org/TR/xmlschema-2/#unsignedInt
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_UNSIGNED_INT.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_unsigned_short() -> Pattern[str]:
unsigned_short_rep = "(-0|\\+?0*[0-9]{1,5})"
pattern = f"^{unsigned_short_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_UNSIGNED_SHORT = _construct_matches_xs_unsigned_short()
[docs]def matches_xs_unsigned_short(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:unsignedShort``.
See: https://www.w3.org/TR/xmlschema-2/#unsignedShort
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_UNSIGNED_SHORT.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_unsigned_byte() -> Pattern[str]:
unsigned_byte_rep = "(-0|\\+?0*[0-9]{1,3})"
pattern = f"^{unsigned_byte_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_UNSIGNED_BYTE = _construct_matches_xs_unsigned_byte()
[docs]def matches_xs_unsigned_byte(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:unsignedByte``.
See: https://www.w3.org/TR/xmlschema-2/#unsignedByte
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_UNSIGNED_BYTE.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_non_positive_integer() -> Pattern[str]:
non_positive_integer_rep = "(\\+0|0|-[0-9]+)"
pattern = f"^{non_positive_integer_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_NON_POSITIVE_INTEGER = _construct_matches_xs_non_positive_integer()
[docs]def matches_xs_non_positive_integer(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:nonPositiveInteger``.
See: https://www.w3.org/TR/xmlschema-2/#nonPositiveInteger
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_NON_POSITIVE_INTEGER.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_negative_integer() -> Pattern[str]:
negative_integer_rep = "(-0*[1-9][0-9]*)"
pattern = f"^{negative_integer_rep}$"
return re.compile(pattern)
_REGEX_MATCHES_XS_NEGATIVE_INTEGER = _construct_matches_xs_negative_integer()
[docs]def matches_xs_negative_integer(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:negativeInteger``.
See: https://www.w3.org/TR/xmlschema-2/#negativeInteger
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_NEGATIVE_INTEGER.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_xs_string() -> Pattern[str]:
pattern = "^[\\x09\\x0a\\x0d\\x20-\\ud7ff\\ue000-\\ufffd\\U00010000-\\U0010ffff]*$"
return re.compile(pattern)
_REGEX_MATCHES_XS_STRING = _construct_matches_xs_string()
[docs]def matches_xs_string(text: str) -> bool:
"""
Check that :paramref:`text` conforms to the pattern of an ``xs:string``.
See: https://www.w3.org/TR/xmlschema-2/#string
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_XS_STRING.match(text) is not None
def _is_magnitude_at_most(digits: str, limit: str) -> bool:
"""
Check that the number given as :paramref:`digits` is at most :paramref:`limit`.
Both :paramref:`digits` and :paramref:`limit` are expected to be decimal digits
without a sign and without leading zeros. An empty text represents zero.
We compare the numbers as strings, since they might not fit into an integer.
The digits of numbers of equal length are ordered as the numbers themselves.
:param digits: Number to be checked
:param limit: Largest allowed number
:return:
True if :paramref:`digits` is at most :paramref:`limit`
"""
if len(digits) != len(limit):
return len(digits) < len(limit)
return digits <= limit
def _is_integer_in_range(text: str, max_negative: str, max_positive: str) -> bool:
"""
Check that the integer :paramref:`text` is within the given range.
The :paramref:`text` is expected to consist of decimal digits with an optional
sign.
:param text: Text to be checked
:param max_negative:
Largest allowed magnitude of a negative number
:param max_positive: Largest allowed positive number
:return: True if the :paramref:`text` is within the range
"""
digits = text.lstrip("+-").lstrip("0")
if text.startswith("-"):
return _is_magnitude_at_most(digits, max_negative)
return _is_magnitude_at_most(digits, max_positive)
def _is_decimal_magnitude_below(text: str, limit: str) -> bool:
"""
Check that the magnitude of the decimal :paramref:`text` is below :paramref:`limit`.
The :paramref:`text` is expected to match the pattern of a finite ``xs:double``
or ``xs:float``, *i.e.*, a decimal with an optional sign, an optional point and
an optional exponent. The :paramref:`limit` is expected to be a positive integer
without leading zeros.
We compare the numbers as strings, since they do not necessarily fit into
any native number, and parsing them to floating-point numbers would round them.
:param text: Decimal to be checked
:param limit: Exclusive upper bound on the magnitude
:return:
True if the magnitude of :paramref:`text` is below :paramref:`limit`
"""
unsigned = text.lstrip("+-")
exponent_start = unsigned.find("e")
if exponent_start == -1:
exponent_start = unsigned.find("E")
mantissa = unsigned
exponent_text = ""
if exponent_start != -1:
mantissa = unsigned[:exponent_start]
exponent_text = unsigned[exponent_start + 1 :]
point = mantissa.find(".")
integer_part = mantissa
fraction_part = ""
if point != -1:
integer_part = mantissa[:point]
fraction_part = mantissa[point + 1 :]
head = integer_part.lstrip("0")
tail = fraction_part
shift: int = len(head)
if head == "":
tail = fraction_part.lstrip("0")
if tail == "":
return True
shift = len(tail) - len(fraction_part)
exponent_digits = exponent_text.lstrip("+-").lstrip("0")
if len(exponent_digits) > 15:
return exponent_text.startswith("-")
exponent: int = 0
if len(exponent_digits) > 0:
exponent = our_common.parse_safe_int(exponent_digits)
if exponent_text.startswith("-"):
exponent = -exponent
magnitude = exponent + shift
if magnitude != len(limit):
return magnitude < len(limit)
return (head + tail) < (limit)
[docs]def is_xs_double(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:double``.
We check that the :paramref:`text` matches the pattern of ``xs:double``, and
that it does not overflow, *i.e.*, that it does not round to infinity unless it
is ``INF`` or ``-INF``. See :py:attr:`.constants.XS_DOUBLE_OVERFLOW_THRESHOLD`.
See: https://www.w3.org/TR/xmlschema-2/#double
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:double``
"""
if not matches_xs_double(text):
return False
if text in ("INF", "-INF", "NaN"):
return True
return _is_decimal_magnitude_below(text, our_constants.XS_DOUBLE_OVERFLOW_THRESHOLD)
[docs]def is_xs_float(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:float``.
We check that the :paramref:`text` matches the pattern of ``xs:float``, and
that it does not overflow, *i.e.*, that it does not round to infinity unless it
is ``INF`` or ``-INF``. See :py:attr:`.constants.XS_FLOAT_OVERFLOW_THRESHOLD`.
See: https://www.w3.org/TR/xmlschema-2/#float
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:float``
"""
if not matches_xs_float(text):
return False
if text in ("INF", "-INF", "NaN"):
return True
return _is_decimal_magnitude_below(text, our_constants.XS_FLOAT_OVERFLOW_THRESHOLD)
[docs]def is_xs_g_month_day(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:gMonthDay``.
We check that the :paramref:`text` matches the pattern of ``xs:gMonthDay``,
and that the day exists in the month. February 29th is valid, as there is no
year to tell otherwise.
See: https://www.w3.org/TR/xmlschema-2/#gMonthDay
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:gMonthDay``
"""
return matches_xs_g_month_day(text) and _is_day_of_month_valid(
True, our_common.parse_safe_int(text[2:4]), our_common.parse_safe_int(text[5:7])
)
[docs]def is_xs_long(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:long``.
We check that the :paramref:`text` matches the pattern of ``xs:long``, and
that the number is within the range of ``xs:long``.
See: https://www.w3.org/TR/xmlschema-2/#long
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:long``
"""
return matches_xs_long(text) and _is_integer_in_range(
text, "9223372036854775808", "9223372036854775807"
)
[docs]def is_xs_int(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:int``.
We check that the :paramref:`text` matches the pattern of ``xs:int``, and
that the number is within the range of ``xs:int``.
See: https://www.w3.org/TR/xmlschema-2/#int
:param text: Text to be checked
:return: True if the :paramref:`text` is a valid ``xs:int``
"""
return matches_xs_int(text) and _is_integer_in_range(
text, "2147483648", "2147483647"
)
[docs]def is_xs_short(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:short``.
We check that the :paramref:`text` matches the pattern of ``xs:short``, and
that the number is within the range of ``xs:short``.
See: https://www.w3.org/TR/xmlschema-2/#short
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:short``
"""
return matches_xs_short(text) and _is_integer_in_range(text, "32768", "32767")
[docs]def is_xs_byte(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:byte``.
We check that the :paramref:`text` matches the pattern of ``xs:byte``, and
that the number is within the range of ``xs:byte``.
See: https://www.w3.org/TR/xmlschema-2/#byte
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:byte``
"""
return matches_xs_byte(text) and _is_integer_in_range(text, "128", "127")
[docs]def is_xs_unsigned_long(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:unsignedLong``.
We check that the :paramref:`text` matches the pattern of ``xs:unsignedLong``, and
that the number is within the range of ``xs:unsignedLong``.
See: https://www.w3.org/TR/xmlschema-2/#unsignedLong
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:unsignedLong``
"""
return matches_xs_unsigned_long(text) and _is_integer_in_range(
text, "0", "18446744073709551615"
)
[docs]def is_xs_unsigned_int(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:unsignedInt``.
We check that the :paramref:`text` matches the pattern of ``xs:unsignedInt``, and
that the number is within the range of ``xs:unsignedInt``.
See: https://www.w3.org/TR/xmlschema-2/#unsignedInt
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:unsignedInt``
"""
return matches_xs_unsigned_int(text) and _is_integer_in_range(
text, "0", "4294967295"
)
[docs]def is_xs_unsigned_short(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:unsignedShort``.
We check that the :paramref:`text` matches the pattern of ``xs:unsignedShort``, and
that the number is within the range of ``xs:unsignedShort``.
See: https://www.w3.org/TR/xmlschema-2/#unsignedShort
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:unsignedShort``
"""
return matches_xs_unsigned_short(text) and _is_integer_in_range(text, "0", "65535")
[docs]def is_xs_unsigned_byte(text: str) -> bool:
"""
Check that :paramref:`text` is a valid ``xs:unsignedByte``.
We check that the :paramref:`text` matches the pattern of ``xs:unsignedByte``, and
that the number is within the range of ``xs:unsignedByte``.
See: https://www.w3.org/TR/xmlschema-2/#unsignedByte
:param text: Text to be checked
:return:
True if the :paramref:`text` is a valid ``xs:unsignedByte``
"""
return matches_xs_unsigned_byte(text) and _is_integer_in_range(text, "0", "255")
[docs]def value_consistent_with_xsd_type(
value: str, value_type: our_types.DataTypeDefXSD
) -> bool:
"""
Check that the :paramref:`value` conforms to its :paramref:`value_type`.
:param value: which needs to conform
:param value_type: pre-defined value type
:return: True if the :paramref:`value` conforms
"""
if value_type == our_types.DataTypeDefXSD.ANY_URI:
return matches_xs_any_uri(value)
elif value_type == our_types.DataTypeDefXSD.BASE_64_BINARY:
return matches_xs_base_64_binary(value)
elif value_type == our_types.DataTypeDefXSD.BOOLEAN:
return matches_xs_boolean(value)
elif value_type == our_types.DataTypeDefXSD.BYTE:
return is_xs_byte(value)
elif value_type == our_types.DataTypeDefXSD.DATE:
return is_xs_date(value)
elif value_type == our_types.DataTypeDefXSD.DATE_TIME:
return is_xs_date_time(value)
elif value_type == our_types.DataTypeDefXSD.DECIMAL:
return matches_xs_decimal(value)
elif value_type == our_types.DataTypeDefXSD.DOUBLE:
return is_xs_double(value)
elif value_type == our_types.DataTypeDefXSD.DURATION:
return matches_xs_duration(value)
elif value_type == our_types.DataTypeDefXSD.FLOAT:
return is_xs_float(value)
elif value_type == our_types.DataTypeDefXSD.G_DAY:
return matches_xs_g_day(value)
elif value_type == our_types.DataTypeDefXSD.G_MONTH:
return matches_xs_g_month(value)
elif value_type == our_types.DataTypeDefXSD.G_MONTH_DAY:
return is_xs_g_month_day(value)
elif value_type == our_types.DataTypeDefXSD.G_YEAR:
return matches_xs_g_year(value)
elif value_type == our_types.DataTypeDefXSD.G_YEAR_MONTH:
return matches_xs_g_year_month(value)
elif value_type == our_types.DataTypeDefXSD.HEX_BINARY:
return matches_xs_hex_binary(value)
elif value_type == our_types.DataTypeDefXSD.INT:
return is_xs_int(value)
elif value_type == our_types.DataTypeDefXSD.INTEGER:
return matches_xs_integer(value)
elif value_type == our_types.DataTypeDefXSD.LONG:
return is_xs_long(value)
elif value_type == our_types.DataTypeDefXSD.NEGATIVE_INTEGER:
return matches_xs_negative_integer(value)
elif value_type == our_types.DataTypeDefXSD.NON_NEGATIVE_INTEGER:
return matches_xs_non_negative_integer(value)
elif value_type == our_types.DataTypeDefXSD.NON_POSITIVE_INTEGER:
return matches_xs_non_positive_integer(value)
elif value_type == our_types.DataTypeDefXSD.POSITIVE_INTEGER:
return matches_xs_positive_integer(value)
elif value_type == our_types.DataTypeDefXSD.SHORT:
return is_xs_short(value)
elif value_type == our_types.DataTypeDefXSD.STRING:
return matches_xs_string(value)
elif value_type == our_types.DataTypeDefXSD.TIME:
return matches_xs_time(value)
elif value_type == our_types.DataTypeDefXSD.UNSIGNED_BYTE:
return is_xs_unsigned_byte(value)
elif value_type == our_types.DataTypeDefXSD.UNSIGNED_INT:
return is_xs_unsigned_int(value)
elif value_type == our_types.DataTypeDefXSD.UNSIGNED_LONG:
return is_xs_unsigned_long(value)
elif value_type == our_types.DataTypeDefXSD.UNSIGNED_SHORT:
return is_xs_unsigned_short(value)
return False
[docs]def is_model_reference_to(
reference: our_types.Reference, expected_type: our_types.KeyTypes
) -> bool:
"""
Check that the target of the model reference matches the :paramref:`expected_type`.
"""
return (
reference.type == our_types.ReferenceTypes.MODEL_REFERENCE
and len(reference.keys) != 0
and reference.keys[-1].type == expected_type
)
[docs]def is_model_reference_to_referable(reference: our_types.Reference) -> bool:
"""
Check that the target of the reference matches a :py:attr:`.constants.AAS_REFERABLES`.
"""
return (
reference.type == our_types.ReferenceTypes.MODEL_REFERENCE
and len(reference.keys) != 0
and (reference.keys[-1].type in our_constants.AAS_REFERABLES)
)
[docs]def id_shorts_are_unique(referables: Sequence[our_types.Referable]) -> bool:
"""
Check that the :py:attr:`.types.Referable.id_short`'s among the :paramref:`referables` are
unique in their namespace.
"""
id_short_set: Set[str] = set()
for referable in referables:
id_short = referable.id_short
if id_short is None:
continue
if id_short in id_short_set:
return False
id_short_set.add(id_short)
return True
def _collect_unique_id_shorts_of_variables(
variables: Optional[Sequence[our_types.OperationVariable]], id_short_set: Set[str]
) -> bool:
"""
Collect the :py:attr:`.types.Referable.id_short`'s of the :paramref:`variables` values.
:param variables:
Operation variables whose ID-shorts we collect
:param id_short_set:
ID-shorts observed so far, extended in place
:return: False if an ID-short has been already observed
"""
if variables is None:
return True
for variable in variables:
id_short = variable.value.id_short
if id_short is None:
continue
if id_short in id_short_set:
return False
id_short_set.add(id_short)
return True
[docs]def id_shorts_of_variables_are_unique(
input_variables: Optional[Sequence[our_types.OperationVariable]],
output_variables: Optional[Sequence[our_types.OperationVariable]],
inoutput_variables: Optional[Sequence[our_types.OperationVariable]],
) -> bool:
"""
Check that the :py:attr:`.types.Referable.id_short`'s among all the
:paramref:`input_variables`, :paramref:`output_variables`
and :paramref:`inoutput_variables` are unique.
"""
id_short_set: Set[str] = set()
return (
_collect_unique_id_shorts_of_variables(input_variables, id_short_set)
and _collect_unique_id_shorts_of_variables(output_variables, id_short_set)
and _collect_unique_id_shorts_of_variables(inoutput_variables, id_short_set)
)
# noinspection SpellCheckingInspection
def _construct_specific_asset_id_name_matches_global_asset_id() -> Pattern[str]:
pattern = "^[gG][lL][oO][bB][aA][lL][aA][sS][sS][eE][tT][iI][dD]$"
return re.compile(pattern)
_REGEX_SPECIFIC_ASSET_ID_NAME_MATCHES_GLOBAL_ASSET_ID = (
_construct_specific_asset_id_name_matches_global_asset_id()
)
[docs]def specific_asset_id_name_matches_global_asset_id(name: str) -> bool:
"""
Check whether :paramref:`name` is the reserved global asset ID key.
"""
return _REGEX_SPECIFIC_ASSET_ID_NAME_MATCHES_GLOBAL_ASSET_ID.match(name) is not None
[docs]def submodel_element_has_template_qualifier_in_tree(
element: our_types.SubmodelElement,
) -> bool:
"""
Check whether :paramref:`element` or its descendants have template qualifiers.
"""
if (element.qualifiers is not None) and (
any(
qualifier.kind_or_default() == our_types.QualifierKind.TEMPLATE_QUALIFIER
for qualifier in element.qualifiers
)
):
return True
if isinstance(element, our_types.SubmodelElementList):
return (element.value is not None) and (
any(
submodel_element_has_template_qualifier_in_tree(child)
for child in element.value
)
)
if isinstance(element, our_types.SubmodelElementCollection):
return (element.value is not None) and (
any(
submodel_element_has_template_qualifier_in_tree(child)
for child in element.value
)
)
if isinstance(element, our_types.Entity):
return (element.statements is not None) and (
any(
submodel_element_has_template_qualifier_in_tree(child)
for child in element.statements
)
)
if isinstance(element, our_types.AnnotatedRelationshipElement):
return (element.annotations is not None) and (
any(
submodel_element_has_template_qualifier_in_tree(child)
for child in element.annotations
)
)
if isinstance(element, our_types.Operation):
pass
return False
[docs]def submodel_elements_have_no_template_qualifiers(
elements: Sequence[our_types.SubmodelElement],
) -> bool:
"""
Check that :paramref:`elements` have no template qualifiers in their trees.
"""
return all(
not submodel_element_has_template_qualifier_in_tree(element)
for element in elements
)
[docs]def submodel_element_lists_have_exactly_one_element_in_tree(
element: our_types.SubmodelElement,
) -> bool:
"""
Recursively check that submodel element lists have exactly one child.
"""
if isinstance(element, our_types.SubmodelElementList):
return (
(element.value is not None)
and len(element.value) == 1
and (
all(
submodel_element_lists_have_exactly_one_element_in_tree(child)
for child in element.value
)
)
)
if isinstance(element, our_types.SubmodelElementCollection):
return (element.value is None) or (
all(
submodel_element_lists_have_exactly_one_element_in_tree(child)
for child in element.value
)
)
if isinstance(element, our_types.Entity):
return (element.statements is None) or (
all(
submodel_element_lists_have_exactly_one_element_in_tree(child)
for child in element.statements
)
)
if isinstance(element, our_types.AnnotatedRelationshipElement):
return (element.annotations is None) or (
all(
submodel_element_lists_have_exactly_one_element_in_tree(child)
for child in element.annotations
)
)
return True
[docs]def submodel_element_lists_in_submodel_elements_have_exactly_one_element(
elements: Sequence[our_types.SubmodelElement],
) -> bool:
"""
Check that all submodel element lists among :paramref:`elements` have one item.
"""
return all(
submodel_element_lists_have_exactly_one_element_in_tree(element)
for element in elements
)
[docs]def submodel_element_lists_in_operation_variables_have_exactly_one_element(
input_variables: Optional[Sequence[our_types.OperationVariable]],
output_variables: Optional[Sequence[our_types.OperationVariable]],
inoutput_variables: Optional[Sequence[our_types.OperationVariable]],
) -> bool:
"""
Check that submodel element lists in operation variables have one item.
"""
return (
(
(
(input_variables is None)
or (
all(
submodel_element_lists_have_exactly_one_element_in_tree(
variable.value
)
for variable in input_variables
)
)
)
)
and (
(
(output_variables is None)
or (
all(
submodel_element_lists_have_exactly_one_element_in_tree(
variable.value
)
for variable in output_variables
)
)
)
)
and (
(
(inoutput_variables is None)
or (
all(
submodel_element_lists_have_exactly_one_element_in_tree(
variable.value
)
for variable in inoutput_variables
)
)
)
)
)
[docs]def extension_names_are_unique(extensions: Sequence[our_types.Extension]) -> bool:
"""Check that the extension names are unique."""
name_set: Set[str] = set()
for extension in extensions:
if extension.name in name_set:
return False
name_set.add(extension.name)
return True
[docs]def submodel_elements_have_identical_semantic_ids(
elements: Sequence[our_types.SubmodelElement],
) -> bool:
"""Check that all semantic IDs are identical, if specified."""
that_semantic_id: Optional[our_types.Reference] = None
for element in elements:
this_semantic_id = element.semantic_id
if this_semantic_id is None:
continue
if that_semantic_id is None:
that_semantic_id = this_semantic_id
elif not reference_key_values_equal(that_semantic_id, this_semantic_id):
return False
return True
[docs]def submodel_element_is_of_type(
element: our_types.SubmodelElement, element_type: our_types.AASSubmodelElements
) -> bool:
"""
Check that the run-time type of the :paramref:`element` coincides with
:paramref:`element_type`.
"""
if element_type == our_types.AASSubmodelElements.ANNOTATED_RELATIONSHIP_ELEMENT:
return isinstance(element, our_types.AnnotatedRelationshipElement)
elif element_type == our_types.AASSubmodelElements.BASIC_EVENT_ELEMENT:
return isinstance(element, our_types.BasicEventElement)
elif element_type == our_types.AASSubmodelElements.BLOB:
return isinstance(element, our_types.Blob)
elif element_type == our_types.AASSubmodelElements.CAPABILITY:
return isinstance(element, our_types.Capability)
elif element_type == our_types.AASSubmodelElements.DATA_ELEMENT:
return isinstance(element, our_types.DataElement)
elif element_type == our_types.AASSubmodelElements.ENTITY:
return isinstance(element, our_types.Entity)
elif element_type == our_types.AASSubmodelElements.EVENT_ELEMENT:
return isinstance(element, our_types.EventElement)
elif element_type == our_types.AASSubmodelElements.FILE:
return isinstance(element, our_types.File)
elif element_type == our_types.AASSubmodelElements.MULTI_LANGUAGE_PROPERTY:
return isinstance(element, our_types.MultiLanguageProperty)
elif element_type == our_types.AASSubmodelElements.OPERATION:
return isinstance(element, our_types.Operation)
elif element_type == our_types.AASSubmodelElements.PROPERTY:
return isinstance(element, our_types.Property)
elif element_type == our_types.AASSubmodelElements.RANGE:
return isinstance(element, our_types.Range)
elif element_type == our_types.AASSubmodelElements.REFERENCE_ELEMENT:
return isinstance(element, our_types.ReferenceElement)
elif element_type == our_types.AASSubmodelElements.RELATIONSHIP_ELEMENT:
return isinstance(element, our_types.RelationshipElement)
elif element_type == our_types.AASSubmodelElements.SUBMODEL_ELEMENT:
return True
elif element_type == our_types.AASSubmodelElements.SUBMODEL_ELEMENT_LIST:
return isinstance(element, our_types.SubmodelElementList)
elif element_type == our_types.AASSubmodelElements.SUBMODEL_ELEMENT_COLLECTION:
return isinstance(element, our_types.SubmodelElementCollection)
return False
[docs]def properties_or_ranges_have_value_type(
elements: Sequence[our_types.SubmodelElement], value_type: our_types.DataTypeDefXSD
) -> bool:
"""
Check that all the :paramref:`elements` have the :paramref:`value_type`.
"""
for element in elements:
if isinstance(element, our_types.Property) and element.value_type != value_type:
return False
if isinstance(element, our_types.Range) and element.value_type != value_type:
return False
return True
[docs]def reference_key_values_equal(
that: our_types.Reference, other: our_types.Reference
) -> bool:
"""
Check that the two references are equal by comparing their key values.
"""
if len(that.keys) != len(other.keys):
return False
for i in range(0, len(that.keys)):
if that.keys[i].value != other.keys[i].value:
return False
return True
[docs]def data_specification_iec_61360s_for_property_or_value_have_appropriate_data_type(
embedded_data_specifications: Sequence[our_types.EmbeddedDataSpecification],
) -> bool:
"""
Check that the :py:attr:`.types.DataSpecificationIEC61360.data_type` is defined
appropriately for all data specifications whose content is given as IEC 61360.
"""
return all(
not isinstance(
data_specification.data_specification_content,
our_types.DataSpecificationIEC61360,
)
or (
(
(data_specification.data_specification_content.data_type is not None)
and (
data_specification.data_specification_content.data_type
in our_constants.DATA_TYPE_IEC_61360_FOR_PROPERTY_OR_VALUE
)
)
)
for data_specification in embedded_data_specifications
)
[docs]def data_specification_iec_61360s_for_reference_have_appropriate_data_type(
embedded_data_specifications: Sequence[our_types.EmbeddedDataSpecification],
) -> bool:
"""
Check that the :py:attr:`.types.DataSpecificationIEC61360.data_type` is defined
appropriately for all data specifications whose content is given as IEC 61360.
"""
return all(
not isinstance(
data_specification.data_specification_content,
our_types.DataSpecificationIEC61360,
)
or (
(
(data_specification.data_specification_content.data_type is not None)
and (
data_specification.data_specification_content.data_type
in our_constants.DATA_TYPE_IEC_61360_FOR_REFERENCE
)
)
)
for data_specification in embedded_data_specifications
)
[docs]def data_specification_iec_61360s_for_document_have_appropriate_data_type(
embedded_data_specifications: Sequence[our_types.EmbeddedDataSpecification],
) -> bool:
"""
Check that the :py:attr:`.types.DataSpecificationIEC61360.data_type` is defined
appropriately for all data specifications whose content is given as IEC 61360.
"""
return all(
not isinstance(
data_specification.data_specification_content,
our_types.DataSpecificationIEC61360,
)
or (
(
(data_specification.data_specification_content.data_type is not None)
and (
data_specification.data_specification_content.data_type
in our_constants.DATA_TYPE_IEC_61360_FOR_DOCUMENT
)
)
)
for data_specification in embedded_data_specifications
)
[docs]def data_specification_iec_61360s_have_data_type(
embedded_data_specifications: Sequence[our_types.EmbeddedDataSpecification],
) -> bool:
"""
Check that the :py:attr:`.types.DataSpecificationIEC61360.data_type` is defined for all
data specifications whose content is given as IEC 61360.
"""
return all(
not isinstance(
data_specification.data_specification_content,
our_types.DataSpecificationIEC61360,
)
or (data_specification.data_specification_content.data_type is not None)
for data_specification in embedded_data_specifications
)
[docs]def data_specification_iec_61360s_have_value(
embedded_data_specifications: Sequence[our_types.EmbeddedDataSpecification],
) -> bool:
"""
Check that the :py:attr:`.types.DataSpecificationIEC61360.value` is defined
for all data specifications whose content is given as IEC 61360.
"""
return all(
not isinstance(
data_specification.data_specification_content,
our_types.DataSpecificationIEC61360,
)
or (data_specification.data_specification_content.value is not None)
for data_specification in embedded_data_specifications
)
[docs]def data_specification_iec_61360s_have_definition_at_least_in_english(
embedded_data_specifications: Sequence[our_types.EmbeddedDataSpecification],
) -> bool:
"""
Check that the :py:attr:`.types.DataSpecificationIEC61360.definition` is defined
for all data specifications whose content is given as IEC 61360 at least in English.
"""
for data_specification in embedded_data_specifications:
content = data_specification.data_specification_content
if not isinstance(content, our_types.DataSpecificationIEC61360):
continue
definition = content.definition
if definition is None:
return False
if not (
any(
is_bcp_47_for_english(lang_string.language)
for lang_string in definition
)
):
return False
return True
# noinspection SpellCheckingInspection
def _construct_is_bcp_47_for_english() -> Pattern[str]:
pattern = "^(en|EN)(-.*)?$"
return re.compile(pattern)
_REGEX_IS_BCP_47_FOR_ENGLISH = _construct_is_bcp_47_for_english()
[docs]def is_bcp_47_for_english(text: str) -> bool:
"""
Check that the :paramref:`text` corresponds to a BCP47 code for english.
"""
return _REGEX_IS_BCP_47_FOR_ENGLISH.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_path_item() -> Pattern[str]:
pattern = "^(([A-Za-z][A-Za-z0-9_]+)|(\\[[0-9]+\\]))((\\.[A-Za-z][A-Za-z0-9_]+)|(\\[[0-9]+\\]))*$"
return re.compile(pattern)
_REGEX_MATCHES_PATH_ITEM = _construct_matches_path_item()
[docs]def matches_path_item(text: str) -> bool:
"""
Check that :paramref:`text` is a valid idShortPath.
An idShortPath is a chain of idShorts or SubmodelElementList-indexes
which points to an element within a hierarchy of elements, *e.g.*,
``sme1.sme2[0].p1``.
"""
return _REGEX_MATCHES_PATH_ITEM.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_field_identifier() -> Pattern[str]:
array_index = "(0|[1-9][0-9]*)"
optional_index = f"\\[{array_index}?\\]"
reference_clause = f"(type|keys{optional_index}\\.(type|value))"
semantic_id_clause = f"semanticId(\\.{reference_clause})?"
supplemental_semantic_id_clause = (
f"supplementalSemanticIds({optional_index})?(\\.{reference_clause})?"
)
specific_asset_ids_clause = f"specificAssetIds{optional_index}\\.(name|value|externalSubjectId(\\.{reference_clause})?)"
endpoint_clause = (
f"endpoints{optional_index}\\.(interface|protocolinformation\\.href)"
)
sm_descriptor_clause = f"({semantic_id_clause}|{supplemental_semantic_id_clause}|idShort|id|{endpoint_clause})"
id_short = "[A-Za-z]([A-Za-z0-9_-]*[A-Za-z0-9_])?"
id_short_path_segment = f"{id_short}({optional_index})*"
id_short_path = f"{id_short_path_segment}(\\.{id_short_path_segment})*"
fields_aas = f"(idShort|id|assetInformation\\.assetKind|assetInformation\\.assetType|assetInformation\\.globalAssetId|assetInformation\\.{specific_asset_ids_clause}|submodels{optional_index}(\\.{reference_clause})?)"
fields_sm = f"({semantic_id_clause}|{supplemental_semantic_id_clause}|idShort|id)"
fields_sme = f"({semantic_id_clause}|{supplemental_semantic_id_clause}|idShort|value|valueType|language)"
fields_cd = "(idShort|id)"
fields_aas_descriptor = f"(idShort|id|assetKind|assetType|globalAssetId|{specific_asset_ids_clause}|{endpoint_clause}|submodelDescriptors{optional_index}\\.{sm_descriptor_clause})"
pattern = f"^(\\$aas#{fields_aas}|\\$sm#{fields_sm}|\\$sme(\\.{id_short_path})?#{fields_sme}|\\$cd#{fields_cd}|\\$aasdesc#{fields_aas_descriptor}|\\$smdesc#{sm_descriptor_clause})$"
return re.compile(pattern)
_REGEX_MATCHES_FIELD_IDENTIFIER = _construct_matches_field_identifier()
[docs]def matches_field_identifier(text: str) -> bool:
"""
Check that :paramref:`text` is a valid field identifier of the query language.
A field identifier starts with a root (``$aas``, ``$sm``, ``$sme``, ``$cd``,
``$aasdesc`` or ``$smdesc``), optionally followed by an idShortPath in case
of ``$sme``, and ends with an attribute declaration after ``#``, *e.g.*,
``$sme.someCollection.someProperty#value``.
See:
https://industrialdigitaltwin.io/aas-specifications/IDTA-01002/v3.2/query-language.html#query-grammar
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_FIELD_IDENTIFIER.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_fragment_field_identifier() -> Pattern[str]:
array_index = "(0|[1-9][0-9]*)"
optional_index = f"\\[{array_index}?\\]"
reference_clause = f"keys({optional_index})?"
semantic_id_clause = f"semanticId(\\.{reference_clause})?"
supplemental_semantic_id_clause = (
f"supplementalSemanticIds({optional_index}(\\.{reference_clause})?)?"
)
specific_asset_ids_clause = f"specificAssetIds({optional_index}(\\.externalSubjectId(\\.{reference_clause})?)?)?"
submodels_clause = f"submodels({optional_index}(\\.{reference_clause})?)?"
endpoint_clause = f"endpoints({optional_index})?"
sm_descriptor_clause = f"({semantic_id_clause}|{supplemental_semantic_id_clause}|idShort|{endpoint_clause})"
submodel_descriptors_clause = (
f"submodelDescriptors({optional_index}(\\.{sm_descriptor_clause})?)?"
)
id_short = "[A-Za-z]([A-Za-z0-9_-]*[A-Za-z0-9_])?"
id_short_path_segment = f"{id_short}({optional_index})*"
id_short_path = f"{id_short_path_segment}(\\.{id_short_path_segment})*"
fields_aas = f"(idShort|assetInformation\\.assetType|assetInformation\\.globalAssetId|assetInformation\\.{specific_asset_ids_clause}|{submodels_clause})"
fields_sm = f"({semantic_id_clause}|{supplemental_semantic_id_clause}|idShort)"
fields_sme = f"({semantic_id_clause}|{supplemental_semantic_id_clause}|idShort|value|valueType|language)"
fields_aas_descriptor = f"(idShort|description|displayName|extension|administration|assetKind|assetType|globalAssetId|{specific_asset_ids_clause}|{endpoint_clause}|{submodel_descriptors_clause})"
pattern = f"^(\\$aas#{fields_aas}|\\$sm#{fields_sm}|\\$sme(\\.{id_short_path})?(#{fields_sme})?|\\$cd#idShort|\\$aasdesc#{fields_aas_descriptor}|\\$smdesc#{sm_descriptor_clause})$"
return re.compile(pattern)
_REGEX_MATCHES_FRAGMENT_FIELD_IDENTIFIER = (
_construct_matches_fragment_field_identifier()
)
[docs]def matches_fragment_field_identifier(text: str) -> bool:
"""
Check that :paramref:`text` is a valid fragment field identifier.
A fragment field identifier points to the part of the returned data which
should be filtered, *e.g.*, ``$aas#assetInformation.specificAssetIds[]``
or ``$sme.someCollection``.
See:
https://industrialdigitaltwin.io/aas-specifications/IDTA-01002/v3.2/query-language.html#query-grammar
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_FRAGMENT_FIELD_IDENTIFIER.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_hex_literal() -> Pattern[str]:
pattern = "^16#[0-9A-F]+$"
return re.compile(pattern)
_REGEX_MATCHES_HEX_LITERAL = _construct_matches_hex_literal()
[docs]def matches_hex_literal(text: str) -> bool:
"""
Check that :paramref:`text` is a valid hexadecimal literal of the query language.
A hexadecimal literal is prefixed with ``16#``, *e.g.*, ``16#1F``.
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_HEX_LITERAL.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_date_time_literal() -> Pattern[str]:
digit = "[0-9]"
month_with_31_days = f"(0[13578]|1[02])-(0[1-9]|[12]{digit}|3[01])"
month_with_30_days = f"(0[469]|11)-(0[1-9]|[12]{digit}|30)"
february = f"02-(0[1-9]|1{digit}|2[0-8])"
common_date = f"{digit}{{4}}-({month_with_31_days}|{month_with_30_days}|{february})"
leap_year = (
f"({digit}{{2}}(0[48]|[2468][048]|[13579][26])|([02468][048]|[13579][26])00)"
)
leap_day = f"{leap_year}-02-29"
time = f"(([01]{digit}|2[0-3]):[0-5]{digit}(:[0-5]{digit})?(\\.{digit}+)?|24:00(:00)?(\\.0+)?)"
timezone = f"(Z|[+-]((0{digit}|1[0-3]):[0-5]{digit}|14:00))"
pattern = f"^(({common_date})|({leap_day}))T?{time}{timezone}?$"
return re.compile(pattern)
_REGEX_MATCHES_DATE_TIME_LITERAL = _construct_matches_date_time_literal()
[docs]def matches_date_time_literal(text: str) -> bool:
"""
Check that :paramref:`text` is a valid date-time literal of the query language.
A date-time literal is a valid calendar date, followed by an optional ``T``
separator, the time and an optional time zone, *e.g.*,
``2024-02-29T12:00:00Z``.
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_DATE_TIME_LITERAL.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_time_literal() -> Pattern[str]:
digit = "[0-9]"
time = f"(([01]{digit}|2[0-3]):[0-5]{digit}(:[0-5]{digit})?(\\.{digit}+)?|24:00(:00)?(\\.0+)?)"
timezone = f"(Z|[+-]((0{digit}|1[0-3]):[0-5]{digit}|14:00))"
pattern = f"^{time}{timezone}?$"
return re.compile(pattern)
_REGEX_MATCHES_TIME_LITERAL = _construct_matches_time_literal()
[docs]def matches_time_literal(text: str) -> bool:
"""
Check that :paramref:`text` is a valid time literal of the query language.
A time literal is given as ``HH:MM``, ``HH:MM:SS``, optionally with
fractional seconds and an optional time zone, *e.g.*, ``12:00:00+01:00``.
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_TIME_LITERAL.match(text) is not None
# noinspection SpellCheckingInspection
def _construct_matches_reference_identifier() -> Pattern[str]:
array_index = "(0|[1-9][0-9]*)"
optional_index = f"\\[{array_index}?\\]"
reference_clause = f"(type|keys{optional_index}\\.(type|value))"
semantic_id_clause = f"semanticId(\\.{reference_clause})?"
supplemental_semantic_id_clause = (
f"supplementalSemanticIds({optional_index})?(\\.{reference_clause})?"
)
specific_asset_ids_clause = f"specificAssetIds{optional_index}\\.(name|value|externalSubjectId(\\.{reference_clause})?)"
id_short = "[A-Za-z]([A-Za-z0-9_-]*[A-Za-z0-9_])?"
id_short_path_segment = f"{id_short}({optional_index})*"
id_short_path = f"{id_short_path_segment}(\\.{id_short_path_segment})*"
identifier_character = '([\\x09\\x0a\\x0d\\x20-\\x21\\x23-\\x5b\\x5d-\\ud7ff\\ue000-\\ufffd\\U00010000-\\U0010ffff]|\\\\["\\\\])'
identifier_instance = f'\\("{identifier_character}+"\\)'
fields_aas = f"(idShort|id|assetInformation\\.assetKind|assetInformation\\.assetType|assetInformation\\.globalAssetId|assetInformation\\.{specific_asset_ids_clause}|submodels{optional_index}(\\.{reference_clause})?)"
fields_sm = f"({semantic_id_clause}|{supplemental_semantic_id_clause}|idShort|id)"
fields_sme = f"({semantic_id_clause}|{supplemental_semantic_id_clause}|idShort|value|valueType|language)"
pattern = f"^(\\$aas{identifier_instance}#{fields_aas}|\\$sm{identifier_instance}#{fields_sm}|\\$cd{identifier_instance}#(idShort|id)|\\$sme{identifier_instance}\\.{id_short_path}#{fields_sme})$"
return re.compile(pattern)
_REGEX_MATCHES_REFERENCE_IDENTIFIER = _construct_matches_reference_identifier()
[docs]def matches_reference_identifier(text: str) -> bool:
"""
Check that :paramref:`text` is a valid reference identifier.
A reference identifier points to an attribute of a specific instance given
by its identifier, *e.g.*, ``$sm("https://example.com/sm")#idShort`` or
``$sme("https://example.com/sm").someProperty#value``. A quotation mark and
a reverse solidus in the identifier are escaped as ``\\"`` and ``\\\\``,
respectively.
See:
https://industrialdigitaltwin.io/aas-specifications/IDTA-01002/v3.2/query-language.html#query-grammar
:param text: Text to be checked
:return:
True if the :paramref:`text` conforms to the pattern
"""
return _REGEX_MATCHES_REFERENCE_IDENTIFIER.match(text) is not None
def _can_be_of_type(value: our_types.Value, value_type: str) -> bool:
"""
Check that :paramref:`value` can be used as an operand of :paramref:`value_type`.
Following the normative JSON schema of the query language, a field is
implicitly cast to the type of the other operand, and can hence be used as
an operand of any type. A global attribute giving a date and time
(``LOCALNOW``, ``UTCNOW`` or ``CLIENTNOW``) can be used both as a string and
as a date-time, while all the other attributes are strings.
See:
https://industrialdigitaltwin.io/aas-specifications/IDTA-01002/v3.2/query-language.html#_json_schema
:param value: Operand of a comparison
:param value_type:
One of ``string``, ``number``, ``hex``, ``boolean``, ``date_time``
or ``time``
:return:
True if :paramref:`value` can be used as :paramref:`value_type`
"""
if isinstance(value, our_types.FieldOperand):
return True
if isinstance(value, our_types.AttributeOperand):
if value_type == "string":
return True
attribute = value.attribute
return (
value_type == "date_time"
and isinstance(attribute, our_types.GlobalAttribute)
and (
(
attribute.kind == our_types.GlobalAttributeKind.LOCAL_NOW
or attribute.kind == our_types.GlobalAttributeKind.UTC_NOW
or attribute.kind == our_types.GlobalAttributeKind.CLIENT_NOW
)
)
)
if isinstance(value, (our_types.StringLiteral, our_types.StringCast)):
return value_type == "string"
if isinstance(
value,
(
our_types.NumberLiteral,
our_types.NumberCast,
our_types.DayOfWeek,
our_types.DayOfMonth,
our_types.Month,
our_types.Year,
),
):
return value_type == "number"
if isinstance(value, (our_types.HexLiteral, our_types.HexCast)):
return value_type == "hex"
if isinstance(value, (our_types.BooleanLiteral, our_types.BooleanCast)):
return value_type == "boolean"
if isinstance(value, (our_types.DateTimeLiteral, our_types.DateTimeCast)):
return value_type == "date_time"
if isinstance(value, (our_types.TimeLiteral, our_types.TimeCast)):
return value_type == "time"
return False
[docs]def are_equality_comparable(left: our_types.Value, right: our_types.Value) -> bool:
"""
Check that :paramref:`left` and :paramref:`right` can be compared for
(in)equality.
Following the normative JSON schema of the query language, the two operands
need to be of the same type: a string, a number, a hexadecimal, a boolean,
a date-time or a time. A field is implicitly cast to the type of the other
operand, and can hence be compared with an operand of any type. A global
attribute giving a date and time (``LOCALNOW``, ``UTCNOW`` or ``CLIENTNOW``)
can be used both as a string and as a date-time.
See:
https://industrialdigitaltwin.io/aas-specifications/IDTA-01002/v3.2/query-language.html#_json_schema
:param left: First operand of the comparison
:param right: Second operand of the comparison
:return:
True if the operands can be compared for (in)equality
"""
return (
((_can_be_of_type(left, "string") and _can_be_of_type(right, "string")))
or ((_can_be_of_type(left, "number") and _can_be_of_type(right, "number")))
or ((_can_be_of_type(left, "hex") and _can_be_of_type(right, "hex")))
or ((_can_be_of_type(left, "boolean") and _can_be_of_type(right, "boolean")))
or (
(_can_be_of_type(left, "date_time") and _can_be_of_type(right, "date_time"))
)
or ((_can_be_of_type(left, "time") and _can_be_of_type(right, "time")))
)
[docs]def are_order_comparable(left: our_types.Value, right: our_types.Value) -> bool:
"""
Check that :paramref:`left` and :paramref:`right` can be compared by order.
The operands need to be comparable for (in)equality (see
``are_equality_comparable``), but booleans can not be ordered.
See:
https://industrialdigitaltwin.io/aas-specifications/IDTA-01002/v3.2/query-language.html#_json_schema
:param left: First operand of the comparison
:param right: Second operand of the comparison
:return: True if the operands can be compared by order
"""
return (
are_equality_comparable(left, right)
and (not isinstance(left, (our_types.BooleanLiteral, our_types.BooleanCast)))
and (not isinstance(right, (our_types.BooleanLiteral, our_types.BooleanCast)))
)
class _Transformer(our_types.AbstractTransformer[Iterator[Error]]):
# noinspection PyMethodMayBeStatic
def transform_extension(self, that: our_types.Extension) -> Iterator[Error]:
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.refers_to is not None) or (len(that.refers_to) >= 1)):
yield Error("Refers-to must be either not set or have at least one item.")
if not (
not (that.value is not None)
or value_consistent_with_xsd_type(that.value, that.value_type_or_default())
):
yield Error("The value must match the value type.")
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
for error in verify_name_type(that.name):
error.path._prepend(PropertySegment(that, "name"))
yield error
if that.value is not None:
for error in verify_value_data_type(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
if that.refers_to is not None:
for error in _verify_list_of__class(that.refers_to):
error.path._prepend(PropertySegment(that, "refers_to"))
yield error
# noinspection PyMethodMayBeStatic
def transform_administrative_information(
self, that: our_types.AdministrativeInformation
) -> Iterator[Error]:
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (
not (((that.created_at is not None) and (that.updated_at is not None)))
or date_time_utc_less_or_equal_or_invalid(that.created_at, that.updated_at)
):
yield Error("Created-at must be before or equal to updated-at.")
if not (not (that.revision is not None) or (that.version is not None)):
yield Error(
"Constraint AASd-005: If version is not specified, revision "
+ "shall also be unspecified. This means that a revision "
+ "requires a version. If there is no version, there is no "
+ "revision. Revision is optional."
)
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.version is not None:
for error in verify_version_type(that.version):
error.path._prepend(PropertySegment(that, "version"))
yield error
if that.revision is not None:
for error in verify_revision_type(that.revision):
error.path._prepend(PropertySegment(that, "revision"))
yield error
if that.creator is not None:
for error in verify(that.creator):
error.path._prepend(PropertySegment(that, "creator"))
yield error
if that.created_at is not None:
for error in verify_date_time_utc(that.created_at):
error.path._prepend(PropertySegment(that, "created_at"))
yield error
if that.updated_at is not None:
for error in verify_date_time_utc(that.updated_at):
error.path._prepend(PropertySegment(that, "updated_at"))
yield error
if that.template_id is not None:
for error in verify_identifier(that.template_id):
error.path._prepend(PropertySegment(that, "template_id"))
yield error
# noinspection PyMethodMayBeStatic
def transform_qualifier(self, that: our_types.Qualifier) -> Iterator[Error]:
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (
not (that.value is not None)
or value_consistent_with_xsd_type(that.value, that.value_type)
):
yield Error(
"Constraint AASd-020: The value shall be consistent with "
+ "the data type as defined in value type."
)
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
for error in verify_qualifier_type(that.type):
error.path._prepend(PropertySegment(that, "type"))
yield error
if that.value is not None:
for error in verify_value_data_type(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
if that.value_id is not None:
for error in verify(that.value_id):
error.path._prepend(PropertySegment(that, "value_id"))
yield error
# noinspection PyMethodMayBeStatic
def transform_asset_administration_shell(
self, that: our_types.AssetAdministrationShell
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (not (that.submodels is not None) or (len(that.submodels) >= 1)):
yield Error("Submodels must be either not set or have at least one item.")
if not (
not (that.derived_from is not None)
or is_model_reference_to(
that.derived_from, our_types.KeyTypes.ASSET_ADMINISTRATION_SHELL
)
):
yield Error(
"Derived-from must be a model reference to an asset "
+ "administration shell."
)
if not (
not (that.submodels is not None)
or (
all(
is_model_reference_to(reference, our_types.KeyTypes.SUBMODEL)
for reference in that.submodels
)
)
):
yield Error("All submodels must be model references to a submodel.")
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.administration is not None:
for error in verify(that.administration):
error.path._prepend(PropertySegment(that, "administration"))
yield error
for error in verify_identifier(that.id):
error.path._prepend(PropertySegment(that, "id"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.derived_from is not None:
for error in verify(that.derived_from):
error.path._prepend(PropertySegment(that, "derived_from"))
yield error
for error in verify(that.asset_information):
error.path._prepend(PropertySegment(that, "asset_information"))
yield error
if that.submodels is not None:
for error in _verify_list_of__class(that.submodels):
error.path._prepend(PropertySegment(that, "submodels"))
yield error
# noinspection PyMethodMayBeStatic
def transform_asset_information(
self, that: our_types.AssetInformation
) -> Iterator[Error]:
if not (
not (that.specific_asset_ids is not None)
or (
all(
not specific_asset_id_name_matches_global_asset_id(
specific_asset_id.name
)
or (
(
(that.global_asset_id is not None)
and specific_asset_id.value == that.global_asset_id
)
)
for specific_asset_id in that.specific_asset_ids
)
)
):
yield Error(
"Constraint AASd-116: ``globalAssetId`` (case-insensitive) "
+ "is a reserved key. If used as value for the name of "
+ "specific asset ID then the value of specific asset ID shall "
+ "be identical to the global asset ID with semantics as "
+ "defined in "
+ "https://admin-shell.io/aas/3/x/AssetInformation/globalAssetId, "
+ "x being the minor version of the used specification."
)
if not (
(
(
(
(that.global_asset_id is not None)
or (that.specific_asset_ids is not None)
)
)
and (
not (that.specific_asset_ids is not None)
or (len(that.specific_asset_ids) >= 1)
)
)
):
yield Error(
"Constraint AASd-131: Either the global asset ID shall be "
+ "defined or at least one specific asset ID."
)
if not (
not (that.specific_asset_ids is not None)
or (len(that.specific_asset_ids) >= 1)
):
yield Error(
"Specific asset IDs must be either not set or have at least "
+ "one item."
)
if that.global_asset_id is not None:
for error in verify_identifier(that.global_asset_id):
error.path._prepend(PropertySegment(that, "global_asset_id"))
yield error
if that.specific_asset_ids is not None:
for error in _verify_list_of__class(that.specific_asset_ids):
error.path._prepend(PropertySegment(that, "specific_asset_ids"))
yield error
if that.asset_type is not None:
for error in verify_identifier(that.asset_type):
error.path._prepend(PropertySegment(that, "asset_type"))
yield error
if that.default_thumbnail is not None:
for error in verify(that.default_thumbnail):
error.path._prepend(PropertySegment(that, "default_thumbnail"))
yield error
# noinspection PyMethodMayBeStatic
def transform_resource(self, that: our_types.Resource) -> Iterator[Error]:
for error in verify_path_type(that.path):
error.path._prepend(PropertySegment(that, "path"))
yield error
if that.content_type is not None:
for error in verify_content_type(that.content_type):
error.path._prepend(PropertySegment(that, "content_type"))
yield error
# noinspection PyMethodMayBeStatic
def transform_specific_asset_id(
self, that: our_types.SpecificAssetID
) -> Iterator[Error]:
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (
not (that.external_subject_id is not None)
or (
that.external_subject_id.type
== our_types.ReferenceTypes.EXTERNAL_REFERENCE
)
):
yield Error(
"Constraint AASd-133: External subject ID shall be "
+ "an external reference."
)
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
for error in verify_label_type(that.name):
error.path._prepend(PropertySegment(that, "name"))
yield error
for error in verify_identifier(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
if that.external_subject_id is not None:
for error in verify(that.external_subject_id):
error.path._prepend(PropertySegment(that, "external_subject_id"))
yield error
# noinspection PyMethodMayBeStatic
def transform_submodel(self, that: our_types.Submodel) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (
not (that.submodel_elements is not None)
or (len(that.submodel_elements) >= 1)
):
yield Error(
"Submodel elements must be either not set or have at least "
+ "one item."
)
if not (
not (that.submodel_elements is not None)
or (all(item.id_short is not None for item in that.submodel_elements))
):
yield Error(
"ID-shorts need to be defined for all the items of submodel "
+ "elements according to AASd-117 (ID-short of "
+ "non-identifiable Referables not being a direct child of "
+ "a Submodel element list shall be specified)."
)
if not (
not (that.submodel_elements is not None)
or id_shorts_are_unique(that.submodel_elements)
):
yield Error(
"Constraint AASd-022: ID-short of non-identifiable "
+ "referables within the same name space shall be unique "
+ "(case-sensitive)."
)
if not (
not (that.kind_or_default() == our_types.ModellingKind.TEMPLATE)
or (
(
(that.submodel_elements is not None)
and submodel_element_lists_in_submodel_elements_have_exactly_one_element(
that.submodel_elements
)
)
)
):
yield Error(
"Constraint AASd-138: A submodel element list within "
+ "a submodel of kind Template or as part of an operation "
+ "variable shall have exactly one element."
)
if not (
not (that.submodel_elements is not None)
or (
not (that.kind_or_default() != our_types.ModellingKind.TEMPLATE)
or submodel_elements_have_no_template_qualifiers(that.submodel_elements)
)
):
yield Error(
"Constraint AASd-129: If any kind value of a qualifier "
+ "(attribute qualifier inherited via Qualifiable) is equal to "
+ "TemplateQualifier, the submodel element shall be part of "
+ "a submodel template, i.e. a submodel with kind (attribute "
+ "kind inherited via Has-Kind) value equal to Template. "
+ "Exception: the submodel element is part of an operation "
+ "variable."
)
if not (
not (that.qualifiers is not None)
or (
not (
any(
qualifier.kind_or_default()
== our_types.QualifierKind.TEMPLATE_QUALIFIER
for qualifier in that.qualifiers
)
)
or (that.kind_or_default() == our_types.ModellingKind.TEMPLATE)
)
):
yield Error(
"Constraint AASd-119: If any qualifier kind value of "
+ "a qualifiable qualifier is equal to template qualifier and "
+ "the qualified element has kind then the qualified element "
+ "shall be of kind template."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.administration is not None:
for error in verify(that.administration):
error.path._prepend(PropertySegment(that, "administration"))
yield error
for error in verify_identifier(that.id):
error.path._prepend(PropertySegment(that, "id"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.submodel_elements is not None:
for error in _verify_list_of__class(that.submodel_elements):
error.path._prepend(PropertySegment(that, "submodel_elements"))
yield error
# noinspection PyMethodMayBeStatic
def transform_relationship_element(
self, that: our_types.RelationshipElement
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.first is not None:
for error in verify(that.first):
error.path._prepend(PropertySegment(that, "first"))
yield error
if that.second is not None:
for error in verify(that.second):
error.path._prepend(PropertySegment(that, "second"))
yield error
# noinspection PyMethodMayBeStatic
def transform_submodel_element_list(
self, that: our_types.SubmodelElementList
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (not (that.value is not None) or (len(that.value) >= 1)):
yield Error("Value must be either not set or have at least one item.")
if not (
not (
(
(that.value is not None)
and (that.semantic_id_list_element is not None)
)
)
or (
all(
not (child.semantic_id is not None)
or reference_key_values_equal(
child.semantic_id, that.semantic_id_list_element
)
for child in that.value
)
)
):
yield Error(
"Constraint AASd-107: If a first level child element has "
+ "a semantic ID it shall be identical to semantic ID list "
+ "element."
)
if not (
not (that.value is not None)
or submodel_elements_have_identical_semantic_ids(that.value)
):
yield Error(
"Constraint AASd-114: If two first level child elements have "
+ "a semantic ID then they shall be identical."
)
if not (
not (that.value is not None)
or (
all(
submodel_element_is_of_type(element, that.type_value_list_element)
for element in that.value
)
)
):
yield Error(
"Constraint AASd-108: All first level child elements shall "
+ "have the same submodel element type as specified in type "
+ "value list element."
)
if not (
not (
(
(that.value is not None)
and (
(
that.type_value_list_element
== our_types.AASSubmodelElements.PROPERTY
or that.type_value_list_element
== our_types.AASSubmodelElements.RANGE
)
)
)
)
or (
(
(that.value_type_list_element is not None)
and properties_or_ranges_have_value_type(
that.value, that.value_type_list_element
)
)
)
):
yield Error(
"Constraint AASd-109: If type value list element is equal to "
+ "Property or Range value type list element shall be set and "
+ "all first level child elements shall have the value type as "
+ "specified in value type list element."
)
if not (not (that.value is not None) or id_shorts_are_unique(that.value)):
yield Error("ID-shorts of the value must be unique.")
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.semantic_id_list_element is not None:
for error in verify(that.semantic_id_list_element):
error.path._prepend(PropertySegment(that, "semantic_id_list_element"))
yield error
if that.value is not None:
for error in _verify_list_of__class(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
# noinspection PyMethodMayBeStatic
def transform_submodel_element_collection(
self, that: our_types.SubmodelElementCollection
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (not (that.value is not None) or (len(that.value) >= 1)):
yield Error("Value must be either not set or have at least one item.")
if not (
not (that.value is not None)
or (all(item.id_short is not None for item in that.value))
):
yield Error(
"ID-shorts need to be defined for all the items of value "
+ "according to AASd-117 (ID-short of non-identifiable "
+ "Referables not being a direct child of a Submodel element "
+ "list shall be specified)."
)
if not (not (that.value is not None) or id_shorts_are_unique(that.value)):
yield Error("ID-shorts of the value must be unique.")
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.value is not None:
for error in _verify_list_of__class(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
# noinspection PyMethodMayBeStatic
def transform_property(self, that: our_types.Property) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (
not (that.value is not None)
or value_consistent_with_xsd_type(that.value, that.value_type)
):
yield Error("Value must be consistent with the value type.")
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.value is not None:
for error in verify_value_data_type(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
if that.value_id is not None:
for error in verify(that.value_id):
error.path._prepend(PropertySegment(that, "value_id"))
yield error
# noinspection PyMethodMayBeStatic
def transform_multi_language_property(
self, that: our_types.MultiLanguageProperty
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (
not (that.value is not None)
or lang_strings_have_unique_languages(that.value)
):
yield Error("Value must specify unique languages.")
if not (not (that.value is not None) or (len(that.value) >= 1)):
yield Error("Value must be either not set or have at least one item.")
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.value is not None:
for error in _verify_list_of__class(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
if that.value_id is not None:
for error in verify(that.value_id):
error.path._prepend(PropertySegment(that, "value_id"))
yield error
# noinspection PyMethodMayBeStatic
def transform_range(self, that: our_types.Range) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (
not (that.max is not None)
or value_consistent_with_xsd_type(that.max, that.value_type)
):
yield Error("Max must be consistent with the value type.")
if not (
not (that.min is not None)
or value_consistent_with_xsd_type(that.min, that.value_type)
):
yield Error("Min must be consistent with the value type.")
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.min is not None:
for error in verify_value_data_type(that.min):
error.path._prepend(PropertySegment(that, "min"))
yield error
if that.max is not None:
for error in verify_value_data_type(that.max):
error.path._prepend(PropertySegment(that, "max"))
yield error
# noinspection PyMethodMayBeStatic
def transform_reference_element(
self, that: our_types.ReferenceElement
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.value is not None:
for error in verify(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
# noinspection PyMethodMayBeStatic
def transform_blob(self, that: our_types.Blob) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.value is not None:
for error in verify_blob_type(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
if that.content_type is not None:
for error in verify_content_type(that.content_type):
error.path._prepend(PropertySegment(that, "content_type"))
yield error
# noinspection PyMethodMayBeStatic
def transform_file(self, that: our_types.File) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.value is not None:
for error in verify_path_type(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
if that.content_type is not None:
for error in verify_content_type(that.content_type):
error.path._prepend(PropertySegment(that, "content_type"))
yield error
# noinspection PyMethodMayBeStatic
def transform_annotated_relationship_element(
self, that: our_types.AnnotatedRelationshipElement
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (not (that.annotations is not None) or (len(that.annotations) >= 1)):
yield Error(
"Annotations must be either not set or have at least one " + "item."
)
if not (
not (that.annotations is not None)
or (all(item.id_short is not None for item in that.annotations))
):
yield Error(
"ID-shorts need to be defined for all the items of "
+ "annotations according to AASd-117 (ID-short of "
+ "non-identifiable Referables not being a direct child of "
+ "a Submodel element list shall be specified)."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.first is not None:
for error in verify(that.first):
error.path._prepend(PropertySegment(that, "first"))
yield error
if that.second is not None:
for error in verify(that.second):
error.path._prepend(PropertySegment(that, "second"))
yield error
if that.annotations is not None:
for error in _verify_list_of__class(that.annotations):
error.path._prepend(PropertySegment(that, "annotations"))
yield error
# noinspection PyMethodMayBeStatic
def transform_entity(self, that: our_types.Entity) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (not (that.statements is not None) or (len(that.statements) >= 1)):
yield Error("Statements must be either not set or have at least one item.")
if not (
not (that.statements is not None)
or (all(item.id_short is not None for item in that.statements))
):
yield Error(
"ID-shorts need to be defined for all the items of "
+ "statements according to AASd-117 (ID-short of "
+ "non-identifiable Referables not being a direct child of "
+ "a Submodel element list shall be specified)."
)
if not (
not (that.entity_type is not None)
or (
not (that.entity_type == our_types.EntityType.SELF_MANAGED_ENTITY)
or (
(
(
(
(that.global_asset_id is not None)
and (that.specific_asset_ids is None)
)
)
or (
(
(that.global_asset_id is None)
and (that.specific_asset_ids is not None)
and len(that.specific_asset_ids) >= 1
)
)
)
)
)
):
yield Error(
"Constraint AASd-014: Either the attribute global asset ID "
+ "or specific asset ID must be set if Entity/entityType is "
+ "set to :attr:`Entity_type.Self_managed_entity`."
)
if not (
not (that.specific_asset_ids is not None)
or (len(that.specific_asset_ids) >= 1)
):
yield Error(
"Specific asset IDs must be either not set or have at least "
+ "one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.statements is not None:
for error in _verify_list_of__class(that.statements):
error.path._prepend(PropertySegment(that, "statements"))
yield error
if that.global_asset_id is not None:
for error in verify_identifier(that.global_asset_id):
error.path._prepend(PropertySegment(that, "global_asset_id"))
yield error
if that.specific_asset_ids is not None:
for error in _verify_list_of__class(that.specific_asset_ids):
error.path._prepend(PropertySegment(that, "specific_asset_ids"))
yield error
# noinspection PyMethodMayBeStatic
def transform_event_payload(self, that: our_types.EventPayload) -> Iterator[Error]:
if not (
(
is_model_reference_to(that.source, our_types.KeyTypes.EVENT_ELEMENT)
or is_model_reference_to(
that.source, our_types.KeyTypes.BASIC_EVENT_ELEMENT
)
)
):
yield Error("Source must be a model reference to an Event element.")
if not (is_model_reference_to_referable(that.observable_reference)):
yield Error(
"Observable reference must be a model reference to " + "a referable."
)
for error in verify(that.source):
error.path._prepend(PropertySegment(that, "source"))
yield error
if that.source_semantic_id is not None:
for error in verify(that.source_semantic_id):
error.path._prepend(PropertySegment(that, "source_semantic_id"))
yield error
for error in verify(that.observable_reference):
error.path._prepend(PropertySegment(that, "observable_reference"))
yield error
if that.observable_semantic_id is not None:
for error in verify(that.observable_semantic_id):
error.path._prepend(PropertySegment(that, "observable_semantic_id"))
yield error
if that.topic is not None:
for error in verify_message_topic_type(that.topic):
error.path._prepend(PropertySegment(that, "topic"))
yield error
if that.subject_id is not None:
for error in verify(that.subject_id):
error.path._prepend(PropertySegment(that, "subject_id"))
yield error
for error in verify_date_time_utc(that.time_stamp):
error.path._prepend(PropertySegment(that, "time_stamp"))
yield error
if that.payload is not None:
for error in verify_blob_type(that.payload):
error.path._prepend(PropertySegment(that, "payload"))
yield error
# noinspection PyMethodMayBeStatic
def transform_basic_event_element(
self, that: our_types.BasicEventElement
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (
not (that.direction == our_types.Direction.INPUT)
or (that.max_interval is None)
):
yield Error("Max. interval is not applicable for input direction.")
if not is_model_reference_to_referable(that.observed):
yield Error("Observed must be a model reference to a referable.")
if not (
not (that.message_broker is not None)
or is_model_reference_to_referable(that.message_broker)
):
yield Error("Message broker must be a model reference to a referable.")
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
for error in verify(that.observed):
error.path._prepend(PropertySegment(that, "observed"))
yield error
if that.message_topic is not None:
for error in verify_message_topic_type(that.message_topic):
error.path._prepend(PropertySegment(that, "message_topic"))
yield error
if that.message_broker is not None:
for error in verify(that.message_broker):
error.path._prepend(PropertySegment(that, "message_broker"))
yield error
if that.last_update is not None:
for error in verify_date_time_utc(that.last_update):
error.path._prepend(PropertySegment(that, "last_update"))
yield error
if that.min_interval is not None:
for error in verify_duration(that.min_interval):
error.path._prepend(PropertySegment(that, "min_interval"))
yield error
if that.max_interval is not None:
for error in verify_duration(that.max_interval):
error.path._prepend(PropertySegment(that, "max_interval"))
yield error
# noinspection PyMethodMayBeStatic
def transform_operation(self, that: our_types.Operation) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (
submodel_element_lists_in_operation_variables_have_exactly_one_element(
that.input_variables, that.output_variables, that.inoutput_variables
)
):
yield Error(
"Constraint AASd-138: A submodel element list within "
+ "a submodel of kind Template or as part of an operation "
+ "variable shall have exactly one element."
)
if not (
id_shorts_of_variables_are_unique(
that.input_variables, that.output_variables, that.inoutput_variables
)
):
yield Error(
"Constraint AASd-134: For an Operation the ID-short of all "
+ "values of input, output and in/output variables shall be "
+ "unique."
)
if not (
not (that.input_variables is not None) or (len(that.input_variables) >= 1)
):
yield Error(
"Input variables must be either not set or have at least one " + "item."
)
if not (
not (that.output_variables is not None) or (len(that.output_variables) >= 1)
):
yield Error(
"Output variables must be either not set or have at least "
+ "one item."
)
if not (
not (that.inoutput_variables is not None)
or (len(that.inoutput_variables) >= 1)
):
yield Error(
"Inoutput variables must be either not set or have at least "
+ "one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.input_variables is not None:
for error in _verify_list_of__class(that.input_variables):
error.path._prepend(PropertySegment(that, "input_variables"))
yield error
if that.output_variables is not None:
for error in _verify_list_of__class(that.output_variables):
error.path._prepend(PropertySegment(that, "output_variables"))
yield error
if that.inoutput_variables is not None:
for error in _verify_list_of__class(that.inoutput_variables):
error.path._prepend(PropertySegment(that, "inoutput_variables"))
yield error
# noinspection PyMethodMayBeStatic
def transform_operation_variable(
self, that: our_types.OperationVariable
) -> Iterator[Error]:
if not (that.value.id_short is not None):
yield Error(
"Value must have the ID-short specified according to "
+ "Constraint AASd-117 (ID-short of non-identifiable "
+ "Referables not being a direct child of a Submodel element "
+ "list shall be specified)."
)
for error in verify(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
# noinspection PyMethodMayBeStatic
def transform_capability(self, that: our_types.Capability) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_concept_description(
self, that: our_types.ConceptDescription
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (not (that.is_case_of is not None) or (len(that.is_case_of) >= 1)):
yield Error("Is-case-of must be either not set or have at least one item.")
if not (
not (that.embedded_data_specifications is not None)
or (
(
data_specification_iec_61360s_have_definition_at_least_in_english(
that.embedded_data_specifications
)
or data_specification_iec_61360s_have_value(
that.embedded_data_specifications
)
)
)
):
yield Error(
"Constraint AASc-3a-008: For a concept description using "
+ "data specification template IEC 61360, the definition is "
+ "mandatory and shall be defined at least in English. "
+ "Exception: The concept description describes a value."
)
if not (
not (
(
(that.category is not None)
and that.category == "QUALIFIER_TYPE"
and (that.embedded_data_specifications is not None)
)
)
or data_specification_iec_61360s_have_data_type(
that.embedded_data_specifications
)
):
yield Error(
"Constraint AASc-3a-007: For a concept description with "
+ "category QUALIFIER_TYPE using data specification IEC 61360, "
+ "the data type of the data specification is mandatory and "
+ "shall be defined."
)
if not (
not (
(
(that.category is not None)
and that.category == "DOCUMENT"
and (that.embedded_data_specifications is not None)
)
)
or data_specification_iec_61360s_for_document_have_appropriate_data_type(
that.embedded_data_specifications
)
):
yield Error(
"Constraint AASc-3a-006: For a concept description with "
+ "category DOCUMENT using data specification IEC 61360, "
+ "the data type of the data specification shall be one of: "
+ "FILE, BLOB, HTML."
)
if not (
not (
(
(that.category is not None)
and that.category == "REFERENCE"
and (that.embedded_data_specifications is not None)
)
)
or data_specification_iec_61360s_for_reference_have_appropriate_data_type(
that.embedded_data_specifications
)
):
yield Error(
"Constraint AASc-3a-005: For a concept description with "
+ "category REFERENCE using data specification IEC 61360, "
+ "the data type of the data specification shall be one of: "
+ "STRING, IRI, IRDI."
)
if not (
not (
(
(that.category is not None)
and ((that.category == "PROPERTY" or that.category == "VALUE"))
and (that.embedded_data_specifications is not None)
)
)
or data_specification_iec_61360s_for_property_or_value_have_appropriate_data_type(
that.embedded_data_specifications
)
):
yield Error(
"Constraint AASc-3a-004: For a concept description with "
+ "category PROPERTY or VALUE using data specification IEC "
+ "61360, the data type of the data specification is mandatory "
+ "and shall be one of: DATE, STRING, STRING_TRANSLATABLE, "
+ "INTEGER_MEASURE, INTEGER_COUNT, INTEGER_CURRENCY, "
+ "REAL_MEASURE, REAL_COUNT, REAL_CURRENCY, BOOLEAN, RATIONAL, "
+ "RATIONAL_MEASURE, TIME, TIMESTAMP."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.administration is not None:
for error in verify(that.administration):
error.path._prepend(PropertySegment(that, "administration"))
yield error
for error in verify_identifier(that.id):
error.path._prepend(PropertySegment(that, "id"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.is_case_of is not None:
for error in _verify_list_of__class(that.is_case_of):
error.path._prepend(PropertySegment(that, "is_case_of"))
yield error
# noinspection PyMethodMayBeStatic
def transform_reference(self, that: our_types.Reference) -> Iterator[Error]:
if not (len(that.keys) >= 1):
yield Error("Keys must contain at least one item.")
if not (
not (len(that.keys) >= 1)
or (that.keys[0].type in our_constants.GLOBALLY_IDENTIFIABLES)
):
yield Error(
"Constraint AASd-121: For References the value of type of "
+ "the first key of keys shall be one of Globally "
+ "Identifiables."
)
if not (
not (
(
that.type == our_types.ReferenceTypes.EXTERNAL_REFERENCE
and len(that.keys) >= 1
)
)
or (that.keys[0].type in our_constants.GENERIC_GLOBALLY_IDENTIFIABLES)
):
yield Error(
"Constraint AASd-122: For external references the value of "
+ "type of the first key of keys shall be one of Generic "
+ "Globally Identifiables."
)
if not (
not (
(
that.type == our_types.ReferenceTypes.MODEL_REFERENCE
and len(that.keys) >= 1
)
)
or (that.keys[0].type in our_constants.AAS_IDENTIFIABLES)
):
yield Error(
"Constraint AASd-123: For model references the value of type "
+ "of the first key of keys shall be one of AAS identifiables."
)
if not (
not (that.type == our_types.ReferenceTypes.EXTERNAL_REFERENCE)
or (
all(not (key.type in our_constants.AAS_REFERABLES) for key in that.keys)
)
):
yield Error(
"Constraint AASd-137: For external references, i.e. "
+ "References with Reference/type = ExternalReference, "
+ "the value of Key/type of any key in Reference/keys shall "
+ "not be one of AAS referables."
)
if not (
not (
(
that.type == our_types.ReferenceTypes.EXTERNAL_REFERENCE
and len(that.keys) >= 1
)
)
or (
(
(that.keys[-1].type in our_constants.GENERIC_GLOBALLY_IDENTIFIABLES)
or (that.keys[-1].type in our_constants.GENERIC_FRAGMENT_KEYS)
)
)
):
yield Error(
"Constraint AASd-124: For external references the last key "
+ "of keys shall be either one of Generic Globally "
+ "Identifiables or one of Generic Fragment Keys."
)
if not (
not (
(
that.type == our_types.ReferenceTypes.MODEL_REFERENCE
and len(that.keys) > 1
)
)
or (
all(
that.keys[i].type in our_constants.FRAGMENT_KEYS
for i in range(1, len(that.keys))
)
)
):
yield Error(
"Constraint AASd-125: For model references with more than "
+ "one key in keys the value of type of each of the keys "
+ "following the first key of keys shall be one of Fragment "
+ "Keys."
)
if not (
not (
(
that.type == our_types.ReferenceTypes.MODEL_REFERENCE
and len(that.keys) > 1
)
)
or (
all(
not (that.keys[i].type in our_constants.GENERIC_FRAGMENT_KEYS)
for i in range(0, len(that.keys) - 1)
)
)
):
yield Error(
"Constraint AASd-126: For model references with more than "
+ "one key in keys the value of type of the last key in "
+ "the reference key chain may be one of Generic Fragment Keys "
+ "or no key at all shall have a value out of Generic Fragment "
+ "Keys."
)
if not (
not (
(
that.type == our_types.ReferenceTypes.MODEL_REFERENCE
and len(that.keys) > 1
and that.keys[-1].type == our_types.KeyTypes.FRAGMENT_REFERENCE
)
)
or (
(
that.keys[-2].type == our_types.KeyTypes.FILE
or that.keys[-2].type == our_types.KeyTypes.BLOB
)
)
):
yield Error(
"Constraint AASd-127: For model references, with more than "
+ "one key in keys a key with type Fragment Reference shall be "
+ "preceded by a key with type File or Blob."
)
if not (
not (
(
that.type == our_types.ReferenceTypes.MODEL_REFERENCE
and len(that.keys) > 2
)
)
or (
all(
not (that.keys[i].type == our_types.KeyTypes.SUBMODEL_ELEMENT_LIST)
or matches_xs_non_negative_integer(that.keys[i + 1].value)
for i in range(0, len(that.keys) - 1)
)
)
):
yield Error(
"Constraint AASd-128: For model references, the value of "
+ "a key preceded by a key with type Submodel element list is "
+ "an integer number denoting the position in the array of "
+ "the submodel element list."
)
if that.referred_semantic_id is not None:
for error in verify(that.referred_semantic_id):
error.path._prepend(PropertySegment(that, "referred_semantic_id"))
yield error
for error in _verify_list_of__class(that.keys):
error.path._prepend(PropertySegment(that, "keys"))
yield error
# noinspection PyMethodMayBeStatic
def transform_key(self, that: our_types.Key) -> Iterator[Error]:
for error in verify_identifier(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
# noinspection PyMethodMayBeStatic
def transform_lang_string_name_type(
self, that: our_types.LangStringNameType
) -> Iterator[Error]:
if not (len(that.text) <= 128):
yield Error("String shall have a maximum length of 128 characters.")
for error in verify_bcp_47_language_tag(that.language):
error.path._prepend(PropertySegment(that, "language"))
yield error
for error in verify_non_empty_xml_serializable_string(that.text):
error.path._prepend(PropertySegment(that, "text"))
yield error
# noinspection PyMethodMayBeStatic
def transform_lang_string_text_type(
self, that: our_types.LangStringTextType
) -> Iterator[Error]:
if not (len(that.text) <= 1023):
yield Error("String shall have a maximum length of 1023 characters.")
for error in verify_bcp_47_language_tag(that.language):
error.path._prepend(PropertySegment(that, "language"))
yield error
for error in verify_non_empty_xml_serializable_string(that.text):
error.path._prepend(PropertySegment(that, "text"))
yield error
# noinspection PyMethodMayBeStatic
def transform_environment(self, that: our_types.Environment) -> Iterator[Error]:
if not (
not (that.concept_descriptions is not None)
or (len(that.concept_descriptions) >= 1)
):
yield Error(
"Concept descriptions must be either not set or have at "
+ "least one item."
)
if not (not (that.submodels is not None) or (len(that.submodels) >= 1)):
yield Error("Submodels must be either not set or have at least one item.")
if not (
not (that.asset_administration_shells is not None)
or (len(that.asset_administration_shells) >= 1)
):
yield Error(
"Asset administration shells must be either not set or have "
+ "at least one item."
)
if that.asset_administration_shells is not None:
for error in _verify_list_of__class(that.asset_administration_shells):
error.path._prepend(
PropertySegment(that, "asset_administration_shells")
)
yield error
if that.submodels is not None:
for error in _verify_list_of__class(that.submodels):
error.path._prepend(PropertySegment(that, "submodels"))
yield error
if that.concept_descriptions is not None:
for error in _verify_list_of__class(that.concept_descriptions):
error.path._prepend(PropertySegment(that, "concept_descriptions"))
yield error
# noinspection PyMethodMayBeStatic
def transform_embedded_data_specification(
self, that: our_types.EmbeddedDataSpecification
) -> Iterator[Error]:
for error in verify(that.data_specification):
error.path._prepend(PropertySegment(that, "data_specification"))
yield error
for error in verify(that.data_specification_content):
error.path._prepend(PropertySegment(that, "data_specification_content"))
yield error
# noinspection PyMethodMayBeStatic
def transform_level_type(self, that: our_types.LevelType) -> Iterator[Error]:
# No verification has been defined for LevelType.
return
# For this uncommon return-yield construction, see:
# https://stackoverflow.com/questions/13243766/how-to-define-an-empty-generator-function
# noinspection PyUnreachableCode
yield
# noinspection PyMethodMayBeStatic
def transform_value_reference_pair(
self, that: our_types.ValueReferencePair
) -> Iterator[Error]:
for error in verify_value_type_iec_61360(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
if that.value_id is not None:
for error in verify(that.value_id):
error.path._prepend(PropertySegment(that, "value_id"))
yield error
# noinspection PyMethodMayBeStatic
def transform_value_list(self, that: our_types.ValueList) -> Iterator[Error]:
if not (len(that.value_reference_pairs) >= 1):
yield Error("Value reference pair types must contain at least one item.")
for error in _verify_list_of__class(that.value_reference_pairs):
error.path._prepend(PropertySegment(that, "value_reference_pairs"))
yield error
# noinspection PyMethodMayBeStatic
def transform_lang_string_preferred_name_type_iec_61360(
self, that: our_types.LangStringPreferredNameTypeIEC61360
) -> Iterator[Error]:
if not (len(that.text) <= 255):
yield Error("String shall have a maximum length of 255 characters.")
for error in verify_bcp_47_language_tag(that.language):
error.path._prepend(PropertySegment(that, "language"))
yield error
for error in verify_non_empty_xml_serializable_string(that.text):
error.path._prepend(PropertySegment(that, "text"))
yield error
# noinspection PyMethodMayBeStatic
def transform_lang_string_short_name_type_iec_61360(
self, that: our_types.LangStringShortNameTypeIEC61360
) -> Iterator[Error]:
if not (len(that.text) <= 18):
yield Error("String shall have a maximum length of 18 characters.")
for error in verify_bcp_47_language_tag(that.language):
error.path._prepend(PropertySegment(that, "language"))
yield error
for error in verify_non_empty_xml_serializable_string(that.text):
error.path._prepend(PropertySegment(that, "text"))
yield error
# noinspection PyMethodMayBeStatic
def transform_lang_string_definition_type_iec_61360(
self, that: our_types.LangStringDefinitionTypeIEC61360
) -> Iterator[Error]:
if not (len(that.text) <= 1023):
yield Error("String shall have a maximum length of 1023 characters.")
for error in verify_bcp_47_language_tag(that.language):
error.path._prepend(PropertySegment(that, "language"))
yield error
for error in verify_non_empty_xml_serializable_string(that.text):
error.path._prepend(PropertySegment(that, "text"))
yield error
# noinspection PyMethodMayBeStatic
def transform_lang_string_uom(
self, that: our_types.LangStringUom
) -> Iterator[Error]:
if not (len(that.text) <= 256):
yield Error("String shall have a maximum length of 256 characters.")
for error in verify_bcp_47_language_tag(that.language):
error.path._prepend(PropertySegment(that, "language"))
yield error
for error in verify_non_empty_xml_serializable_string(that.text):
error.path._prepend(PropertySegment(that, "text"))
yield error
# noinspection PyMethodMayBeStatic
def transform_definition_type_uom(
self, that: our_types.DefinitionTypeUom
) -> Iterator[Error]:
if not (len(that.text) <= 2048):
yield Error("String shall have a maximum length of 2048 characters.")
for error in verify_bcp_47_language_tag(that.language):
error.path._prepend(PropertySegment(that, "language"))
yield error
for error in verify_non_empty_xml_serializable_string(that.text):
error.path._prepend(PropertySegment(that, "text"))
yield error
# noinspection PyMethodMayBeStatic
def transform_data_specification_uom(
self, that: our_types.DataSpecificationUom
) -> Iterator[Error]:
if not (
not (that.preferred_name_quantity is not None)
or (len(that.preferred_name_quantity) >= 1)
):
yield Error(
"Preferred name quantity must be either not set or have at "
+ "least one item."
)
if not (
not (that.preferred_name_quantity is not None)
or lang_strings_have_unique_languages(that.preferred_name_quantity)
):
yield Error("Preferred name quantity must specify unique languages.")
if not (not (that.definition is not None) or (len(that.definition) >= 1)):
yield Error("Definition must be either not set or have at least one item.")
if not (
not (that.definition is not None)
or lang_strings_have_unique_languages(that.definition)
):
yield Error("Definition must specify unique languages.")
if not (len(that.preferred_name) >= 1):
yield Error("Preferred name must have at least one item.")
if not (lang_strings_have_unique_languages(that.preferred_name)):
yield Error("Preferred name must specify unique languages.")
for error in _verify_list_of__class(that.preferred_name):
error.path._prepend(PropertySegment(that, "preferred_name"))
yield error
for error in verify_string_uom(that.symbol):
error.path._prepend(PropertySegment(that, "symbol"))
yield error
if that.specific_unit_id is not None:
for error in verify_string_uom(that.specific_unit_id):
error.path._prepend(PropertySegment(that, "specific_unit_id"))
yield error
if that.definition is not None:
for error in _verify_list_of__class(that.definition):
error.path._prepend(PropertySegment(that, "definition"))
yield error
if that.preferred_name_quantity is not None:
for error in _verify_list_of__class(that.preferred_name_quantity):
error.path._prepend(PropertySegment(that, "preferred_name_quantity"))
yield error
if that.quantity_id is not None:
for error in verify_identifier_uom(that.quantity_id):
error.path._prepend(PropertySegment(that, "quantity_id"))
yield error
if that.classification_system is not None:
for error in verify_string_uom(that.classification_system):
error.path._prepend(PropertySegment(that, "classification_system"))
yield error
if that.classification_system_version is not None:
for error in verify_string_uom(that.classification_system_version):
error.path._prepend(
PropertySegment(that, "classification_system_version")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_data_specification_iec_61360(
self, that: our_types.DataSpecificationIEC61360
) -> Iterator[Error]:
if not (not (((that.value is not None) and (that.value_list is not None)))):
yield Error(
"Constraint AASc-3a-010: If value is not empty then value "
+ "list shall be empty and vice versa."
)
if not (
not (
(
(that.data_type is not None)
and (that.data_type in our_constants.IEC_61360_DATA_TYPES_WITH_UNIT)
)
)
or (((that.unit is not None) or (that.unit_id is not None)))
):
yield Error(
"Constraint AASc-3a-009: If data type is a an integer, real "
+ "or rational with a measure or currency, unit or unit ID "
+ "shall be defined."
)
if not (not (that.definition is not None) or (len(that.definition) >= 1)):
yield Error("Definition must be either not set or have at least one item.")
if not (
not (that.definition is not None)
or lang_strings_have_unique_languages(that.definition)
):
yield Error("Definition must specify unique languages.")
if not (not (that.short_name is not None) or (len(that.short_name) >= 1)):
yield Error("Short name must be either not set or have at least one item.")
if not (
not (that.short_name is not None)
or lang_strings_have_unique_languages(that.short_name)
):
yield Error("Short name must specify unique languages.")
if not (len(that.preferred_name) >= 1):
yield Error("Preferred name must have at least one item.")
if not (lang_strings_have_unique_languages(that.preferred_name)):
yield Error("Preferred name must specify unique languages.")
if not (
any(
is_bcp_47_for_english(lang_string.language)
for lang_string in that.preferred_name
)
):
yield Error(
"Constraint AASc-002: preferred name shall be provided at "
+ "least in English."
)
for error in _verify_list_of__class(that.preferred_name):
error.path._prepend(PropertySegment(that, "preferred_name"))
yield error
if that.short_name is not None:
for error in _verify_list_of__class(that.short_name):
error.path._prepend(PropertySegment(that, "short_name"))
yield error
if that.unit is not None:
for error in verify_non_empty_xml_serializable_string(that.unit):
error.path._prepend(PropertySegment(that, "unit"))
yield error
if that.unit_id is not None:
for error in verify(that.unit_id):
error.path._prepend(PropertySegment(that, "unit_id"))
yield error
if that.source_of_definition is not None:
for error in verify_non_empty_xml_serializable_string(
that.source_of_definition
):
error.path._prepend(PropertySegment(that, "source_of_definition"))
yield error
if that.symbol is not None:
for error in verify_non_empty_xml_serializable_string(that.symbol):
error.path._prepend(PropertySegment(that, "symbol"))
yield error
if that.definition is not None:
for error in _verify_list_of__class(that.definition):
error.path._prepend(PropertySegment(that, "definition"))
yield error
if that.value_format is not None:
for error in verify_non_empty_xml_serializable_string(that.value_format):
error.path._prepend(PropertySegment(that, "value_format"))
yield error
if that.value_list is not None:
for error in verify(that.value_list):
error.path._prepend(PropertySegment(that, "value_list"))
yield error
if that.value is not None:
for error in verify_value_type_iec_61360(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
if that.level_type is not None:
for error in verify(that.level_type):
error.path._prepend(PropertySegment(that, "level_type"))
yield error
# noinspection PyMethodMayBeStatic
def transform_asset_administration_shell_descriptor(
self, that: our_types.AssetAdministrationShellDescriptor
) -> Iterator[Error]:
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error("The name of an extension needs to be unique.")
if not (not (that.endpoints is not None) or (len(that.endpoints) >= 1)):
yield Error("Endpoints must be either not set or have at least one item.")
if not (
not (that.specific_asset_ids is not None)
or (len(that.specific_asset_ids) >= 1)
):
yield Error(
"Specific asset IDs must be either not set or have at least "
+ "one item."
)
if not (
not (that.submodel_descriptors is not None)
or (len(that.submodel_descriptors) >= 1)
):
yield Error(
"Submodel descriptors must be either not set or have at "
+ "least one item."
)
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
for error in verify_identifier(that.id):
error.path._prepend(PropertySegment(that, "id"))
yield error
if that.administration is not None:
for error in verify(that.administration):
error.path._prepend(PropertySegment(that, "administration"))
yield error
if that.asset_type is not None:
for error in verify_identifier(that.asset_type):
error.path._prepend(PropertySegment(that, "asset_type"))
yield error
if that.endpoints is not None:
for error in _verify_list_of__class(that.endpoints):
error.path._prepend(PropertySegment(that, "endpoints"))
yield error
if that.global_asset_id is not None:
for error in verify_identifier(that.global_asset_id):
error.path._prepend(PropertySegment(that, "global_asset_id"))
yield error
if that.id_short is not None:
for error in verify_name_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.specific_asset_ids is not None:
for error in _verify_list_of__class(that.specific_asset_ids):
error.path._prepend(PropertySegment(that, "specific_asset_ids"))
yield error
if that.submodel_descriptors is not None:
for error in _verify_list_of__class(that.submodel_descriptors):
error.path._prepend(PropertySegment(that, "submodel_descriptors"))
yield error
# noinspection PyMethodMayBeStatic
def transform_submodel_descriptor(
self, that: our_types.SubmodelDescriptor
) -> Iterator[Error]:
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error("The name of an extension needs to be unique.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"If there are supplemental semantic IDs defined then there "
+ "shall be also a main semantic ID."
)
if not (len(that.endpoints) >= 1):
yield Error("Endpoints must contain at least one item.")
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
for error in _verify_list_of__class(that.endpoints):
error.path._prepend(PropertySegment(that, "endpoints"))
yield error
for error in verify_identifier(that.id):
error.path._prepend(PropertySegment(that, "id"))
yield error
if that.administration is not None:
for error in verify(that.administration):
error.path._prepend(PropertySegment(that, "administration"))
yield error
if that.id_short is not None:
for error in verify_name_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
# noinspection PyMethodMayBeStatic
def transform_endpoint(self, that: our_types.Endpoint) -> Iterator[Error]:
for error in verify(that.protocol_information):
error.path._prepend(PropertySegment(that, "protocol_information"))
yield error
for error in verify_name_type(that.interface):
error.path._prepend(PropertySegment(that, "interface"))
yield error
# noinspection PyMethodMayBeStatic
def transform_protocol_information(
self, that: our_types.ProtocolInformation
) -> Iterator[Error]:
if not (
not (that.security_attributes is not None)
or (len(that.security_attributes) >= 1)
):
yield Error(
"Security attributes must be either not set or have at least "
+ "one item."
)
for error in verify_locator_type(that.href):
error.path._prepend(PropertySegment(that, "href"))
yield error
if that.endpoint_protocol is not None:
for error in verify_scheme_type(that.endpoint_protocol):
error.path._prepend(PropertySegment(that, "endpoint_protocol"))
yield error
if that.endpoint_protocol_version is not None:
for error in _verify_list_of__name_type(that.endpoint_protocol_version):
error.path._prepend(PropertySegment(that, "endpoint_protocol_version"))
yield error
if that.subprotocol is not None:
for error in verify_short_id_type(that.subprotocol):
error.path._prepend(PropertySegment(that, "subprotocol"))
yield error
if that.subprotocol_body is not None:
for error in verify_text_type(that.subprotocol_body):
error.path._prepend(PropertySegment(that, "subprotocol_body"))
yield error
if that.subprotocol_body_encoding is not None:
for error in verify_name_type(that.subprotocol_body_encoding):
error.path._prepend(PropertySegment(that, "subprotocol_body_encoding"))
yield error
if that.security_attributes is not None:
for error in _verify_list_of__class(that.security_attributes):
error.path._prepend(PropertySegment(that, "security_attributes"))
yield error
# noinspection PyMethodMayBeStatic
def transform_security_attribute_object(
self, that: our_types.SecurityAttributeObject
) -> Iterator[Error]:
# No verification has been defined for SecurityAttributeObject.
return
# For this uncommon return-yield construction, see:
# https://stackoverflow.com/questions/13243766/how-to-define-an-empty-generator-function
# noinspection PyUnreachableCode
yield
# noinspection PyMethodMayBeStatic
def transform_asset_link(self, that: our_types.AssetLink) -> Iterator[Error]:
for error in verify_label_type(that.name):
error.path._prepend(PropertySegment(that, "name"))
yield error
for error in verify_identifier(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
# noinspection PyMethodMayBeStatic
def transform_service_description(
self, that: our_types.ServiceDescription
) -> Iterator[Error]:
if not (len(that.profiles) >= 1):
yield Error("Profiles must contain at least one item.")
# noinspection PyMethodMayBeStatic
def transform_asset_administration_shell_recent_change(
self, that: our_types.AssetAdministrationShellRecentChange
) -> Iterator[Error]:
if not (
not (that.specific_asset_ids is not None)
or (len(that.specific_asset_ids) >= 1)
):
yield Error(
"Specific asset IDs must be either not set or have at least "
+ "one item."
)
for error in verify_date_time_utc(that.created_at):
error.path._prepend(PropertySegment(that, "created_at"))
yield error
for error in verify_date_time_utc(that.updated_at):
error.path._prepend(PropertySegment(that, "updated_at"))
yield error
for error in verify_identifier(that.id):
error.path._prepend(PropertySegment(that, "id"))
yield error
if that.global_asset_id is not None:
for error in verify_identifier(that.global_asset_id):
error.path._prepend(PropertySegment(that, "global_asset_id"))
yield error
if that.specific_asset_ids is not None:
for error in _verify_list_of__class(that.specific_asset_ids):
error.path._prepend(PropertySegment(that, "specific_asset_ids"))
yield error
# noinspection PyMethodMayBeStatic
def transform_concept_description_recent_change(
self, that: our_types.ConceptDescriptionRecentChange
) -> Iterator[Error]:
for error in verify_date_time_utc(that.created_at):
error.path._prepend(PropertySegment(that, "created_at"))
yield error
for error in verify_date_time_utc(that.updated_at):
error.path._prepend(PropertySegment(that, "updated_at"))
yield error
for error in verify_identifier(that.id):
error.path._prepend(PropertySegment(that, "id"))
yield error
# noinspection PyMethodMayBeStatic
def transform_submodel_recent_change(
self, that: our_types.SubmodelRecentChange
) -> Iterator[Error]:
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"If there are supplemental semantic IDs defined then there "
+ "shall be also a main semantic ID."
)
for error in verify_date_time_utc(that.created_at):
error.path._prepend(PropertySegment(that, "created_at"))
yield error
for error in verify_date_time_utc(that.updated_at):
error.path._prepend(PropertySegment(that, "updated_at"))
yield error
for error in verify_identifier(that.id):
error.path._prepend(PropertySegment(that, "id"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
# noinspection PyMethodMayBeStatic
def transform_result(self, that: our_types.Result) -> Iterator[Error]:
if that.messages is not None:
for error in _verify_list_of__class(that.messages):
error.path._prepend(PropertySegment(that, "messages"))
yield error
# noinspection PyMethodMayBeStatic
def transform_message(self, that: our_types.Message) -> Iterator[Error]:
if that.code is not None:
for error in verify_code_type(that.code):
error.path._prepend(PropertySegment(that, "code"))
yield error
if that.correlation_id is not None:
for error in verify_short_id_type(that.correlation_id):
error.path._prepend(PropertySegment(that, "correlation_id"))
yield error
if that.timestamp is not None:
for error in verify_date_time_utc(that.timestamp):
error.path._prepend(PropertySegment(that, "timestamp"))
yield error
# noinspection PyMethodMayBeStatic
def transform_operation_request(
self, that: our_types.OperationRequest
) -> Iterator[Error]:
if not (
not (that.inoutput_arguments is not None)
or (len(that.inoutput_arguments) >= 1)
):
yield Error(
"InOutput arguments must be either not set or have at least "
+ "one item."
)
if not (
not (that.input_arguments is not None) or (len(that.input_arguments) >= 1)
):
yield Error(
"Input arguments must be either not set or have at least one " + "item."
)
if that.input_arguments is not None:
for error in _verify_list_of__class(that.input_arguments):
error.path._prepend(PropertySegment(that, "input_arguments"))
yield error
if that.inoutput_arguments is not None:
for error in _verify_list_of__class(that.inoutput_arguments):
error.path._prepend(PropertySegment(that, "inoutput_arguments"))
yield error
if that.client_timeout_duration is not None:
for error in verify_duration(that.client_timeout_duration):
error.path._prepend(PropertySegment(that, "client_timeout_duration"))
yield error
# noinspection PyMethodMayBeStatic
def transform_operation_request_async(
self, that: our_types.OperationRequestAsync
) -> Iterator[Error]:
if not (
not (that.inoutput_arguments is not None)
or (len(that.inoutput_arguments) >= 1)
):
yield Error(
"InOutput arguments must be either not set or have at least "
+ "one item."
)
if not (
not (that.input_arguments is not None) or (len(that.input_arguments) >= 1)
):
yield Error(
"Input arguments must be either not set or have at least one " + "item."
)
if that.input_arguments is not None:
for error in _verify_list_of__class(that.input_arguments):
error.path._prepend(PropertySegment(that, "input_arguments"))
yield error
if that.inoutput_arguments is not None:
for error in _verify_list_of__class(that.inoutput_arguments):
error.path._prepend(PropertySegment(that, "inoutput_arguments"))
yield error
for error in verify_duration(that.client_timeout_duration):
error.path._prepend(PropertySegment(that, "client_timeout_duration"))
yield error
# noinspection PyMethodMayBeStatic
def transform_operation_request_value_only(
self, that: our_types.OperationRequestValueOnly
) -> Iterator[Error]:
if that.input_arguments is not None:
for error in our_json_value_verification.verify_json_object(
that.input_arguments
):
error.path._prepend(PropertySegment(that, "input_arguments"))
yield error
for key in that.input_arguments:
# NOTE (mristin):
# The key segment names the member whose key is erroneous. The path
# thus leads to the member, and the cause says what is wrong with
# the key which names it.
for error in verify_id_short_type(key):
error.path._prepend(KeySegment(that.input_arguments, key))
error.path._prepend(PropertySegment(that, "input_arguments"))
yield error
if that.inoutput_arguments is not None:
for error in our_json_value_verification.verify_json_object(
that.inoutput_arguments
):
error.path._prepend(PropertySegment(that, "inoutput_arguments"))
yield error
for key in that.inoutput_arguments:
# NOTE (mristin):
# The key segment names the member whose key is erroneous. The path
# thus leads to the member, and the cause says what is wrong with
# the key which names it.
for error in verify_id_short_type(key):
error.path._prepend(KeySegment(that.inoutput_arguments, key))
error.path._prepend(PropertySegment(that, "inoutput_arguments"))
yield error
if that.client_timeout_duration is not None:
for error in verify_duration(that.client_timeout_duration):
error.path._prepend(PropertySegment(that, "client_timeout_duration"))
yield error
# noinspection PyMethodMayBeStatic
def transform_operation_request_async_value_only(
self, that: our_types.OperationRequestAsyncValueOnly
) -> Iterator[Error]:
if that.input_arguments is not None:
for error in our_json_value_verification.verify_json_object(
that.input_arguments
):
error.path._prepend(PropertySegment(that, "input_arguments"))
yield error
for key in that.input_arguments:
# NOTE (mristin):
# The key segment names the member whose key is erroneous. The path
# thus leads to the member, and the cause says what is wrong with
# the key which names it.
for error in verify_id_short_type(key):
error.path._prepend(KeySegment(that.input_arguments, key))
error.path._prepend(PropertySegment(that, "input_arguments"))
yield error
if that.inoutput_arguments is not None:
for error in our_json_value_verification.verify_json_object(
that.inoutput_arguments
):
error.path._prepend(PropertySegment(that, "inoutput_arguments"))
yield error
for key in that.inoutput_arguments:
# NOTE (mristin):
# The key segment names the member whose key is erroneous. The path
# thus leads to the member, and the cause says what is wrong with
# the key which names it.
for error in verify_id_short_type(key):
error.path._prepend(KeySegment(that.inoutput_arguments, key))
error.path._prepend(PropertySegment(that, "inoutput_arguments"))
yield error
for error in verify_duration(that.client_timeout_duration):
error.path._prepend(PropertySegment(that, "client_timeout_duration"))
yield error
# noinspection PyMethodMayBeStatic
def transform_base_operation_result(
self, that: our_types.BaseOperationResult
) -> Iterator[Error]:
if that.messages is not None:
for error in _verify_list_of__class(that.messages):
error.path._prepend(PropertySegment(that, "messages"))
yield error
# noinspection PyMethodMayBeStatic
def transform_operation_result(
self, that: our_types.OperationResult
) -> Iterator[Error]:
if not (
not (that.inoutput_arguments is not None)
or (len(that.inoutput_arguments) >= 1)
):
yield Error(
"InOutput arguments must be either not set or have at least "
+ "one item."
)
if not (
not (that.output_arguments is not None) or (len(that.output_arguments) >= 1)
):
yield Error(
"Output arguments must be either not set or have at least "
+ "one item."
)
if that.messages is not None:
for error in _verify_list_of__class(that.messages):
error.path._prepend(PropertySegment(that, "messages"))
yield error
if that.output_arguments is not None:
for error in _verify_list_of__class(that.output_arguments):
error.path._prepend(PropertySegment(that, "output_arguments"))
yield error
if that.inoutput_arguments is not None:
for error in _verify_list_of__class(that.inoutput_arguments):
error.path._prepend(PropertySegment(that, "inoutput_arguments"))
yield error
# noinspection PyMethodMayBeStatic
def transform_operation_result_value_only(
self, that: our_types.OperationResultValueOnly
) -> Iterator[Error]:
if that.messages is not None:
for error in _verify_list_of__class(that.messages):
error.path._prepend(PropertySegment(that, "messages"))
yield error
if that.output_arguments is not None:
for error in our_json_value_verification.verify_json_object(
that.output_arguments
):
error.path._prepend(PropertySegment(that, "output_arguments"))
yield error
for key in that.output_arguments:
# NOTE (mristin):
# The key segment names the member whose key is erroneous. The path
# thus leads to the member, and the cause says what is wrong with
# the key which names it.
for error in verify_id_short_type(key):
error.path._prepend(KeySegment(that.output_arguments, key))
error.path._prepend(PropertySegment(that, "output_arguments"))
yield error
if that.inoutput_arguments is not None:
for error in our_json_value_verification.verify_json_object(
that.inoutput_arguments
):
error.path._prepend(PropertySegment(that, "inoutput_arguments"))
yield error
for key in that.inoutput_arguments:
# NOTE (mristin):
# The key segment names the member whose key is erroneous. The path
# thus leads to the member, and the cause says what is wrong with
# the key which names it.
for error in verify_id_short_type(key):
error.path._prepend(KeySegment(that.inoutput_arguments, key))
error.path._prepend(PropertySegment(that, "inoutput_arguments"))
yield error
# noinspection PyMethodMayBeStatic
def transform_operation_handle(
self, that: our_types.OperationHandle
) -> Iterator[Error]:
for error in verify_short_id_type(that.handle_id):
error.path._prepend(PropertySegment(that, "handle_id"))
yield error
# noinspection PyMethodMayBeStatic
def transform_paged_result(self, that: our_types.PagedResult) -> Iterator[Error]:
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
# noinspection PyMethodMayBeStatic
def transform_paging_metadata(
self, that: our_types.PagingMetadata
) -> Iterator[Error]:
# No verification has been defined for PagingMetadata.
return
# For this uncommon return-yield construction, see:
# https://stackoverflow.com/questions/13243766/how-to-define-an-empty-generator-function
# noinspection PyUnreachableCode
yield
# noinspection PyMethodMayBeStatic
def transform_package_description(
self, that: our_types.PackageDescription
) -> Iterator[Error]:
for error in verify_short_id_type(that.package_id):
error.path._prepend(PropertySegment(that, "package_id"))
yield error
if that.aas_ids is not None:
for error in _verify_list_of__identifier(that.aas_ids):
error.path._prepend(PropertySegment(that, "aas_ids"))
yield error
# noinspection PyMethodMayBeStatic
def transform_property_metadata(
self, that: our_types.PropertyMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_range_metadata(
self, that: our_types.RangeMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_blob_metadata(self, that: our_types.BlobMetadata) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_file_metadata(self, that: our_types.FileMetadata) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_multi_language_property_metadata(
self, that: our_types.MultiLanguagePropertyMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_reference_element_metadata(
self, that: our_types.ReferenceElementMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_relationship_element_metadata(
self, that: our_types.RelationshipElementMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_annotated_relationship_element_metadata(
self, that: our_types.AnnotatedRelationshipElementMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_entity_metadata(
self, that: our_types.EntityMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_capability_metadata(
self, that: our_types.CapabilityMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_operation_metadata(
self, that: our_types.OperationMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_submodel_element_collection_metadata(
self, that: our_types.SubmodelElementCollectionMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_basic_event_element_metadata(
self, that: our_types.BasicEventElementMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.message_topic is not None:
for error in verify_message_topic_type(that.message_topic):
error.path._prepend(PropertySegment(that, "message_topic"))
yield error
if that.message_broker is not None:
for error in verify(that.message_broker):
error.path._prepend(PropertySegment(that, "message_broker"))
yield error
if that.last_update is not None:
for error in verify_date_time_utc(that.last_update):
error.path._prepend(PropertySegment(that, "last_update"))
yield error
if that.min_interval is not None:
for error in verify_duration(that.min_interval):
error.path._prepend(PropertySegment(that, "min_interval"))
yield error
if that.max_interval is not None:
for error in verify_duration(that.max_interval):
error.path._prepend(PropertySegment(that, "max_interval"))
yield error
# noinspection PyMethodMayBeStatic
def transform_submodel_element_list_metadata(
self, that: our_types.SubmodelElementListMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.semantic_id_list_element is not None:
for error in verify(that.semantic_id_list_element):
error.path._prepend(PropertySegment(that, "semantic_id_list_element"))
yield error
# noinspection PyMethodMayBeStatic
def transform_submodel_metadata(
self, that: our_types.SubmodelMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.supplemental_semantic_ids is not None)
or (len(that.supplemental_semantic_ids) >= 1)
):
yield Error(
"Supplemental semantic IDs must be either not set or have at "
+ "least one item."
)
if not (
not (that.supplemental_semantic_ids is not None)
or (that.semantic_id is not None)
):
yield Error(
"Constraint AASd-118: If there are supplemental semantic IDs "
+ "defined then there shall be also a main semantic ID."
)
if not (not (that.qualifiers is not None) or (len(that.qualifiers) >= 1)):
yield Error("Qualifiers must be either not set or have at least one item.")
if not (
not (that.qualifiers is not None)
or qualifier_types_are_unique(that.qualifiers)
):
yield Error(
"Constraint AASd-021: Every qualifiable shall only have one "
+ "qualifier with the same type."
)
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if not (
not (that.qualifiers is not None)
or (
not (
any(
qualifier.kind_or_default()
== our_types.QualifierKind.TEMPLATE_QUALIFIER
for qualifier in that.qualifiers
)
)
or (that.kind_or_default() == our_types.ModellingKind.TEMPLATE)
)
):
yield Error(
"Constraint AASd-119: If any qualifier kind value of "
+ "a qualifiable qualifier is equal to template qualifier and "
+ "the qualified element has kind then the qualified element "
+ "shall be of kind template."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.administration is not None:
for error in verify(that.administration):
error.path._prepend(PropertySegment(that, "administration"))
yield error
for error in verify_identifier(that.id):
error.path._prepend(PropertySegment(that, "id"))
yield error
if that.semantic_id is not None:
for error in verify(that.semantic_id):
error.path._prepend(PropertySegment(that, "semantic_id"))
yield error
if that.supplemental_semantic_ids is not None:
for error in _verify_list_of__class(that.supplemental_semantic_ids):
error.path._prepend(PropertySegment(that, "supplemental_semantic_ids"))
yield error
if that.qualifiers is not None:
for error in _verify_list_of__class(that.qualifiers):
error.path._prepend(PropertySegment(that, "qualifiers"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
# noinspection PyMethodMayBeStatic
def transform_asset_administration_shell_metadata(
self, that: our_types.AssetAdministrationShellMetadata
) -> Iterator[Error]:
if not (not (that.extensions is not None) or (len(that.extensions) >= 1)):
yield Error("Extensions must be either not set or have at least one item.")
if not (
not (that.extensions is not None)
or extension_names_are_unique(that.extensions)
):
yield Error(
"Constraint AASd-077: The name of an extension within "
+ "Has-Extensions needs to be unique."
)
if not (not (that.description is not None) or (len(that.description) >= 1)):
yield Error(
"Description must be either not set or have at least one " + "item."
)
if not (
not (that.description is not None)
or lang_strings_have_unique_languages(that.description)
):
yield Error("Description must specify unique languages.")
if not (not (that.display_name is not None) or (len(that.display_name) >= 1)):
yield Error(
"Display name must be either not set or have at least one " + "item."
)
if not (
not (that.display_name is not None)
or lang_strings_have_unique_languages(that.display_name)
):
yield Error("Display name must specify unique languages.")
if not (
not (that.embedded_data_specifications is not None)
or (len(that.embedded_data_specifications) >= 1)
):
yield Error(
"Embedded data specifications must be either not set or have "
+ "at least one item."
)
if that.extensions is not None:
for error in _verify_list_of__class(that.extensions):
error.path._prepend(PropertySegment(that, "extensions"))
yield error
if that.category is not None:
for error in verify_name_type(that.category):
error.path._prepend(PropertySegment(that, "category"))
yield error
if that.id_short is not None:
for error in verify_id_short_type(that.id_short):
error.path._prepend(PropertySegment(that, "id_short"))
yield error
if that.display_name is not None:
for error in _verify_list_of__class(that.display_name):
error.path._prepend(PropertySegment(that, "display_name"))
yield error
if that.description is not None:
for error in _verify_list_of__class(that.description):
error.path._prepend(PropertySegment(that, "description"))
yield error
if that.administration is not None:
for error in verify(that.administration):
error.path._prepend(PropertySegment(that, "administration"))
yield error
for error in verify_identifier(that.id):
error.path._prepend(PropertySegment(that, "id"))
yield error
if that.embedded_data_specifications is not None:
for error in _verify_list_of__class(that.embedded_data_specifications):
error.path._prepend(
PropertySegment(that, "embedded_data_specifications")
)
yield error
if that.derived_from is not None:
for error in verify(that.derived_from):
error.path._prepend(PropertySegment(that, "derived_from"))
yield error
# noinspection PyMethodMayBeStatic
def transform_reference_element_value(
self, that: our_types.ReferenceElementValue
) -> Iterator[Error]:
if not (len(that.keys) >= 1):
yield Error("Keys must contain at least one item.")
for error in _verify_list_of__class(that.keys):
error.path._prepend(PropertySegment(that, "keys"))
yield error
if that.referred_semantic_id is not None:
for error in verify(that.referred_semantic_id):
error.path._prepend(PropertySegment(that, "referred_semantic_id"))
yield error
# noinspection PyMethodMayBeStatic
def transform_blob_value(self, that: our_types.BlobValue) -> Iterator[Error]:
if that.content_type is not None:
for error in verify_content_type(that.content_type):
error.path._prepend(PropertySegment(that, "content_type"))
yield error
if that.value is not None:
for error in verify_blob_type(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
# noinspection PyMethodMayBeStatic
def transform_file_value(self, that: our_types.FileValue) -> Iterator[Error]:
if that.content_type is not None:
for error in verify_content_type(that.content_type):
error.path._prepend(PropertySegment(that, "content_type"))
yield error
if that.value is not None:
for error in verify_path_type(that.value):
error.path._prepend(PropertySegment(that, "value"))
yield error
# noinspection PyMethodMayBeStatic
def transform_range_value(self, that: our_types.RangeValue) -> Iterator[Error]:
# No verification has been defined for RangeValue.
return
# For this uncommon return-yield construction, see:
# https://stackoverflow.com/questions/13243766/how-to-define-an-empty-generator-function
# noinspection PyUnreachableCode
yield
# noinspection PyMethodMayBeStatic
def transform_relationship_element_value(
self, that: our_types.RelationshipElementValue
) -> Iterator[Error]:
if that.first is not None:
for error in verify(that.first):
error.path._prepend(PropertySegment(that, "first"))
yield error
if that.second is not None:
for error in verify(that.second):
error.path._prepend(PropertySegment(that, "second"))
yield error
# noinspection PyMethodMayBeStatic
def transform_basic_event_element_value(
self, that: our_types.BasicEventElementValue
) -> Iterator[Error]:
for error in verify(that.observed):
error.path._prepend(PropertySegment(that, "observed"))
yield error
# noinspection PyMethodMayBeStatic
def transform_annotated_relationship_element_value(
self, that: our_types.AnnotatedRelationshipElementValue
) -> Iterator[Error]:
if that.first is not None:
for error in verify(that.first):
error.path._prepend(PropertySegment(that, "first"))
yield error
if that.second is not None:
for error in verify(that.second):
error.path._prepend(PropertySegment(that, "second"))
yield error
if that.annotations is not None:
for error in our_json_value_verification.verify_json_object(
that.annotations
):
error.path._prepend(PropertySegment(that, "annotations"))
yield error
for key in that.annotations:
# NOTE (mristin):
# The key segment names the member whose key is erroneous. The path
# thus leads to the member, and the cause says what is wrong with
# the key which names it.
for error in verify_id_short_type(key):
error.path._prepend(KeySegment(that.annotations, key))
error.path._prepend(PropertySegment(that, "annotations"))
yield error
# noinspection PyMethodMayBeStatic
def transform_entity_value(self, that: our_types.EntityValue) -> Iterator[Error]:
if not (
not (that.specific_asset_ids is not None)
or (len(that.specific_asset_ids) >= 1)
):
yield Error(
"Specific asset IDs must be either not set or have at least "
+ "one item."
)
if that.global_asset_id is not None:
for error in verify_identifier(that.global_asset_id):
error.path._prepend(PropertySegment(that, "global_asset_id"))
yield error
if that.specific_asset_ids is not None:
for error in _verify_list_of__json_object(that.specific_asset_ids):
error.path._prepend(PropertySegment(that, "specific_asset_ids"))
yield error
if that.statements is not None:
for error in our_json_value_verification.verify_json_object(
that.statements
):
error.path._prepend(PropertySegment(that, "statements"))
yield error
for key in that.statements:
# NOTE (mristin):
# The key segment names the member whose key is erroneous. The path
# thus leads to the member, and the cause says what is wrong with
# the key which names it.
for error in verify_id_short_type(key):
error.path._prepend(KeySegment(that.statements, key))
error.path._prepend(PropertySegment(that, "statements"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_asset_administration_shells_result(
self, that: our_types.GetAssetAdministrationShellsResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_asset_administration_shells_metadata_result(
self, that: our_types.GetAssetAdministrationShellsMetadataResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_all_asset_administration_shells_recent_changes_result(
self, that: our_types.GetAllAssetAdministrationShellsRecentChangesResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_asset_administration_shell_descriptors_result(
self, that: our_types.GetAssetAdministrationShellDescriptorsResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_concept_descriptions_result(
self, that: our_types.GetConceptDescriptionsResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_all_concept_descriptions_recent_changes_result(
self, that: our_types.GetAllConceptDescriptionsRecentChangesResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_package_descriptions_result(
self, that: our_types.GetPackageDescriptionsResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_path_items_result(
self, that: our_types.GetPathItemsResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__path_item(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_references_result(
self, that: our_types.GetReferencesResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_submodel_descriptors_result(
self, that: our_types.GetSubmodelDescriptorsResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_submodel_elements_metadata_result(
self, that: our_types.GetSubmodelElementsMetadataResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_submodel_elements_result(
self, that: our_types.GetSubmodelElementsResult
) -> Iterator[Error]:
if not (
not (that.result is not None)
or (all(item.id_short is not None for item in that.result))
):
yield Error(
"ID-shorts need to be defined for all the items of result "
+ "according to AASd-117 (ID-short of non-identifiable "
+ "Referables not being a direct child of a Submodel element "
+ "list shall be specified)."
)
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_submodel_elements_value_result(
self, that: our_types.GetSubmodelElementsValueResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__json_object(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_all_submodels_recent_changes_result(
self, that: our_types.GetAllSubmodelsRecentChangesResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_submodels_metadata_result(
self, that: our_types.GetSubmodelsMetadataResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_submodels_result(
self, that: our_types.GetSubmodelsResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__class(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_get_submodels_value_result(
self, that: our_types.GetSubmodelsValueResult
) -> Iterator[Error]:
for error in verify(that.paging_metadata):
error.path._prepend(PropertySegment(that, "paging_metadata"))
yield error
if that.result is not None:
for error in _verify_list_of__json_object(that.result):
error.path._prepend(PropertySegment(that, "result"))
yield error
# noinspection PyMethodMayBeStatic
def transform_claim_attribute(
self, that: our_types.ClaimAttribute
) -> Iterator[Error]:
# No verification has been defined for ClaimAttribute.
return
# For this uncommon return-yield construction, see:
# https://stackoverflow.com/questions/13243766/how-to-define-an-empty-generator-function
# noinspection PyUnreachableCode
yield
# noinspection PyMethodMayBeStatic
def transform_global_attribute(
self, that: our_types.GlobalAttribute
) -> Iterator[Error]:
# No verification has been defined for GlobalAttribute.
return
# For this uncommon return-yield construction, see:
# https://stackoverflow.com/questions/13243766/how-to-define-an-empty-generator-function
# noinspection PyUnreachableCode
yield
# noinspection PyMethodMayBeStatic
def transform_reference_attribute(
self, that: our_types.ReferenceAttribute
) -> Iterator[Error]:
for error in verify_reference_identifier(that.reference):
error.path._prepend(PropertySegment(that, "reference"))
yield error
# noinspection PyMethodMayBeStatic
def transform_date_time_attribute_item(
self, that: our_types.DateTimeAttributeItem
) -> Iterator[Error]:
# No verification has been defined for DateTimeAttributeItem.
return
# For this uncommon return-yield construction, see:
# https://stackoverflow.com/questions/13243766/how-to-define-an-empty-generator-function
# noinspection PyUnreachableCode
yield
# noinspection PyMethodMayBeStatic
def transform_field_operand(self, that: our_types.FieldOperand) -> Iterator[Error]:
for error in verify_field_identifier(that.field):
error.path._prepend(PropertySegment(that, "field"))
yield error
# noinspection PyMethodMayBeStatic
def transform_string_literal(
self, that: our_types.StringLiteral
) -> Iterator[Error]:
for error in verify_standard_string(that.str_val):
error.path._prepend(PropertySegment(that, "str_val"))
yield error
# noinspection PyMethodMayBeStatic
def transform_attribute_operand(
self, that: our_types.AttributeOperand
) -> Iterator[Error]:
for error in verify(that.attribute):
error.path._prepend(PropertySegment(that, "attribute"))
yield error
# noinspection PyMethodMayBeStatic
def transform_number_literal(
self, that: our_types.NumberLiteral
) -> Iterator[Error]:
# No verification has been defined for NumberLiteral.
return
# For this uncommon return-yield construction, see:
# https://stackoverflow.com/questions/13243766/how-to-define-an-empty-generator-function
# noinspection PyUnreachableCode
yield
# noinspection PyMethodMayBeStatic
def transform_hex_literal(self, that: our_types.HexLiteral) -> Iterator[Error]:
for error in verify_hex_literal_type(that.hex_val):
error.path._prepend(PropertySegment(that, "hex_val"))
yield error
# noinspection PyMethodMayBeStatic
def transform_date_time_literal(
self, that: our_types.DateTimeLiteral
) -> Iterator[Error]:
for error in verify_date_time_literal_type(that.date_time_val):
error.path._prepend(PropertySegment(that, "date_time_val"))
yield error
# noinspection PyMethodMayBeStatic
def transform_time_literal(self, that: our_types.TimeLiteral) -> Iterator[Error]:
for error in verify_time_literal_type(that.time_val):
error.path._prepend(PropertySegment(that, "time_val"))
yield error
# noinspection PyMethodMayBeStatic
def transform_boolean_literal(
self, that: our_types.BooleanLiteral
) -> Iterator[Error]:
# No verification has been defined for BooleanLiteral.
return
# For this uncommon return-yield construction, see:
# https://stackoverflow.com/questions/13243766/how-to-define-an-empty-generator-function
# noinspection PyUnreachableCode
yield
# noinspection PyMethodMayBeStatic
def transform_string_cast(self, that: our_types.StringCast) -> Iterator[Error]:
for error in verify(that.str_cast):
error.path._prepend(PropertySegment(that, "str_cast"))
yield error
# noinspection PyMethodMayBeStatic
def transform_number_cast(self, that: our_types.NumberCast) -> Iterator[Error]:
for error in verify(that.num_cast):
error.path._prepend(PropertySegment(that, "num_cast"))
yield error
# noinspection PyMethodMayBeStatic
def transform_hex_cast(self, that: our_types.HexCast) -> Iterator[Error]:
for error in verify(that.hex_cast):
error.path._prepend(PropertySegment(that, "hex_cast"))
yield error
# noinspection PyMethodMayBeStatic
def transform_boolean_cast(self, that: our_types.BooleanCast) -> Iterator[Error]:
for error in verify(that.bool_cast):
error.path._prepend(PropertySegment(that, "bool_cast"))
yield error
# noinspection PyMethodMayBeStatic
def transform_date_time_cast(self, that: our_types.DateTimeCast) -> Iterator[Error]:
for error in verify(that.date_time_cast):
error.path._prepend(PropertySegment(that, "date_time_cast"))
yield error
# noinspection PyMethodMayBeStatic
def transform_time_cast(self, that: our_types.TimeCast) -> Iterator[Error]:
for error in verify(that.time_cast):
error.path._prepend(PropertySegment(that, "time_cast"))
yield error
# noinspection PyMethodMayBeStatic
def transform_day_of_week(self, that: our_types.DayOfWeek) -> Iterator[Error]:
for error in verify(that.day_of_week):
error.path._prepend(PropertySegment(that, "day_of_week"))
yield error
# noinspection PyMethodMayBeStatic
def transform_day_of_month(self, that: our_types.DayOfMonth) -> Iterator[Error]:
for error in verify(that.day_of_month):
error.path._prepend(PropertySegment(that, "day_of_month"))
yield error
# noinspection PyMethodMayBeStatic
def transform_month(self, that: our_types.Month) -> Iterator[Error]:
for error in verify(that.month):
error.path._prepend(PropertySegment(that, "month"))
yield error
# noinspection PyMethodMayBeStatic
def transform_year(self, that: our_types.Year) -> Iterator[Error]:
for error in verify(that.year):
error.path._prepend(PropertySegment(that, "year"))
yield error
# noinspection PyMethodMayBeStatic
def transform_date_time_attribute_operand(
self, that: our_types.DateTimeAttributeOperand
) -> Iterator[Error]:
for error in verify(that.attribute):
error.path._prepend(PropertySegment(that, "attribute"))
yield error
# noinspection PyMethodMayBeStatic
def transform_equal_comparison(
self, that: our_types.EqualComparison
) -> Iterator[Error]:
if not are_equality_comparable(that.eq[0], that.eq[1]):
yield Error("The operands must be comparable by (in)equality.")
for error in _verify_tuple2_of__class__class(that.eq):
error.path._prepend(PropertySegment(that, "eq"))
yield error
# noinspection PyMethodMayBeStatic
def transform_not_equal_comparison(
self, that: our_types.NotEqualComparison
) -> Iterator[Error]:
if not are_equality_comparable(that.ne[0], that.ne[1]):
yield Error("The operands must be comparable by (in)equality.")
for error in _verify_tuple2_of__class__class(that.ne):
error.path._prepend(PropertySegment(that, "ne"))
yield error
# noinspection PyMethodMayBeStatic
def transform_greater_than_comparison(
self, that: our_types.GreaterThanComparison
) -> Iterator[Error]:
if not are_order_comparable(that.gt[0], that.gt[1]):
yield Error("The operands must be comparable by order.")
for error in _verify_tuple2_of__class__class(that.gt):
error.path._prepend(PropertySegment(that, "gt"))
yield error
# noinspection PyMethodMayBeStatic
def transform_greater_than_or_equal_comparison(
self, that: our_types.GreaterThanOrEqualComparison
) -> Iterator[Error]:
if not are_order_comparable(that.ge[0], that.ge[1]):
yield Error("The operands must be comparable by order.")
for error in _verify_tuple2_of__class__class(that.ge):
error.path._prepend(PropertySegment(that, "ge"))
yield error
# noinspection PyMethodMayBeStatic
def transform_less_than_comparison(
self, that: our_types.LessThanComparison
) -> Iterator[Error]:
if not are_order_comparable(that.lt[0], that.lt[1]):
yield Error("The operands must be comparable by order.")
for error in _verify_tuple2_of__class__class(that.lt):
error.path._prepend(PropertySegment(that, "lt"))
yield error
# noinspection PyMethodMayBeStatic
def transform_less_than_or_equal_comparison(
self, that: our_types.LessThanOrEqualComparison
) -> Iterator[Error]:
if not are_order_comparable(that.le[0], that.le[1]):
yield Error("The operands must be comparable by order.")
for error in _verify_tuple2_of__class__class(that.le):
error.path._prepend(PropertySegment(that, "le"))
yield error
# noinspection PyMethodMayBeStatic
def transform_contains_comparison(
self, that: our_types.ContainsComparison
) -> Iterator[Error]:
for error in _verify_tuple2_of__class__class(that.contains):
error.path._prepend(PropertySegment(that, "contains"))
yield error
# noinspection PyMethodMayBeStatic
def transform_starts_with_comparison(
self, that: our_types.StartsWithComparison
) -> Iterator[Error]:
for error in _verify_tuple2_of__class__class(that.starts_with):
error.path._prepend(PropertySegment(that, "starts_with"))
yield error
# noinspection PyMethodMayBeStatic
def transform_ends_with_comparison(
self, that: our_types.EndsWithComparison
) -> Iterator[Error]:
for error in _verify_tuple2_of__class__class(that.ends_with):
error.path._prepend(PropertySegment(that, "ends_with"))
yield error
# noinspection PyMethodMayBeStatic
def transform_regex_comparison(
self, that: our_types.RegexComparison
) -> Iterator[Error]:
for error in _verify_tuple2_of__class__class(that.regex):
error.path._prepend(PropertySegment(that, "regex"))
yield error
# noinspection PyMethodMayBeStatic
def transform_match_clause(self, that: our_types.MatchClause) -> Iterator[Error]:
if not (len(that.match_operands) >= 1):
yield Error("Match operands must have at least one item.")
for error in _verify_list_of__class(that.match_operands):
error.path._prepend(PropertySegment(that, "match_operands"))
yield error
# noinspection PyMethodMayBeStatic
def transform_and_expression(
self, that: our_types.AndExpression
) -> Iterator[Error]:
if not (len(that.and_operands) >= 2):
yield Error("And operands must have at least two items.")
for error in _verify_list_of__class(that.and_operands):
error.path._prepend(PropertySegment(that, "and_operands"))
yield error
# noinspection PyMethodMayBeStatic
def transform_or_expression(self, that: our_types.OrExpression) -> Iterator[Error]:
if not (len(that.or_operands) >= 2):
yield Error("Or operands must have at least two items.")
for error in _verify_list_of__class(that.or_operands):
error.path._prepend(PropertySegment(that, "or_operands"))
yield error
# noinspection PyMethodMayBeStatic
def transform_not_expression(
self, that: our_types.NotExpression
) -> Iterator[Error]:
for error in verify(that.not_operand):
error.path._prepend(PropertySegment(that, "not_operand"))
yield error
# noinspection PyMethodMayBeStatic
def transform_query_filter(self, that: our_types.QueryFilter) -> Iterator[Error]:
for error in verify_fragment_field_identifier(that.fragment):
error.path._prepend(PropertySegment(that, "fragment"))
yield error
for error in verify(that.condition):
error.path._prepend(PropertySegment(that, "condition"))
yield error
# noinspection PyMethodMayBeStatic
def transform_query(self, that: our_types.Query) -> Iterator[Error]:
for error in verify(that.condition):
error.path._prepend(PropertySegment(that, "condition"))
yield error
if that.filters is not None:
for error in _verify_list_of__class(that.filters):
error.path._prepend(PropertySegment(that, "filters"))
yield error
_TRANSFORMER = _Transformer()
[docs]def verify(that: our_types.Class) -> Iterator[Error]:
"""
Verify the constraints of :paramref:`that` recursively.
:param that: instance whose constraints we want to verify
:yield: constraint violations
"""
yield from _TRANSFORMER.transform(that)
def _verify_list_of__class(that: Sequence[our_types.Class]) -> Iterator[Error]:
"""Verify the items of :paramref:`that` recursively."""
for i, item in enumerate(that):
for error in verify(item):
error.path._prepend(IndexSegment(that, i))
yield error
def _verify_list_of__name_type(that: Sequence[str]) -> Iterator[Error]:
"""Verify the items of :paramref:`that` recursively."""
for i, item in enumerate(that):
for error in verify_name_type(item):
error.path._prepend(IndexSegment(that, i))
yield error
def _verify_list_of__identifier(that: Sequence[str]) -> Iterator[Error]:
"""Verify the items of :paramref:`that` recursively."""
for i, item in enumerate(that):
for error in verify_identifier(item):
error.path._prepend(IndexSegment(that, i))
yield error
def _verify_list_of__json_object(
that: Sequence[our_types.JsonObject],
) -> Iterator[Error]:
"""Verify the items of :paramref:`that` recursively."""
for i, item in enumerate(that):
for error in our_json_value_verification.verify_json_object(item):
error.path._prepend(IndexSegment(that, i))
yield error
for key in item:
# NOTE (mristin):
# The key segment names the member whose key is erroneous. The path
# thus leads to the member, and the cause says what is wrong with
# the key which names it.
for error in verify_label_type(key):
error.path._prepend(KeySegment(item, key))
error.path._prepend(IndexSegment(that, i))
yield error
def _verify_list_of__path_item(that: Sequence[str]) -> Iterator[Error]:
"""Verify the items of :paramref:`that` recursively."""
for i, item in enumerate(that):
for error in verify_path_item(item):
error.path._prepend(IndexSegment(that, i))
yield error
def _verify_tuple2_of__class__class(
that: Tuple[our_types.Class, our_types.Class],
) -> Iterator[Error]:
"""Verify the items of :paramref:`that` recursively."""
for error in verify(that[0]):
error.path._prepend(IndexSegment(that, 0))
yield error
for error in verify(that[1]):
error.path._prepend(IndexSegment(that, 1))
yield error
[docs]def verify_xml_serializable_string(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
[docs]def verify_non_empty_xml_serializable_string(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
[docs]def verify_date_time_utc(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xs_date_time_utc(that):
yield Error(
"The value must match the pattern of xs:dateTime with "
+ "the time zone fixed to UTC."
)
if not is_xs_date_time_utc(that):
yield Error(
"The value must represent a valid xs:dateTime with the time "
+ "zone fixed to UTC."
)
[docs]def verify_date_time(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xs_date_time(that):
yield Error("The value must match the pattern of xs:dateTime.")
if not is_xs_date_time(that):
yield Error("The value must represent a valid xs:dateTime.")
[docs]def verify_duration(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xs_duration(that):
yield Error("The value must match the pattern of xs:duration.")
# noinspection PyUnusedLocal
[docs]def verify_blob_type(that: bytes) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
# There is no verification specified.
return
# Empty generator according to:
# https://stackoverflow.com/a/13243870/1600678
# noinspection PyUnreachableCode
yield
[docs]def verify_identifier(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 2048):
yield Error("Identifier shall have a maximum length of 2048 characters.")
[docs]def verify_value_type_iec_61360(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 2048):
yield Error(
"Value type IEC 61360 shall have a maximum length of 2048 " + "characters."
)
[docs]def verify_name_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 128):
yield Error("Name type shall have a maximum length of 128 characters.")
[docs]def verify_version_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not matches_version_type(that):
yield Error("Version type shall match the version pattern.")
if not (len(that) <= 4):
yield Error("Version type shall have a maximum length of 4 characters.")
[docs]def verify_revision_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not matches_revision_type(that):
yield Error("Revision type shall match the revision pattern.")
if not (len(that) <= 4):
yield Error("Revision type shall have a maximum length of 4 characters.")
[docs]def verify_label_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 64):
yield Error("Label type shall have a maximum length of 64 characters.")
[docs]def verify_message_topic_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 255):
yield Error(
"Message topic type shall have a maximum length of 255 " + "characters."
)
[docs]def verify_bcp_47_language_tag(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_bcp_47(that):
yield Error(
"The value must represent a value language tag conformant to " + "BCP 47."
)
[docs]def verify_content_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 128):
yield Error("Content type shall have a maximum length of 128 characters.")
if not matches_mime_type(that):
yield Error(
"The value must represent a valid content MIME type "
+ "according to RFC 2046."
)
[docs]def verify_path_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 2048):
yield Error("Identifier shall have a maximum length of 2048 characters.")
if not matches_rfc_2396(that):
yield Error(
"String with max 2048 and min 1 characters conformant to "
+ "a URI as per RFC 2396."
)
[docs]def verify_qualifier_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 128):
yield Error("Name type shall have a maximum length of 128 characters.")
[docs]def verify_value_data_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
[docs]def verify_id_short_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 128):
yield Error("Name type shall have a maximum length of 128 characters.")
if not matches_id_short(that):
yield Error(
"AASd-002: ID-short of Referables shall consist of at least "
+ "two characters and shall only feature letters, digits, "
+ "hyphen (``-``) and underscore (``_``); starting mandatory "
+ "with a letter, and not ending with a hyphen, *I.e.* "
+ "``^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9_]+$``."
)
[docs]def verify_string_uom(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 256):
yield Error("String UoM shall have a maximum length of 256 characters.")
[docs]def verify_identifier_uom(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 2048):
yield Error(
"Identifier UoM shall have a maximum length of 2048 " + "characters."
)
[docs]def verify_non_negative_integer(that: int) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not (that >= 0):
yield Error("The value must be a non-negative integer.")
[docs]def verify_code_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not (len(that) <= 32):
yield Error("Code type shall have a maximum length of 32 characters.")
if not (len(that) >= 1):
yield Error("The value must not be empty.")
[docs]def verify_short_id_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 128):
yield Error("Name type shall have a maximum length of 128 characters.")
[docs]def verify_locator_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not (len(that) <= 2048):
yield Error("Locator type shall have a maximum length of 2048 characters.")
if not (len(that) >= 1):
yield Error("The value must not be empty.")
[docs]def verify_text_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not (len(that) <= 2048):
yield Error("Text type shall have a maximum length of 2048 characters.")
if not (len(that) >= 1):
yield Error("The value must not be empty.")
[docs]def verify_scheme_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_xml_serializable_string(that):
yield Error(
"Constraint AASd-130: An attribute with data type 'string' "
+ "shall consist of these characters only: "
+ "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."
)
if not (len(that) >= 1):
yield Error("The value must not be empty.")
if not (len(that) <= 128):
yield Error("Name type shall have a maximum length of 128 characters.")
[docs]def verify_path_item(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_path_item(that):
yield Error("The value must match the pattern of a path item.")
[docs]def verify_field_identifier(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_field_identifier(that):
yield Error("The value must match the pattern of a field identifier.")
[docs]def verify_fragment_field_identifier(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_fragment_field_identifier(that):
yield Error(
"The value must match the pattern of a fragment field " + "identifier."
)
[docs]def verify_standard_string(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not (len(that) >= 1):
yield Error("The value must have at least one character.")
[docs]def verify_hex_literal_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_hex_literal(that):
yield Error("The value must match the pattern of a hexadecimal literal.")
[docs]def verify_date_time_literal_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_date_time_literal(that):
yield Error("The value must match the pattern of a date-time literal.")
[docs]def verify_time_literal_type(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_time_literal(that):
yield Error("The value must match the pattern of a time literal.")
[docs]def verify_reference_identifier(that: str) -> Iterator[Error]:
"""Verify the constraints of :paramref:`that`."""
if not matches_reference_identifier(that):
yield Error("The value must match the pattern of a reference identifier.")
# This code has been automatically generated by aas-core-codegen.
# Do NOT edit or append.