Return relationship of matching `reltype`, `target`, and `is_external` from collection, or None if not found.
(
self, reltype: str, target: Part | str, is_external: bool = False
)
| 68 | return rels_elm.xml |
| 69 | |
| 70 | def _get_matching( |
| 71 | self, reltype: str, target: Part | str, is_external: bool = False |
| 72 | ) -> _Relationship | None: |
| 73 | """Return relationship of matching `reltype`, `target`, and `is_external` from |
| 74 | collection, or None if not found.""" |
| 75 | |
| 76 | def matches(rel: _Relationship, reltype: str, target: Part | str, is_external: bool): |
| 77 | if rel.reltype != reltype: |
| 78 | return False |
| 79 | if rel.is_external != is_external: |
| 80 | return False |
| 81 | rel_target = rel.target_ref if rel.is_external else rel.target_part |
| 82 | return rel_target == target |
| 83 | |
| 84 | for rel in self.values(): |
| 85 | if matches(rel, reltype, target, is_external): |
| 86 | return rel |
| 87 | return None |
| 88 | |
| 89 | def _get_rel_of_type(self, reltype: str): |
| 90 | """Return single relationship of type `reltype` from the collection. |
no outgoing calls
no test coverage detected