Skip to content

Commit

Permalink
upgrade to autosar-data 0.18
Browse files Browse the repository at this point in the history
- add support for the new mathod Element::remove_sub_element_kind
  • Loading branch information
DanielT committed Feb 5, 2025
1 parent efaa7d4 commit f6e0127
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
20 changes: 4 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ name = "autosar_data"
crate-type = ["cdylib"]

[dependencies]
autosar-data = {version = "0.16"}
autosar-data-specification = {version = "0.16"}
autosar-data = {version = "0.18"}
autosar-data-specification = {version = "0.18"}
pyo3 = "0.23.3"
3 changes: 3 additions & 0 deletions autosar_data.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ class Element:
def remove_sub_element(self, element: Element) -> None:
"""remove a sub element and all of its content"""
...
def remove_sub_element_kind(self, element_name: ElementName) -> None:
"""remove a sub element with the given name, together with all of its content"""
...
reference_target: Element
"""returns the target of the reference, if the element contains a reference"""
def get_sub_element(self, name_str: str) -> Element:
Expand Down
7 changes: 7 additions & 0 deletions src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ impl Element {
.map_err(|error| AutosarDataError::new_err(error.to_string()))
}

fn remove_sub_element_kind(&self, name_str: &str) -> PyResult<()> {
let element_name = get_element_name(name_str)?;
self.0
.remove_sub_element_kind(element_name)
.map_err(|error| AutosarDataError::new_err(error.to_string()))
}

#[setter]
fn set_reference_target(&self, target: Element) -> PyResult<()> {
self.0
Expand Down
5 changes: 5 additions & 0 deletions test/element_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ def test_element_creation() -> None:
invalid = el_pkg3.path
with pytest.raises(AutosarDataError):
invalid2 = el_pkg3.model

# create an ADMIN-DATA element in the root, and remove it again
el_admin_data = model.root_element.create_sub_element("ADMIN-DATA")
assert el_admin_data in model.root_element.sub_elements
model.root_element.remove_sub_element_kind("ADMIN-DATA")

# validate the resulting model
element_info = [x for x in model.root_element.elements_dfs]
Expand Down

0 comments on commit f6e0127

Please sign in to comment.