-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_format_converter_factory.py
More file actions
29 lines (20 loc) · 983 Bytes
/
file_format_converter_factory.py
File metadata and controls
29 lines (20 loc) · 983 Bytes
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
import os
import logging
from file_conversion_type import FileConversionType
from interfaces.file_format_converter_interface import FileFormatConverter
from impl.file_conversion_md_to_html import MarkdownToHtml
log = logging.getLogger(f'__main__.{__name__}')
class FileFormatConverterFactory:
def __init__(self, verbose=False) -> None:
self.verbose = verbose
if self.verbose:
log.setLevel(logging.DEBUG)
log.info(f'Initializing {self.__class__.__name__}')
def get_instance(self, conversion_type: FileConversionType) -> FileFormatConverter:
if conversion_type == FileConversionType.MD_TO_HTML:
log.info(f'{conversion_type} is a supported conversion type.')
# current_directory = os.path.abspath(__file__)
# log.debug(f'{current_directory}')
return MarkdownToHtml(self.verbose)
else:
raise IOError(f'{conversion_type} is not a supported conversion type.')