verify_config_reference.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. ])
  18. def is_ignored(setting, option):
  19. return setting in ignore or option.deprecate_by
  20. def find_undocumented_settings(directive='.. setting:: '):
  21. settings = dict(flatten(NAMESPACES))
  22. all = set(settings)
  23. documented = set(
  24. line.strip()[len(directive):].strip() for line in _input()
  25. if line.strip().startswith(directive)
  26. )
  27. return [setting for setting in all ^ documented
  28. if not is_ignored(setting, settings[setting])]
  29. if __name__ == '__main__':
  30. sep = '\n * '
  31. missing = find_undocumented_settings()
  32. if missing:
  33. print(
  34. 'Error: found undocumented settings:{0}{1}'.format(
  35. sep, sep.join(sorted(missing))),
  36. file=stderr,
  37. )
  38. exit(1)
  39. print('OK: Configuration reference complete :-)')
  40. exit(0)