dim_template_class.py 873 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # -*- coding: utf-8 -*-
  2. # @Time : 2023/7/20 17:41
  3. # @Author : XuJiakai
  4. # @File : dim_template_class
  5. # @Software: PyCharm
  6. from abc import abstractmethod
  7. class DimTemplateClass:
  8. def __init__(self):
  9. pass
  10. @abstractmethod
  11. async def _exec_row(self, row_data: dict):
  12. raise NotImplementedError
  13. async def _prefix_func(self, dim_data: list):
  14. pass
  15. async def _postfix_func(self, dim_data: list):
  16. pass
  17. async def execute_dim(self, dim_data: list):
  18. await self._prefix_func(dim_data)
  19. result_list = []
  20. for row in dim_data:
  21. row_data = await self._exec_row(row)
  22. if row_data is not None:
  23. result_list.append(row_data)
  24. if len(result_list) > 0:
  25. await self._prefix_func(result_list)
  26. return result_list
  27. if __name__ == '__main__':
  28. pass