Skip to content

Commit

Permalink
Explicitly open XML files as UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
juliavdkris committed Sep 29, 2023
1 parent 89014b0 commit 7ccfcc8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docx_charts/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, path: str, name: str):
path (str): The path to the chart's XML file.
name (str): The name of the chart.
'''
self.file = open(path, 'r+')
self.file = open(path, 'r+', encoding='utf-8')
self.name = name


Expand Down
4 changes: 2 additions & 2 deletions docx_charts/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def charts(self) -> list[Chart]:
A list of objects representing the charts in the Word document.
'''
charts: list[Chart] = []
with open(os.path.join(self.extracted.name, 'word/document.xml')) as doc:
with open(os.path.join(self.extracted.name, 'word/_rels/document.xml.rels')) as rels:
with open(os.path.join(self.extracted.name, 'word/document.xml'), encoding='utf-8') as doc:
with open(os.path.join(self.extracted.name, 'word/_rels/document.xml.rels'), encoding='utf-8') as rels:
doc_dom = minidom.parse(doc)
rels_dom = minidom.parse(rels)
for node in doc_dom.getElementsByTagName('c:chart'):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "docx-charts"
version = "0.1.10"
version = "0.1.11"
description = "Python library for manipulating chart data in word documents"
authors = ["Julia van der Kris <julia@juuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuulia.dev>"]
readme = "README.md"
Expand Down

0 comments on commit 7ccfcc8

Please sign in to comment.