import os from utils.utils_func import list_dir class MatchingData(object): def __init__(self): pass def get_all_folder(self, root_path): folder_list = [] last_goods_no = "" last_label_color = "green" if os.path.exists(root_path): all_folder = list_dir(root_path) for folder_name in all_folder: # original_path = "{}/{}/800x800".format(root_path, folder_name) original_path = "{}/{}/原始图".format(root_path, folder_name) cut_out_path = "{}/{}/原始图_已抠图".format(root_path, folder_name) if os.path.exists(original_path) and os.path.exists(cut_out_path): if folder_name[:-1] == last_goods_no: label_color = last_label_color else: if last_label_color == "green": last_label_color = "blue" else: last_label_color = "green" last_goods_no = folder_name[:-1] label_color = last_label_color folder_list.append( {"root_path": root_path, "goods_art_no_folder_path": "{}/{}".format(root_path, folder_name), "original_path": original_path, "folder_name": folder_name, "cut_out_path": cut_out_path, "label_color": label_color, } ) return folder_list