Skip to content

Commit e63c5a9

Browse files
committed
Fix Writer Model
1 parent 43671d1 commit e63c5a9

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

models/writer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from abc import abstractmethod, ABC
2-
from typing import List
2+
from typing import List, Dict
33

44
from models.word import WordDefinition
55

@@ -10,7 +10,7 @@ class Writer(ABC):
1010
"""
1111

1212
@abstractmethod
13-
def write(self, data: List[WordDefinition]):
13+
def write(self, data: Dict[str, List[WordDefinition]]):
1414
"""
1515
Write data to a file.
1616
"""

writers/json_writer.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from typing import List
21
import json
2+
from typing import List, Dict
33

44
from models.word import WordDefinition
55
from models.writer import Writer
@@ -13,5 +13,12 @@ def __init__(self, file_name: str, indent=4, sort_keys=True, ensure_ascii=False)
1313
self.sort_keys = sort_keys
1414
self.ensure_ascii = ensure_ascii
1515

16-
def write(self, data: List[WordDefinition]):
17-
json.dump(data, self.file, cls=WordDefinitionJsonEncoder, indent=self.indent, sort_keys=self.sort_keys,ensure_ascii=self.ensure_ascii)
16+
def write(self, data: Dict[str, List[WordDefinition]]):
17+
json.dump(
18+
data,
19+
self.file,
20+
cls=WordDefinitionJsonEncoder,
21+
indent=self.indent,
22+
sort_keys=self.sort_keys,
23+
ensure_ascii=self.ensure_ascii
24+
)

0 commit comments

Comments
 (0)