from Load_process.file_processing import Process_File
from Load_process.Loading_Tools import Load_Data_Prepare, Load_Data_Tools
from merge_class.merge import merge

class Loding_Data_Root(Process_File):
    def __init__(self, Labels, Training_Root, Generator_Root):
        self.Label_List = Labels
        self.Train_Root = Training_Root
        self.Generator_Root = Generator_Root

        super().__init__()
        pass

    def process_main(self):
        '''處理讀Training、Image Generator檔資料'''
        Merge = merge()

        get_Image_Data = self.get_Image_data_roots(self.Train_Root)
        Get_ImageGenerator_Image_Data = self.get_Image_data_roots(self.Generator_Root)

        Get_Total_Image_Data_Root = Merge.merge_dict_to_dict(get_Image_Data, Get_ImageGenerator_Image_Data)

        return Get_Total_Image_Data_Root

    def get_Image_data_roots(self, DataRoot) -> dict: 
        Prepare = Load_Data_Prepare()
        Loading_Tool = Load_Data_Tools()

        # Setting the dictionary's content on Prepare.Set_Data_Dictionary object
        Prepare.Set_Label_List(self.Label_List)
        Prepare.Set_Data_Content([], len(self.Label_List))
        Prepare.Set_Data_Dictionary(Prepare.Get_Label_List(), Prepare.Get_Data_Content(), len(self.Label_List))

        # Gets the classifcation's total data
        get_image_data = Loading_Tool.get_data_root(DataRoot, Prepare.Get_Data_Dict(), Prepare.Get_Label_List())

        # return get_NPC_original_image_data
        return get_image_data