API Documentation: autosar_data¶
autosar_data ¶
Provides functionality to read, modify and write Autosar arxml files, both separately and in projects consisting of multiple files.
Classes:
- ArxmlFile
- AutosarModel
- AutosarVersion
- Element
- ElementType
- ValidSubElementInfo
Variables:
- version
AttributeName
module-attribute
¶
AttributeName: TypeAlias = Literal[
"ACCESSKEY",
"ALIGN",
"ALLOW-BREAK",
"ALT",
"BASE",
"BGCOLOR",
"BINDING-TIME",
"BLUEPRINT-VALUE",
"BREAK",
"CLASS",
"COLNAME",
"COLNUM",
"COLOR",
"COLS",
"COLSEP",
"COLWIDTH",
"COORDS",
"DEST",
"EDIT-HEIGHT",
"EDIT-WIDTH",
"EDITFIT",
"EDITSCALE",
"ENUM-TABLE",
"FILENAME",
"FIT",
"FLOAT",
"FONT",
"FRAME",
"GENERATOR",
"GID",
"HEIGHT",
"HELP-ENTRY",
"HREF",
"HTML-FIT",
"HTML-HEIGHT",
"HTML-SCALE",
"HTML-WIDTH",
"INDEX",
"INTERVAL-TYPE",
"ITEM-LABEL-POS",
"KEEP-WITH-PREVIOUS",
"L",
"LEVEL",
"MIME-TYPE",
"MOREROWS",
"NAME",
"NAME-PATTERN",
"NAMEEND",
"NAMEST",
"NOHREF",
"NOTATION",
"NOTE-TYPE",
"ONBLUR",
"ONCLICK",
"ONDBLCLICK",
"ONFOCUS",
"ONKEYDOWN",
"ONKEYPRESS",
"ONKEYUP",
"ONMOUSEDOWN",
"ONMOUSEMOVE",
"ONMOUSEOUT",
"ONMOUSEOVER",
"ONMOUSEUP",
"ORIENT",
"PGWIDE",
"RESOLUTION-POLICY",
"ROTATE",
"ROWSEP",
"S",
"SCALE",
"SD",
"SHAPE",
"SHORT-LABEL",
"SHOW-CONTENT",
"SHOW-RESOURCE-ALIAS-NAME",
"SHOW-RESOURCE-CATEGORY",
"SHOW-RESOURCE-LONG-NAME",
"SHOW-RESOURCE-NUMBER",
"SHOW-RESOURCE-PAGE",
"SHOW-RESOURCE-SHORT-NAME",
"SHOW-RESOURCE-TYPE",
"SHOW-SEE",
"SI",
"SPANNAME",
"STYLE",
"T",
"TABINDEX",
"TABSTYLE",
"TEX-RENDER",
"TITLE",
"TYPE",
"UUID",
"VALIDITY",
"VALIGN",
"VIEW",
"WIDTH",
"xml:space",
"xmlns",
"xmlns:xsi",
"xsi:schemaLocation",
]
CharacterDataType
module-attribute
¶
CharacterDataType: TypeAlias = Union[
CharacterDataTypeEnum,
CharacterDataTypeFloat,
CharacterDataTypeRestrictedString,
CharacterDataTypeString,
CharacterDataTypeUnsignedInt,
]
IncompatibleItemError
module-attribute
¶
IncompatibleItemError: TypeAlias = Union[
IncompatibleAttributeError,
IncompatibleAttributeValueError,
IncompatibleElementError,
]
VersionSpecification
module-attribute
¶
VersionSpecification: TypeAlias = Union[
AutosarVersion, List[AutosarVersion]
]
ArxmlFile ¶
Represents a file that is part of an AutosarModel
xml_standalone
property
¶
xml_standalone: bool
get the "xml_standalone" attribute from the header of the ARXML file
check_version_compatibility
method descriptor
¶
check_version_compatibility() -> List[
IncompatibleItemError
]
Check if the data in the ARXML file is compatible with the given target version
elements_dfs_with_max_depth
method descriptor
¶
elements_dfs_with_max_depth(
max_depth: int,
) -> ArxmlFileElementsDfsIterator
dfs iterator over all elements in this file, with a maximum depth
ArxmlFileElementsDfsIterator ¶
A depth first search iterator over all elements contained in the file that created this iterator
Attribute ¶
AttributeIterator ¶
Iterates over all attributes on an element
AttributeSpec ¶
AutosarDataError ¶
Bases: builtins.Exception
AutosarModel ¶
Autosar data model. It contains all elements.
elements_dfs
property
¶
elements_dfs: Iterator[int, Element]
depth first dearch iterator over all elements in the model, regardless of their association with a file
files
property
¶
files: List[ArxmlFile]
a list of ArxmlFile objects containing all files in the model
identifiable_elements
property
¶
identifiable_elements: IdentifiablesIterator
List of all paths of identifiable elements in the model
check_references
method descriptor
¶
check_references() -> List[Element]
check all references in the model and return a list of elements containing invalid references
create_file
method descriptor
¶
create_file(
filename: str, /, version: AutosarVersion = Ellipsis
) -> ArxmlFile
create a new file in the model
duplicate
method descriptor
¶
duplicate() -> AutosarModel
duplicate the model, creating a new independent copy
get_element_by_path
method descriptor
¶
get_element_by_path(path) -> Element
get an identifiable element in the model by its Autosar path
get_references_to
method descriptor
¶
get_references_to(target_path: str) -> List[Element]
get all reference elements which refer to the given Autosar path
load_buffer
method descriptor
¶
load_buffer(
buffer: str, filename: str, /, strict: bool = False
) -> Tuple[ArxmlFile, List[str]]
load a buffer (string) as arxml
load_file
method descriptor
¶
load_file(
filename: str, /, strict: bool = False
) -> Tuple[ArxmlFile, List[str]]
load a file as arxml
remove_file
method descriptor
¶
remove_file(file) -> None
remove a file from the model. Any elements belonging exclusively to that file will also be removed.
serialize_files
method descriptor
¶
serialize_files() -> Dict[str, str]
serialize all files individually, to generate a dict(filename, serialized content),
sort
method descriptor
¶
sort() -> None
sort the entire model in place. Takes all ordering constraints into account.
AutosarVersion ¶
CharacterDataTypeEnum ¶
The character data in an element or attribute is an enum value
CharacterDataTypeFloat ¶
The character data in an element or attribute is a float
CharacterDataTypeRestrictedString ¶
CharacterDataTypeString ¶
CharacterDataTypeUnsignedInt ¶
The character data in an element or attribute is an unsigned integer
ContentMode ¶
The content mode of an element type
ContentType ¶
Element ¶
An element in the Autosar data model
reference_target
property
¶
reference_target: Element
Set the reference target of a reference element
This is only valid for elements with a reference content type.
add_to_file
method descriptor
¶
add_to_file(file: ArxmlFile) -> None
add the element to a file. if necessary all parent elements of this element also become part of the file
attribute_value
method descriptor
¶
attribute_value(attrname_str) -> CharacterData
get the attribute value of a specific attribute. Returns None if that attribute is not set
create_copied_sub_element
method descriptor
¶
create_copied_sub_element() -> Element
Create a new sub-element by copying the given element and all its children
This creates a fully-independen copy. The function can copy elements between different models.
create_named_sub_element
method descriptor
¶
create_named_sub_element() -> Element
Create a new sub-element with the given element name and item name
create_sub_element
method descriptor
¶
create_sub_element() -> Element
Create a new sub-element with the given element name
elements_dfs_with_max_depth
method descriptor
¶
elements_dfs_with_max_depth(
max_depth: int,
) -> Iterator[Tuple[int, Element]]
depth first search iterator for this element and all of its sub elements, with a maximum depth
get_bsw_sub_element
method descriptor
¶
get_bsw_sub_element() -> Element
get the sub element with the given definition ref. It is possible to specify either the full definition ref, or only the last part after the final '/'
get_named_sub_element
method descriptor
¶
get_named_sub_element() -> Element
Get the sub-element with the given item name, if it exists
get_or_create_named_sub_element
method descriptor
¶
get_or_create_named_sub_element() -> Element
Get or create a sub-element with the given element name and item name
get_or_create_sub_element
method descriptor
¶
get_or_create_sub_element() -> Element
Get or create a sub-element with the given element name
This is used to ensure that a sub-element with the given name exists.
get_sub_element
method descriptor
¶
get_sub_element() -> Element
Get a sub-element with the given element name
If multiple sub-elements with the same name exist, only the first one is returned.
get_sub_element_at
method descriptor
¶
get_sub_element_at() -> Element
Get a sub-element at the given position
The position is 0-based, and must be less than the number of sub-elements.
insert_character_content_item
method descriptor
¶
insert_character_content_item() -> None
for elements with ElementType mixed, this allows character data to be inserted at any point in the content of this element
list_valid_sub_elements
method descriptor
¶
list_valid_sub_elements() -> List[ValidSubElementInfo]
provide information about valid sub elements as a list of ValidSubElementInfo
move_element_here
method descriptor
¶
move_element_here() -> Element
Move the given element to become a sub-element of this element
remove_attribute
method descriptor
¶
remove_attribute() -> None
remove an attribute from the element
remove_character_content_item
method descriptor
¶
remove_character_content_item() -> None
remove one character content item from the given position
remove_character_data
method descriptor
¶
remove_character_data() -> None
Remove the character data from the element
remove_from_file
method descriptor
¶
remove_from_file(file: ArxmlFile) -> None
remove this element from a file. Does not affect parent elements. When an element is no longer part of any file it is deleted.
remove_sub_element
method descriptor
¶
remove_sub_element() -> None
Remove the given sub-element from this element
Removing the element invalidates it, and causes all of the removed elements children to be removed as well.
remove_sub_element_kind
method descriptor
¶
remove_sub_element_kind() -> None
Remove a sub-element with the given element name
If multiple sub-elements with the same name exist, only the first one is removed.
set_attribute
method descriptor
¶
set_attribute(attrname_str, value) -> None
set the given attribute to the provided value. If the attribute is valid for this element it will be created or modified as needed.
ElementContentIterator ¶
Iterates over all content in an element
Content items an be sub elements or character data
ElementType ¶
Type of an Element in the specification
find_attribute_spec
method descriptor
¶
find_attribute_spec(attrname_str) -> AttributeSpec
find the specification for the given attribute name
find_sub_element
method descriptor
¶
find_sub_element(
target_name: ElementName, version_obj
) -> ElementType
find the ElementType of the named sub element in the specification of this ElementType
reference_dest_value
method descriptor
¶
reference_dest_value(target: ElementType) -> EnumItem
helper to determine the correct value for the DEST attribute when setting a reference
splittable_in
method descriptor
¶
splittable_in(version: AutosarVersion) -> bool
is this element splittable in a particular AutosarVersion
ElementsDfsIterator ¶
ElementsIterator ¶
Iterator over all sub elements of an element
IdentifiablesIterator ¶
Iterator of all identifiable elements in the model. It provides the tuple (path, Element) for each entry.
IncompatibleAttributeError ¶
IncompatibleAttributeValueError ¶
IncompatibleElementError ¶
SubElementSpec ¶
Specification of a sub element
ValidSubElementInfo ¶
check_buffer
builtin
¶
check_buffer()
Check if the given buffer contains valid Autosar data
The function returns true if the buffer starts with a valid arxml header (after skipping whitespace and comments). This function does not check anything after the header.
check_file
builtin
¶
check_file(filename: str)
Check if the file contains arxml data. Returns true if an arxml file header is found and does not parse anything after it.