verify_config_reference.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from __future__ import print_function
  2. from fileinput import input as _input
  3. from sys import exit, stderr
  4. from celery.app.defaults import NAMESPACES, flatten
  5. ignore = frozenset([
  6. 'CELERYD_AGENT',
  7. 'CELERYD_POOL_PUTLOCKS',
  8. 'BROKER_HOST',
  9. 'BROKER_USER',
  10. 'BROKER_PASSWORD',
  11. 'BROKER_VHOST',
  12. 'BROKER_PORT',
  13. 'CELERY_REDIS_HOST',
  14. 'CELERY_REDIS_PORT',
  15. 'CELERY_REDIS_DB',
  16. 'CELERY_REDIS_PASSWORD',
  17. 'CELERYD_FORCE_EXECV',
  18. ])
  19. def is_ignored(setting, option):
  20. return setting in ignore or option.deprecate_by
  21. def find_undocumented_settings(directive='.. setting:: '):
  22. settings = dict(flatten(NAMESPACES))
  23. all = set(settings)
  24. documented = set(
  25. line.strip()[len(directive):].strip() for line in _input()
  26. if line.strip().startswith(directive)
  27. )
  28. return [setting for setting in all ^ documented
  29. if not is_ignored(setting, settings[setting])]
  30. if __name__ == '__main__':
  31. sep = '\n * '
  32. missing = find_undocumented_settings()
  33. if missing:
  34. print(
  35. 'Error: found undocumented settings:{0}{1}'.format(
  36. sep, sep.join(sorted(missing))),
  37. file=stderr,
  38. )
  39. exit(1)
  40. print('OK: Configuration reference complete :-)')
  41. exit(0)