Skip to content

Commit 9299d4c

Browse files
authored
TALIE-1370: fix bugs in docx parsing (#548)
1 parent 67b0d42 commit 9299d4c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

dedoc/readers/docx_reader/numbering_extractor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ def parse(self, xml: Tag, paragraph_properties: BaseProperties, run_properties:
6767
else:
6868
ilvl = ilvl["w:val"]
6969

70-
lvl_info: LevelInfo = self.num_dict[num_id].level_number2level_info[ilvl]
70+
try:
71+
lvl_info: LevelInfo = self.num_dict[num_id].level_number2level_info[ilvl]
72+
except KeyError:
73+
return
7174
text = self.__get_list_item_text(ilvl, num_id)
7275

7376
# change style of the paragraph/run: style -> pPr -> rPr

dedoc/readers/docx_reader/styles_extractor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __get_styles_hierarchy(self, style: Tag, style_id: str, style_type: StyleTyp
9999

100100
styles = [style]
101101
current_style = style
102-
while current_style.basedOn:
102+
while current_style and current_style.basedOn:
103103
try:
104104
parent_style_id = current_style.basedOn["w:val"]
105105
current_style = self.__find_style(parent_style_id, style_type)

0 commit comments

Comments
 (0)