From 0cb554faaa25494b374473852d2e839c91691c73 Mon Sep 17 00:00:00 2001 From: Joos Kiener Date: Mon, 3 Jun 2024 06:53:27 +0200 Subject: [PATCH] fixed issue that would raise exception in case when a text element has no styles set. --- pycdxml/cdxml_converter/chemdraw_types.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pycdxml/cdxml_converter/chemdraw_types.py b/pycdxml/cdxml_converter/chemdraw_types.py index 0d067e5..48e72a4 100644 --- a/pycdxml/cdxml_converter/chemdraw_types.py +++ b/pycdxml/cdxml_converter/chemdraw_types.py @@ -220,8 +220,11 @@ def to_element(self, t: ET.Element): :return: the passed in element with the style elements added """ if len(self.style_starts) == 0: - raise TypeError('Call of to_element on CDXString is invalid if no styles are present. ' - 'If CDXString is part of a property there are no styles.') + # raise TypeError('Call of to_element on CDXString is invalid if no styles are present. ' + # 'If CDXString is part of a property there are no styles.') + logger.warning("No style elements () found for text element (). " + "Returning text element without any added styles.") + return t for idx, style in enumerate(self.styles): s = style.to_element() text_start_index = self.style_starts[idx]