summaryrefslogtreecommitdiff
path: root/libmat2/office.py
diff options
context:
space:
mode:
authorAlex Marchant2024-04-03 15:27:48 -0400
committerAlex Marchant2024-04-03 15:27:48 -0400
commitf931a0eceed3a89ef7c94a8a7b2bbed208bf0295 (patch)
tree18a47539de82c034ee753b947f157598fa4c6dc4 /libmat2/office.py
parent1b9ce34e2c3da718e79137e2c2210ccdcd299486 (diff)
Make utf-8 explicit in all tree.write calls
Diffstat (limited to 'libmat2/office.py')
-rw-r--r--libmat2/office.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/libmat2/office.py b/libmat2/office.py
index 6f69e4a..fa79834 100644
--- a/libmat2/office.py
+++ b/libmat2/office.py
@@ -38,7 +38,7 @@ def _sort_xml_attributes(full_path: str) -> bool:
38 for c in tree.getroot(): 38 for c in tree.getroot():
39 c[:] = sorted(c, key=lambda child: (child.tag, child.get('desc'))) 39 c[:] = sorted(c, key=lambda child: (child.tag, child.get('desc')))
40 40
41 tree.write(full_path, xml_declaration=True) 41 tree.write(full_path, xml_declaration=True, encoding='utf-8')
42 return True 42 return True
43 43
44 44
@@ -220,7 +220,7 @@ class MSOfficeParser(ZipParser):
220 for element in elements_to_remove: 220 for element in elements_to_remove:
221 parent_map[element].remove(element) 221 parent_map[element].remove(element)
222 222
223 tree.write(full_path, xml_declaration=True) 223 tree.write(full_path, xml_declaration=True, encoding='utf-8')
224 return True 224 return True
225 225
226 @staticmethod 226 @staticmethod
@@ -250,7 +250,7 @@ class MSOfficeParser(ZipParser):
250 for element in elements_to_remove: 250 for element in elements_to_remove:
251 parent_map[element].remove(element) 251 parent_map[element].remove(element)
252 252
253 tree.write(full_path, xml_declaration=True) 253 tree.write(full_path, xml_declaration=True, encoding='utf-8')
254 return True 254 return True
255 255
256 @staticmethod 256 @staticmethod
@@ -287,7 +287,7 @@ class MSOfficeParser(ZipParser):
287 parent_map[element].insert(position, children) 287 parent_map[element].insert(position, children)
288 parent_map[element].remove(element) 288 parent_map[element].remove(element)
289 289
290 tree.write(full_path, xml_declaration=True) 290 tree.write(full_path, xml_declaration=True, encoding='utf-8')
291 return True 291 return True
292 292
293 def __remove_content_type_members(self, full_path: str) -> bool: 293 def __remove_content_type_members(self, full_path: str) -> bool:
@@ -320,7 +320,7 @@ class MSOfficeParser(ZipParser):
320 if name in removed_fnames: 320 if name in removed_fnames:
321 root.remove(item) 321 root.remove(item)
322 322
323 tree.write(full_path, xml_declaration=True) 323 tree.write(full_path, xml_declaration=True, encoding='utf-8')
324 return True 324 return True
325 325
326 def _final_checks(self) -> bool: 326 def _final_checks(self) -> bool:
@@ -355,7 +355,7 @@ class MSOfficeParser(ZipParser):
355 355
356 for item in tree.iterfind('.//p14:creationId', namespace): 356 for item in tree.iterfind('.//p14:creationId', namespace):
357 item.set('val', '%s' % random.randint(0, 2**32)) 357 item.set('val', '%s' % random.randint(0, 2**32))
358 tree.write(full_path, xml_declaration=True) 358 tree.write(full_path, xml_declaration=True, encoding='utf-8')
359 return True 359 return True
360 360
361 @staticmethod 361 @staticmethod
@@ -371,7 +371,7 @@ class MSOfficeParser(ZipParser):
371 371
372 for item in tree.iterfind('.//p:sldMasterId', namespace): 372 for item in tree.iterfind('.//p:sldMasterId', namespace):
373 item.set('id', '%s' % random.randint(0, 2**32)) 373 item.set('id', '%s' % random.randint(0, 2**32))
374 tree.write(full_path, xml_declaration=True) 374 tree.write(full_path, xml_declaration=True, encoding='utf-8')
375 return True 375 return True
376 376
377 def _specific_cleanup(self, full_path: str) -> bool: 377 def _specific_cleanup(self, full_path: str) -> bool:
@@ -514,7 +514,7 @@ class LibreOfficeParser(ZipParser):
514 for changes in text.iterfind('.//text:tracked-changes', namespace): 514 for changes in text.iterfind('.//text:tracked-changes', namespace):
515 text.remove(changes) 515 text.remove(changes)
516 516
517 tree.write(full_path, xml_declaration=True) 517 tree.write(full_path, xml_declaration=True, encoding='utf-8')
518 return True 518 return True
519 519
520 def _specific_cleanup(self, full_path: str) -> bool: 520 def _specific_cleanup(self, full_path: str) -> bool: