Skip to content

Commit

Permalink
check for xml parsing errors in merge_giella_dicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Phaqui committed Feb 28, 2024
1 parent 811a512 commit 2f46c67
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dicts/scripts/merge_giella_dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ def merge_giella_dicts(directory, out_file):
for file in xml_files:
with open(file) as f:
text = f.read()
tree = ET.fromstring(text)
try:
tree = ET.fromstring(text)
except ET.ParseError as e:
print(f"Warning: XML error in file {file}", file=sys.stderr)
print("The process continues, but the contents of this file will "
"not be included in the merged output")
print(e, file=sys.stderr)
continue
if tree.tag != "r":
# root node not <r>, not a giella xml dictionary
# (this can be the meta.xml file, for example)
Expand Down

0 comments on commit 2f46c67

Please sign in to comment.