from pathlib import Path

from ..utils import UnsupportedFileError

class Base():
    _supported_formats = [".pdf", ".doc", ".docx", ".ppt", ".pptx", ".txt", ".odt"] # "rtf"]

    def __init__(self) -> None:
        pass

    def initialize_details(self, input_file_path: str, output_file_format: str) -> None:
        self.input_file_path = input_file_path 
        self.input_file_format = self._input_file_path.suffix
        self.input_file_name = self._input_file_path.stem
        self.output_file_format = output_file_format

    @property    
    def input_file_path(self):
        return self._input_file_path

    @input_file_path.setter
    def input_file_path(self, value):
        file_path = Path(value)
        file_format = file_path.suffix 
        print(file_format)
        if(file_format not in Base._supported_formats):
            raise UnsupportedFileError(file_format) 
        self.input_file_format = file_path.suffix
        self.input_file_name = file_path.stem
        self._input_file_path = file_path

    @property    
    def output_file_format(self):
        return self._output_file_format

    @output_file_format.setter
    def output_file_format(self, value):
        if(value not in Base._supported_formats):
            raise UnsupportedFileError(value) 
        self._output_file_format = value

if __name__ == "main":
    base = Base("pdf_converter.pf", ".pdf")
    print(base.input_file_format)
    print(base.output_file_format)