No Description
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.

manage_lodel.py 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #-*- coding: utf-8 -*-
  2. import sys
  3. import argparse
  4. try:
  5. from loader import *
  6. except ImportError: pass
  7. from plugins import *
  8. if __name__ == '__main__':
  9. parser = argparse.ArgumentParser()
  10. parser.add_argument(
  11. '--list-hooks',
  12. action='store_const',
  13. const=True,
  14. default=False,
  15. help='Display the list of registered hooks'
  16. )
  17. parser.add_argument(
  18. '--list-plugins',
  19. action='store_const',
  20. const=True,
  21. default=False,
  22. help='Display the list of plugins'
  23. )
  24. parser.add_argument(
  25. '--plugin',
  26. action='store',
  27. type=str,
  28. metavar='PLUGIN_NAME',
  29. nargs='+',
  30. help='Filter on plugins name'
  31. )
  32. parser.add_argument(
  33. '--hookname',
  34. action='store',
  35. type=str,
  36. metavar='HOOK_NAME',
  37. nargs='+',
  38. help='Filter on hook name'
  39. )
  40. kwargs = parser.parse_args()
  41. # Listing registered hooks
  42. if kwargs.list_hooks:
  43. import Lodel.plugins
  44. list_args = {}
  45. if kwargs.plugin is not None and len(kwargs.plugin) > 0:
  46. list_args['plugins'] = kwargs.plugin
  47. if kwargs.hookname is not None and len(kwargs.hookname) > 0:
  48. list_args['names'] = kwargs.hookname
  49. print(Lodel.plugins.list_hooks(**list_args))
  50. exit(0)
  51. # Listing plugins
  52. elif kwargs.list_plugins:
  53. import Lodel.plugins
  54. print(Lodel.plugins.list_plugins())
  55. exit(0)
  56. parser.print_help()
  57. exit(1)