|
@@ -1,3 +1,5 @@
|
|
|
+from src.errors.argument_exception import argument_exception
|
|
|
+from src.export.strategies.export import export
|
|
|
from src.export.exporter import exporter
|
|
|
from src.export.strategies.csv_export import csv_export
|
|
|
from src.export.strategies.markdown_export import markdown_export
|
|
@@ -5,6 +7,23 @@ from src.export.strategies.json_export import json_export
|
|
|
|
|
|
|
|
|
class exporter_factory:
|
|
|
+ __formats = {"csv": csv_export, "markdown": markdown_export, "json": json_export}
|
|
|
+
|
|
|
+ def create(self, format: str):
|
|
|
+ """Создать экспортер заданного формата"""
|
|
|
+
|
|
|
+ format = format.lower().strip()
|
|
|
+
|
|
|
+ if format not in self.__formats:
|
|
|
+ raise argument_exception("Wrong format name")
|
|
|
+
|
|
|
+ return self.make(self.__formats[format])
|
|
|
+
|
|
|
+ def make(self, strat: export):
|
|
|
+ """Создать экспортер с переданной стратегией"""
|
|
|
+
|
|
|
+ return exporter(strat())
|
|
|
+
|
|
|
def make_csv(self):
|
|
|
"""Создать экспортер формата CSV"""
|
|
|
|