consolidator
43 строки · 1.5 Кб
1import os2import sys3import pandas as pd4import datetime5from MainConsolidator import MainConsolidator6
7class handler(object):8@staticmethod9def module_name():10return 'Лист МКС-5000 со сторонней обработкой'11@staticmethod12def handle(row:pd.Series,consolidator:MainConsolidator)->pd.Series:13try:14row["error"] = pd.NA15except Exception as exp:16row["error"] = f"{exp}"17finally:18row["Продукт УП"]='не реализовано'19row["Время укрупнения"]=datetime.datetime.now()20return row21
22def debug_handle(self,inputDf:pd.DataFrame,consolidator:MainConsolidator,module:str=None)->pd.DataFrame:23try:24if module is None: return inputDf.apply(lambda row: self.handle(row,consolidator), axis=1)25else: return inputDf[inputDf["Производство2"]==module].apply(lambda row: self.handle(row,consolidator), axis=1)26except: raise27
28def get_compiled(self):29code:str=f"print('{__file__}')"30try:31with open(__file__,encoding="utf-8",mode="r") as f:32code=f.read()33except Exception as exp:34code=f"print('error: {exp}')"35finally:36cc = compile(code,"","exec")37return cc38
39if __name__=="__sheet_5k_contractor__":40consolidator:MainConsolidator41record:pd.Series42result:pd.Series43result = handler.handle(record,consolidator)44
45