-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileHandler.py
More file actions
29 lines (22 loc) · 1.46 KB
/
FileHandler.py
File metadata and controls
29 lines (22 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class FileHandler:
@staticmethod
def parse(file:str) -> dict[str, str] | set[str]:
"""A function to parse a file and extract it's data.
Args:
file (str): The filepath/filename of the file to process.
Raises:
NotImplementedError: This is always raised when calling FileHandler.parse, you should call the `parse` method of the child classes.
Returns:
dict[str, str]: A dictionary with key: value pairs where key is the `original text` and value is the `translated text`, or a set where each value is an `original text` where there is no translation for it.
"""
raise NotImplementedError("This method must be overridden")
@staticmethod
def export(file:str, texts:dict[str, str] | set[str]) -> None:
"""A function to export the `texts` to a file.
Args:
file (str): The filepath/filename to the file which will hold the data. (The file is created if it doesn't exist).
texts (dict[str, str] | set[str]): A dictionary with key: value pairs where key is the `original text` and value is the `translated text`, or a set where each value is an `original text` where there is no translation for it.
Raises:
NotImplementedError: This is always raised when calling FileHandle.export, you should call the `export` method of the child classes.
"""
raise NotImplementedError("This method must be overridden")