Skip to content

Commit

Permalink
feat(importer): Don't delete descriptions
Browse files Browse the repository at this point in the history
If the ROS messages don't have a description for an object, keep the
current description in the Capella model unchanged. This allows adding
descriptions in the Capella model manually if they're not present in the
imported ROS messages package.

Fixes #11
  • Loading branch information
Wuestengecko committed Nov 4, 2024
1 parent d8d356d commit 3c01365
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions capella_ros_tools/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def _convert_class(
"set": {
"type": decl.Promise(promise_ref),
"kind": "COMPOSITION",
"description": field_def.description,
"min_card": decl.NewObject(
"LiteralNumericValue", value=field_def.type.card.min
),
Expand All @@ -148,6 +147,8 @@ def _convert_class(
),
},
}
if field_def.description:
prop_yml["set"]["description"] = field_def.description
props.append(prop_yml)
self._needed_associations.setdefault(pkg_name, {})[
prop_promise_id
Expand All @@ -158,9 +159,11 @@ def _convert_class(
"find": {
"name": msg_def.name,
},
"set": {
"description": msg_def.description,
},
"set": (
{"description": msg_def.description}
if msg_def.description
else {}
),
"sync": {
"properties": props,
},
Expand All @@ -174,26 +177,29 @@ def _convert_enum(
self._promise_ids[promise_id] = None
literals = []
for literal in enum_def.literals:
literal_yml = {
literal_yml: t.Any = {
"find": {
"name": literal.name,
},
"set": {
"description": literal.description,
"value": decl.NewObject(
"LiteralNumericValue", value=literal.value
),
},
}
if literal.description:
literal_yml["set"]["description"] = literal.description
literals.append(literal_yml)
yml = {
"promise_id": promise_id,
"find": {
"name": enum_def.name,
},
"set": {
"description": enum_def.description,
},
"set": (
{"description": enum_def.description}
if enum_def.description
else {}
),
"sync": {
"literals": literals,
},
Expand Down

0 comments on commit 3c01365

Please sign in to comment.