Skip to content

Commit f6e0127

Browse files
committed
upgrade to autosar-data 0.18
- add support for the new mathod Element::remove_sub_element_kind
1 parent efaa7d4 commit f6e0127

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

Cargo.lock

Lines changed: 4 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ name = "autosar_data"
1212
crate-type = ["cdylib"]
1313

1414
[dependencies]
15-
autosar-data = {version = "0.16"}
16-
autosar-data-specification = {version = "0.16"}
15+
autosar-data = {version = "0.18"}
16+
autosar-data-specification = {version = "0.18"}
1717
pyo3 = "0.23.3"

autosar_data.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ class Element:
230230
def remove_sub_element(self, element: Element) -> None:
231231
"""remove a sub element and all of its content"""
232232
...
233+
def remove_sub_element_kind(self, element_name: ElementName) -> None:
234+
"""remove a sub element with the given name, together with all of its content"""
235+
...
233236
reference_target: Element
234237
"""returns the target of the reference, if the element contains a reference"""
235238
def get_sub_element(self, name_str: str) -> Element:

src/element.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ impl Element {
219219
.map_err(|error| AutosarDataError::new_err(error.to_string()))
220220
}
221221

222+
fn remove_sub_element_kind(&self, name_str: &str) -> PyResult<()> {
223+
let element_name = get_element_name(name_str)?;
224+
self.0
225+
.remove_sub_element_kind(element_name)
226+
.map_err(|error| AutosarDataError::new_err(error.to_string()))
227+
}
228+
222229
#[setter]
223230
fn set_reference_target(&self, target: Element) -> PyResult<()> {
224231
self.0

test/element_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ def test_element_creation() -> None:
416416
invalid = el_pkg3.path
417417
with pytest.raises(AutosarDataError):
418418
invalid2 = el_pkg3.model
419+
420+
# create an ADMIN-DATA element in the root, and remove it again
421+
el_admin_data = model.root_element.create_sub_element("ADMIN-DATA")
422+
assert el_admin_data in model.root_element.sub_elements
423+
model.root_element.remove_sub_element_kind("ADMIN-DATA")
419424

420425
# validate the resulting model
421426
element_info = [x for x in model.root_element.elements_dfs]

0 commit comments

Comments
 (0)