From 04ce9f17b88eda5b21849442ee1fdaba1f50782a Mon Sep 17 00:00:00 2001 From: David Huggins-Daines Date: Fri, 13 Dec 2024 00:11:52 -0500 Subject: [PATCH] fix: somehow attribute classes got broken, fix them --- playa/structtree.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/playa/structtree.py b/playa/structtree.py index 64ce1ac8..73e61efb 100644 --- a/playa/structtree.py +++ b/playa/structtree.py @@ -222,7 +222,7 @@ def _make_attributes( if aobj == revision and prev_obj is not None: attr_objs.append(prev_obj) prev_obj = None - elif isinstance(aobj, dict): + elif isinstance(aobj, dict) or isinstance(aobj, PSLiteral): if prev_obj is not None: attr_objs.append(prev_obj) prev_obj = aobj @@ -244,14 +244,20 @@ def _make_attributes( logger.warning("Unknown attribute class %s", key) continue obj = self.class_map[key] - elif isinstance(obj, dict): for k, v in obj.items(): if isinstance(v, PSLiteral): attr[k] = decode_text(v.name) else: attr[k] = obj[k] - else: - logger.warning("Unexpected attribute object type: %r", obj) + for obj in attr_objs: + assert not isinstance(obj, ObjRef) + # An attribute dict + if isinstance(obj, dict): + for k, v in obj.items(): + if isinstance(v, PSLiteral): + attr[k] = decode_text(v.name) + else: + attr[k] = obj[k] return attr def _make_element(self, obj: Any) -> Tuple[Union[StructElement, None], List[Any]]: