le_compare.py 708 B

12345678910111213141516171819202122232425262728
  1. # coding=utf-8
  2. """
  3. @project: maxkb
  4. @Author:虎
  5. @file: lt_compare.py
  6. @date:2024/6/11 9:52
  7. @desc: 小于比较器
  8. """
  9. from typing import List
  10. from application.flow.compare import Compare
  11. class LECompare(Compare):
  12. def support(self, node_id, fields: List[str], source_value, compare, target_value):
  13. if compare == 'le':
  14. return True
  15. def compare(self, source_value, compare, target_value):
  16. try:
  17. return float(source_value) <= float(target_value)
  18. except Exception as e:
  19. try:
  20. return str(source_value) <= str(target_value)
  21. except Exception as _:
  22. pass
  23. return False