summaryrefslogtreecommitdiff
path: root/libmat2/office.py
diff options
context:
space:
mode:
authorjvoisin2022-08-28 22:29:06 +0200
committerjvoisin2022-08-28 22:29:06 +0200
commitcc5be8608b49d74a633b80a95a49a018d4dcd477 (patch)
tree322c21ba2543831d5a1804ebce50a3f7c2391029 /libmat2/office.py
parent292f44c0861a57b54a289641ead7e59f158e307e (diff)
Simplify the typing annotations
Diffstat (limited to 'libmat2/office.py')
-rw-r--r--libmat2/office.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/libmat2/office.py b/libmat2/office.py
index d7eca11..ae6ef39 100644
--- a/libmat2/office.py
+++ b/libmat2/office.py
@@ -4,7 +4,7 @@ import logging
4import os 4import os
5import re 5import re
6import zipfile 6import zipfile
7from typing import Dict, Set, Pattern, Tuple, Any 7from typing import Pattern, Any
8 8
9import xml.etree.ElementTree as ET # type: ignore 9import xml.etree.ElementTree as ET # type: ignore
10 10
@@ -13,10 +13,9 @@ from .archive import ZipParser
13# pylint: disable=line-too-long 13# pylint: disable=line-too-long
14 14
15# Make pyflakes happy 15# Make pyflakes happy
16assert Set
17assert Pattern 16assert Pattern
18 17
19def _parse_xml(full_path: str) -> Tuple[ET.ElementTree, Dict[str, str]]: 18def _parse_xml(full_path: str) -> tuple[ET.ElementTree, dict[str, str]]:
20 """ This function parses XML, with namespace support. """ 19 """ This function parses XML, with namespace support. """
21 namespace_map = dict() 20 namespace_map = dict()
22 for _, (key, value) in ET.iterparse(full_path, ("start-ns", )): 21 for _, (key, value) in ET.iterparse(full_path, ("start-ns", )):
@@ -148,7 +147,7 @@ class MSOfficeParser(ZipParser):
148 return False 147 return False
149 xml_data = zin.read('[Content_Types].xml') 148 xml_data = zin.read('[Content_Types].xml')
150 149
151 self.content_types = dict() # type: Dict[str, str] 150 self.content_types = dict() # type: dict[str, str]
152 try: 151 try:
153 tree = ET.fromstring(xml_data) 152 tree = ET.fromstring(xml_data)
154 except ET.ParseError: 153 except ET.ParseError:
@@ -431,7 +430,7 @@ class MSOfficeParser(ZipParser):
431 430
432 return True 431 return True
433 432
434 def _specific_get_meta(self, full_path: str, file_path: str) -> Dict[str, Any]: 433 def _specific_get_meta(self, full_path: str, file_path: str) -> dict[str, Any]:
435 """ 434 """
436 Yes, I know that parsing xml with regexp ain't pretty, 435 Yes, I know that parsing xml with regexp ain't pretty,
437 be my guest and fix it if you want. 436 be my guest and fix it if you want.
@@ -512,7 +511,7 @@ class LibreOfficeParser(ZipParser):
512 return False 511 return False
513 return True 512 return True
514 513
515 def _specific_get_meta(self, full_path: str, file_path: str) -> Dict[str, Any]: 514 def _specific_get_meta(self, full_path: str, file_path: str) -> dict[str, Any]:
516 """ 515 """
517 Yes, I know that parsing xml with regexp ain't pretty, 516 Yes, I know that parsing xml with regexp ain't pretty,
518 be my guest and fix it if you want. 517 be my guest and fix it if you want.