Guest User

Untitled

a guest
Dec 13th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. # содержимое /plugins/__init__.py
  2. import importlib
  3. import pkgutil
  4.  
  5. __all__ = []
  6.  
  7. def import_plugins(package):
  8. if isinstance(package, str):
  9. package = importlib.import_module(package)
  10.  
  11. for loader, name, is_pkg in pkgutil.walk_packages(package.__path__):
  12. full_name = package.__name__ + '.' + name
  13.  
  14. module = importlib.import_module(full_name)
  15.  
  16. for name in dir(module):
  17. if name[0] == "_":
  18. continue
  19.  
  20. e = module.__getattribute__(name)
  21.  
  22. if e in __all__:
  23. continue
  24.  
  25. if True:
  26. __all__.append(e.__name__)
  27. globals()[e.__name__] = e
  28.  
  29. if is_pkg:
  30. import_plugins(full_name)
  31.  
  32.  
  33. import_plugins(__name__)
  34.  
  35. from Plugins import *
  36.  
  37.  
  38. class Settings:
  39. __slots__ = ("inner_data", "plugins", "user_plugins")
  40.  
  41. def __init__(self):
  42. self.plugins = ()
  43. self.user_plugins = ()
  44. self.inner_data = InnerDataPlugin()
  45.  
  46. self.plugins = (
  47. AntiFloodPlugin(),
  48. self.inner_data,
  49. PairPlugin("pair test", "pt"),
  50. TestingPlugin("test", "tst"),
  51. )
  52.  
  53. self.user_plugins = (
  54. PairUP("pair test", "pt"),
  55. )
Add Comment
Please, Sign In to add comment