Skip to content

Instantly share code, notes, and snippets.

@remia
Created March 29, 2023 18:15
Show Gist options
  • Save remia/fe3fe6fddeff30d53631bae6317dc668 to your computer and use it in GitHub Desktop.
Save remia/fe3fe6fddeff30d53631bae6317dc668 to your computer and use it in GitHub Desktop.
import json
import importlib
from inspect import getmembers, isfunction
from clairmeta.settings import DCP_CHECK_SETTINGS
all_checks = {}
prefix = DCP_CHECK_SETTINGS['module_prefix']
for k, v in DCP_CHECK_SETTINGS['modules'].items():
try:
module_path = 'clairmeta.' + prefix + k
module = importlib.import_module(module_path)
funcs = getmembers(module.Checker, isfunction)
funcs = [f for f in funcs if f[0].startswith("check_")]
checks = [(f[0], f[1].__doc__) for f in funcs]
all_checks[module.__name__] = checks
except Exception as e:
print(str(e))
with open('result.json', 'w') as fp:
json.dump(all_checks, fp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment