verify_config_reference.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from __future__ import print_function, unicode_literals
  2. from fileinput import input as _input
  3. from sys import exit, stderr
  4. from celery.app.defaults import NAMESPACES, flatten
  5. ignore = {
  6. 'worker_agent',
  7. 'worker_pool_putlocks',
  8. 'broker_host',
  9. 'broker_user',
  10. 'broker_password',
  11. 'broker_vhost',
  12. 'broker_port',
  13. 'broker_transport',
  14. 'chord_propagates',
  15. 'redis_host',
  16. 'redis_port',
  17. 'redis_db',
  18. 'redis_password',
  19. 'worker_force_execv',
  20. }
  21. def is_ignored(setting, option):
  22. return setting in ignore or option.deprecate_by
  23. def find_undocumented_settings(directive='.. setting:: '):
  24. settings = dict(flatten(NAMESPACES))
  25. all = set(settings)
  26. inp = (l.decode('utf-8') for l in _input())
  27. documented = set(
  28. line.strip()[len(directive):].strip() for line in inp
  29. if line.strip().startswith(directive)
  30. )
  31. return [setting for setting in all ^ documented
  32. if not is_ignored(setting, settings[setting])]
  33. if __name__ == '__main__':
  34. sep = '\n * '
  35. missing = find_undocumented_settings()
  36. if missing:
  37. print(
  38. 'Error: found undocumented settings:{0}{1}'.format(
  39. sep, sep.join(sorted(missing))),
  40. file=stderr,
  41. )
  42. exit(1)
  43. print('OK: Configuration reference complete :-)')
  44. exit(0)