Skip to content

Commit fa2ed93

Browse files
authored
Fix #114: Move productname close to productid (#115)
* Make them closer to better find it * Correct return type to include None
1 parent bf08c2a commit fa2ed93

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/docbuild/models/deliverable.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ class Deliverable:
2929
_meta: Metadata | None = None
3030

3131
@cached_property
32-
def productid(self) -> str:
32+
def productid(self) -> str|None:
3333
"""Return the product ID."""
3434
# ancestor::product/@productid
35-
return next(self._node.iterancestors('product')).attrib.get('productid')
35+
return self.product_node.attrib.get('productid', None)
36+
37+
@cached_property
38+
def productname(self) -> str|None:
39+
"""Return the product name."""
40+
# ancestor::product/name
41+
return self.product_node.findtext('name', default=None, namespaces=None)
3642

3743
@cached_property
3844
def docsetid(self) -> str:
@@ -185,12 +191,6 @@ def node(self) -> etree._Element:
185191
"""Return the node of the deliverable."""
186192
return self._node
187193

188-
@cached_property
189-
def productname(self) -> str:
190-
"""Return the product name or None if not found."""
191-
# anecstor::product/name
192-
return self.product_node.findtext('name', default=None, namespaces=None)
193-
194194
@cached_property
195195
def acronym(self) -> str:
196196
"""Return the product acronym or None if not found."""

0 commit comments

Comments
 (0)