You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
616 B

5 years ago
  1. import collections
  2. from .core import Check
  3. custom_checks_per_module = collections.defaultdict(list)
  4. class CustomCheck(Check):
  5. def __init__(self, module, func):
  6. super(CustomCheck, self).__init__(module)
  7. self.func = func
  8. def _run(self, env):
  9. return self.func(env)
  10. def custom_check(func):
  11. try:
  12. module = func.__module__.split(".")[2]
  13. except IndexError:
  14. module = ""
  15. custom_checks_per_module[module].append(CustomCheck(module=module, func=func))
  16. return func
  17. def get_checks_for_module(module_name):
  18. return custom_checks_per_module[module_name]