Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't delete descriptions #12

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions capella_ros_tools/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,14 @@ def _convert_class(
f"{field_def.type.package or pkg_name}.{field_def.type.name}"
)
self._promise_id_refs[promise_ref] = None
prop_yml = {
prop_yml: t.Any = {
"promise_id": prop_promise_id,
"find": {
"name": field_def.name,
},
"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
13 changes: 0 additions & 13 deletions tests/data/data_model/example_msgs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
- find:
name: RED
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '0'
Expand Down Expand Up @@ -143,28 +142,24 @@
- find:
name: OK
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '0'
- find:
name: WARN
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '1'
- find:
name: ERROR
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '2'
- find:
name: STALE
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '3'
Expand Down Expand Up @@ -259,7 +254,6 @@
name: field
promise_id: package2.SampleClassEnum.field
set:
description: ''
kind: COMPOSITION
max_card: !new_object
_type: LiteralNumericValue
Expand All @@ -279,28 +273,24 @@
- find:
name: OK
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '0'
- find:
name: WARN
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '1'
- find:
name: ERROR
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '2'
- find:
name: STALE
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '3'
Expand All @@ -314,21 +304,18 @@
- find:
name: RED
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '0'
- find:
name: BLUE
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '1'
- find:
name: YELLOW
set:
description: ''
value: !new_object
_type: LiteralNumericValue
value: '2'
Expand Down
Loading