1
+ """
2
+ Provides functionality to read, modify and write Autosar arxml files,
3
+ both separately and in projects consisting of multiple files.
4
+
5
+ Classes:
6
+
7
+ - ArxmlFile
8
+ - AutosarModel
9
+ - AutosarVersion
10
+ - Element
11
+ - ElementType
12
+ - ValidSubElementInfo
13
+
14
+ Variables:
15
+
16
+ - __version__
17
+
18
+ """
19
+
1
20
from .autosar_data import *
2
21
from typing import Dict , List , FrozenSet , Literal , TypeAlias , Tuple , Union
3
22
@@ -10,50 +29,107 @@ ElementContent: TypeAlias = Union[Element, CharacterData]
10
29
VersionSpecification : TypeAlias = Union [AutosarVersion , List [AutosarVersion ]]
11
30
12
31
class ArxmlFile :
32
+ """
33
+ Represents a file that is part of an AutosarModel
34
+ """
13
35
def __repr__ (self ) -> str : ...
14
36
def __str__ (self ) -> str : ...
15
37
filename : str
38
+ """filename of the arxml file. Must be unique within the model."""
16
39
version : AutosarVersion
17
- def check_version_compatibility (self , version : AutosarVersion ) -> List [IncompatibleItemError ]: ...
40
+ """Autosar version of the file"""
41
+ def check_version_compatibility (self , version : AutosarVersion ) -> List [IncompatibleItemError ]:
42
+ """
43
+ check if the elements in the file would be compatible with the given target version.
44
+
45
+ returns a list of compatibility errors, each of which is an IncompatibleElementError, IncompatibleAttributeError or IncompatibleAttributeValueError
46
+ """
47
+ ...
18
48
model : AutosarModel
49
+ """the autosar data model which this file is part of"""
19
50
elements_dfs : ArxmlFileElementsDfsIterator
20
- def serialize (self ) -> str : ...
51
+ """dfs iterator over all elements in this file"""
52
+ def serialize (self ) -> str :
53
+ """serialize the the file to a string. This string can be loaded as valid arxml if is written to disk."""
54
+ ...
21
55
xml_standalone : bool
56
+ """contains the xml standalone attribute (if any) in the xml file header"""
22
57
23
58
class ArxmlFileElementsDfsIterator :
59
+ """
60
+ A depth first search iterator over all elements contained in the file that created this iterator
61
+ """
24
62
def __iter__ (self ) -> ArxmlFileElementsDfsIterator : ...
25
63
def __next__ (self ) -> Tuple [int , Element ]: ...
26
64
27
65
class Attribute :
66
+ """
67
+ An attribute on an element
68
+ """
28
69
attrname : AttributeName
70
+ """name of this attribute"""
29
71
content : CharacterData
72
+ """content of the attribute - this data can be free-form text, a pre-defined enum value (str), or very rarely a float or int"""
30
73
31
74
class AttributeIterator :
75
+ """
76
+ Iterates over all attributes on an element
77
+ """
32
78
def __iter__ (self ) -> AttributeIterator : ...
33
79
def __next__ (self ) -> Attribute : ...
34
80
35
81
class AutosarDataError (Exception ):
36
82
pass
37
83
38
84
class AutosarModel :
85
+ """
86
+ Autosar data model. It contains all elements.
87
+ """
39
88
def __repr__ (self ) -> str : ...
40
89
def __str__ (self ) -> str : ...
41
- def create_file (self , filename : str , version : AutosarVersion ) -> ArxmlFile : ...
42
- def load_buffer (self , buffer : str , filename : str , strict : bool ) -> Tuple [ArxmlFile , List [str ]]: ...
43
- def load_file (self , filename : str , strict : bool ) -> Tuple [ArxmlFile , List [str ]]: ...
44
- def remove_file (self , arxmlfile : ArxmlFile ) -> None : ...
45
- def serialize_files (self ) -> Dict [str , str ]: ...
46
- def write (self ) -> None : ...
90
+ def create_file (self , filename : str , version : AutosarVersion ) -> ArxmlFile :
91
+ """create a new file in the model"""
92
+ ...
93
+ def load_buffer (self , buffer : str , filename : str , strict : bool ) -> Tuple [ArxmlFile , List [str ]]:
94
+ """load a buffer (string) as arxml"""
95
+ ...
96
+ def load_file (self , filename : str , strict : bool ) -> Tuple [ArxmlFile , List [str ]]:
97
+ """load a file as arxml"""
98
+ ...
99
+ def remove_file (self , arxmlfile : ArxmlFile ) -> None :
100
+ """remove a file from the model. Any elements belonging exclusively to that file will also be removed."""
101
+ ...
102
+ def serialize_files (self ) -> Dict [str , str ]:
103
+ """serialize all files individually, to generate a dict(filename, serialized content),"""
104
+ ...
105
+ def write (self ) -> None :
106
+ """write all files in the model to disk"""
107
+ ...
47
108
files : List [ArxmlFile ]
109
+ """a list of ArxmlFile objects containing all files in the model"""
48
110
root_element : Element
49
- def get_element_by_path (self , autosar_path : str ) -> Element : ...
111
+ """The root element of the model, <AUTOSAR>"""
112
+ def get_element_by_path (self , autosar_path : str ) -> Element :
113
+ """get an identifiable element in the model by its Autosar path"""
114
+ ...
50
115
elements_dfs : ElementsDfsIterator
51
- def sort (self ) -> None : ...
116
+ """depth first dearch iterator over all elements in the model, regardless of their association with a file"""
117
+ def sort (self ) -> None :
118
+ """sort the entire model in place. Takes all ordering constraints into account."""
119
+ ...
52
120
identifiable_elements : List [str ]
53
- def get_references_to (self , target_path : str ) -> List [Element ]: ...
54
- def check_references (self ) -> List [Element ]: ...
121
+ """List of all paths of identifiable elements in the model"""
122
+ def get_references_to (self , target_path : str ) -> List [Element ]:
123
+ """get all reference elements which refer to the given Autosar path"""
124
+ ...
125
+ def check_references (self ) -> List [Element ]:
126
+ """check all references in the model and return a list of elements containing invalid references"""
127
+ ...
55
128
56
129
class AutosarVersion :
130
+ """
131
+ A version of the Autosar standard
132
+ """
57
133
def __new__ (cls , verstring : str ) -> AutosarVersion : ...
58
134
# this is the stupid result of method used by PyO3 to translate Rust enums
59
135
Autosar_4_0_1 : AutosarVersion
@@ -77,102 +153,226 @@ class AutosarVersion:
77
153
Autosar_00051 : AutosarVersion
78
154
79
155
class ContentType :
156
+ """
157
+ The content type of an element
158
+ """
80
159
# this is the stupid result of method used by PyO3 to translate Rust enums
81
160
Elements : ContentType
82
161
CharacterData : ContentType
83
162
Mixed : ContentType
84
163
85
164
class Element :
165
+ """
166
+ An element in the Autosar data model
167
+ """
86
168
def __repr__ (self ) -> str : ...
87
169
def __str__ (self ) -> str : ...
88
170
def serialize (self ) -> str : ...
89
171
parent : Element
172
+ """reference to the parent of this element"""
90
173
element_name : ElementName
174
+ """ElementName of this element, e.g. AUTOSAR or AR-PACKAGE"""
91
175
element_type : ElementType
176
+ """Reference to the element type of the element in the specification"""
92
177
item_name : str
178
+ """item name of an identifiable element, or None for elements which are not identifiable.
179
+
180
+ Setting this value renames the element and updates all references to it.
181
+ """
93
182
is_identifiable : bool
183
+ """true if the element is identifiable, false otherwise"""
94
184
is_reference : bool
185
+ """true if the element can contain a reference to another element"""
95
186
path : str
187
+ """the full autosar path of an identifiable element"""
96
188
model : AutosarModel
189
+ """reference to the model containing this element"""
97
190
content_type : ContentType
98
- def create_sub_element (self , element_name : ElementName ) -> Element : ...
99
- def create_sub_element_at (self , element_name : ElementName , position : int ) -> Element : ...
100
- def create_named_sub_element (self , element_name : ElementName , item_name : str ) -> Element : ...
101
- def create_named_sub_element_at (self , element_name : ElementName , item_name : str , position : int ) -> Element : ...
102
- def create_copied_sub_element (self , other : Element ) -> Element : ...
103
- def create_copied_sub_element_at (self , other : Element , position : int ) -> Element : ...
104
- def move_element_here (self , move_element : Element ) -> Element : ...
105
- def move_element_here_at (self , move_element : Element , position : int ) -> Element : ...
106
- def remove_sub_element (self , element : Element ) -> None : ...
191
+ """content type of the element: character data (<X>some text</X>), elements (<X><Y></Y></X>), or Mixed"""
192
+ def create_sub_element (self , element_name : ElementName ) -> Element :
193
+ """create a sub element under this element with the given ElementName"""
194
+ ...
195
+ def create_sub_element_at (self , element_name : ElementName , position : int ) -> Element :
196
+ """create a sub element under this element with the given ElementName at a specific position"""
197
+ ...
198
+ def create_named_sub_element (self , element_name : ElementName , item_name : str ) -> Element :
199
+ """create a named sub element under this element with the given ElementName"""
200
+ ...
201
+ def create_named_sub_element_at (self , element_name : ElementName , item_name : str , position : int ) -> Element :
202
+ """create a named sub element under this element with the given ElementName at a specific position"""
203
+ ...
204
+ def create_copied_sub_element (self , other : Element ) -> Element :
205
+ """create a copy of some other element (with all of its children) as a child of this element"""
206
+ ...
207
+ def create_copied_sub_element_at (self , other : Element , position : int ) -> Element :
208
+ """create a copy of some other element (with all of its children) as a child of this element at the given position"""
209
+ ...
210
+ def move_element_here (self , move_element : Element ) -> Element :
211
+ """move an element from somewhere else in this model or from another model to become a child element"""
212
+ ...
213
+ def move_element_here_at (self , move_element : Element , position : int ) -> Element :
214
+ """move an element from somewhere else in this model or from another model to become a child element at the given position"""
215
+ ...
216
+ def remove_sub_element (self , element : Element ) -> None :
217
+ """remove a sub element and all of its content"""
218
+ ...
107
219
reference_target : Element
108
- def get_sub_element (self , name_str : str ) -> Element : ...
109
- def get_sub_element_at (self , position : int ) -> Element : ...
220
+ """returns the target of the reference, if the element contains a reference"""
221
+ def get_sub_element (self , name_str : str ) -> Element :
222
+ """get a sub element by its element name. If there are several then this returns the first of them"""
223
+ ...
224
+ def get_sub_element_at (self , position : int ) -> Element :
225
+ """get an element by its position among the content of this element"""
226
+ ...
110
227
position : int
228
+ """the position of this element in the content of its parent"""
111
229
sub_elements : ElementsIterator
230
+ """an iterator over all sub elements in the content of this element. It skips character data content items"""
112
231
elements_dfs : ElementsDfsIterator
232
+ """dpeth first search iterator for this element and all of its sub elements"""
113
233
character_data : CharacterData
114
- def remove_character_data (self ) -> None : ...
115
- def insert_character_content_item (self , chardata : str , position : int ) -> None : ...
116
- def remove_character_content_item (self , position : int ) -> None : ...
234
+ """character content of this element, if any. For elements with ContentType=Element, or empty elements this is None"""
235
+ def remove_character_data (self ) -> None :
236
+ """remove the character data"""
237
+ ...
238
+ def insert_character_content_item (self , chardata : str , position : int ) -> None :
239
+ """for elements with ElementType mixed, this allows character data to be inserted at any point in the content of this element"""
240
+ ...
241
+ def remove_character_content_item (self , position : int ) -> None :
242
+ """remove one character content item from the given position"""
243
+ ...
117
244
content_item_count : int
245
+ """number of content items (character data and/or sub elements)"""
118
246
content : ElementContentIterator
247
+ """iterator over all content of this element"""
119
248
attributes : AttributeIterator
120
- def attribute_value (self , attrname : AttributeName ) -> CharacterData : ...
121
- def set_attribute (self , attrname : AttributeName , chardata : CharacterData ) -> None : ...
122
- def set_attribute_string (self , attrname : AttributeName , value : str ) -> None : ...
123
- def remove_attribute (self , attrname : AttributeName ) -> None : ...
124
- def sort (self ) -> None : ...
125
- def list_valid_sub_elements (self ) -> List [ValidSubElementInfo ]: ...
249
+ """iterator over all attributes of this element"""
250
+ def attribute_value (self , attrname : AttributeName ) -> CharacterData :
251
+ """get the attribute value of a specific attribute. Returns None if that attribute is not set"""
252
+ ...
253
+ def set_attribute (self , attrname : AttributeName , chardata : CharacterData ) -> None :
254
+ """set the given attribute to the provided value. If the attribute is valid for this element it will be created or modified as needed."""
255
+ ...
256
+ def set_attribute_string (self , attrname : AttributeName , value : str ) -> None :
257
+ """like set_attribute, but the input will be converted to the target data type as needed"""
258
+ ...
259
+ def remove_attribute (self , attrname : AttributeName ) -> None :
260
+ """remove an attribute from the element"""
261
+ ...
262
+ def sort (self ) -> None :
263
+ """sort this element and all of its sub elements"""
264
+ ...
265
+ def list_valid_sub_elements (self ) -> List [ValidSubElementInfo ]:
266
+ """provide information about valid sub elements as a list of ValidSubElementInfo"""
267
+ ...
126
268
file_membership : Tuple [bool , FrozenSet [ArxmlFile ]]
127
- def add_to_file (self , file : ArxmlFile ) -> None : ...
128
- def remove_from_file (self , file : ArxmlFile ) -> None : ...
269
+ """file membership information: the tuple (is_local, set(ArxmlFile)) tells if there is a restriction to file membership attached to this element, and which files the element is part of"""
270
+ def add_to_file (self , file : ArxmlFile ) -> None :
271
+ """add the element to a file. if necessary all parent elements of this element also become part of the file"""
272
+ ...
273
+ def remove_from_file (self , file : ArxmlFile ) -> None :
274
+ """remove this element from a file. Does not affect parent elements. When an element is no longer part of any file it is deleted."""
275
+ ...
129
276
xml_path : str
277
+ """a path listing all xml elements from the root of the model to the element. This is intended for display. e.g. in error messages"""
130
278
131
279
class ElementContentIterator :
280
+ """
281
+ Iterates over all content in an element
282
+
283
+ Content items an be sub elements or character data
284
+ """
132
285
def __iter__ (self ) -> ElementContentIterator : ...
133
286
def __next__ (self ) -> ElementContent : ...
134
287
135
288
class ElementType :
289
+ """
290
+ Type of an Element in the specification
291
+ """
136
292
is_named : bool
293
+ """Elements of this type must have a SHORT-NAME"""
137
294
is_ref : bool
295
+ """elements of this type must contain an autosar path in their character data, and have a DEST attribute"""
138
296
is_ordered : bool
297
+ """ordered elements may not be sorted, since the sub element order is semantically meaningful"""
139
298
splittable : List [AutosarVersion ]
140
- def splittable_in (self , version : AutosarVersion ) -> bool : ...
141
- def reference_dest_value (self , target : ElementType ) -> EnumItem : ...
142
- def find_sub_element (self , target_name : ElementName , version : VersionSpecification ) -> ElementType : ...
299
+ """a list of AutosarVersions in which this element is splittable"""
300
+ def splittable_in (self , version : AutosarVersion ) -> bool :
301
+ """is this element splittable in a particular AutosarVersion"""
302
+ ...
303
+ def reference_dest_value (self , target : ElementType ) -> EnumItem :
304
+ """helper to determine the correct value for the DEST attribute when setting a reference"""
305
+ ...
306
+ def find_sub_element (self , target_name : ElementName , version : VersionSpecification ) -> ElementType :
307
+ """find the ElementType of the named sub element in the specification of this ElementType"""
308
+ ...
143
309
144
310
class ElementsDfsIterator :
311
+ """
312
+ Dpeth first search iterator starting at the element which created the iterator
313
+ """
145
314
def __iter__ (self ) -> ElementsDfsIterator : ...
146
315
def __next__ (self ) -> Tuple [int , Element ]: ...
147
316
148
317
class ElementsIterator :
318
+ """
319
+ Iterator over all sub elements of an element
320
+ """
149
321
def __iter__ (self ) -> ElementsIterator : ...
150
322
def __next__ (self ) -> Element : ...
151
323
152
324
class IncompatibleAttributeError :
325
+ """
326
+ Information about an attribute that is incompatible with a given target version
327
+ """
153
328
def __repr__ (self ) -> str : ...
154
329
def __str__ (self ) -> str : ...
155
330
element : Element
331
+ """Element which contains the incompatible attribute"""
156
332
attribute : AttributeName
333
+ """Incompatible attribute"""
157
334
allowed_versions : List [AutosarVersion ]
335
+ """list of versions in which the attribute is permitted on this element"""
158
336
159
337
class IncompatibleAttributeValueError :
338
+ """
339
+ Information about an attribute value that is incompatible with a given target version
340
+ """
160
341
def __repr__ (self ) -> str : ...
161
342
def __str__ (self ) -> str : ...
162
343
element : Element
344
+ """Element which contains the incompatible attribute value"""
163
345
attribute : AttributeName
346
+ """Attribute which contains the invalid value"""
164
347
attribute_value : str
348
+ """The incompatible attribute value"""
165
349
allowed_versions : List [AutosarVersion ]
350
+ """list of versions in which the attribute value is permitted on this attribute"""
166
351
167
352
class IncompatibleElementError :
353
+ """
354
+ Information about an element that is incompatible with a given target version
355
+ """
168
356
def __repr__ (self ) -> str : ...
169
357
def __str__ (self ) -> str : ...
170
358
element : Element
359
+ """incompatible element"""
171
360
allowed_versions : List [AutosarVersion ]
361
+ """list of versions in which this element is compatible"""
172
362
173
363
class ValidSubElementInfo :
364
+ """
365
+ Details about a particular sub element
366
+ """
174
367
element_name : str
368
+ """name of the potential sub element"""
175
369
is_named : bool
370
+ """is the sub element named, i.e. does it need to be created with create_named_sub_element"""
176
371
is_allowed : bool
372
+ """is the sub element currently allowed, given the existing content of the element. Note that some sub elements are mutually exclusive"""
177
373
178
- version : str
374
+ __version__ : str
375
+ """
376
+ Version of the running autosar_data module.
377
+ It contains a semver string of the form 'x.y.z'
378
+ """
0 commit comments