MCPcopy Index your code
hub / github.com/pyload/pyload / PluginManager

Class PluginManager

module/plugins/PluginManager.py:32–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30from module.ConfigParser import IGNORE
31
32class PluginManager:
33 ROOT = "module.plugins."
34 USERROOT = "userplugins."
35 TYPES = ("crypter", "container", "hoster", "captcha", "accounts", "hooks", "internal")
36
37 PATTERN = re.compile(r'__pattern__.*=.*r("|\')([^"\']+)')
38 VERSION = re.compile(r'__version__.*=.*("|\')([0-9.]+)')
39 CONFIG = re.compile(r'__config__.*=.*(\[[^\]]+\])', re.MULTILINE)
40 DESC = re.compile(r'__description__.?=.?("|"""|\')([^"\']+)')
41
42
43 def __init__(self, core):
44 self.core = core
45
46 #self.config = self.core.config
47 self.log = core.log
48
49 self.plugins = {}
50 self.createIndex()
51
52 #register for import hook
53 sys.meta_path.append(self)
54
55
56 def createIndex(self):
57 """create information for all plugins available"""
58
59 def merge(dst, src, overwrite=False):
60 """merge dict of dicts"""
61 for name in src:
62 if name in dst:
63 if overwrite is True:
64 dst[name].update(src[name])
65 else:
66 for _k in set(src[name].keys()) - set(dst[name].keys()):
67 dst[name][_k] = src[name][_k]
68 else:
69 dst[name] = src[name]
70
71 sys.path.append(abspath(""))
72
73 if not exists("userplugins"):
74 makedirs("userplugins")
75 if not exists(join("userplugins", "__init__.py")):
76 f = open(join("userplugins", "__init__.py"), "wb")
77 f.close()
78
79 self.crypterPlugins , config = self.parse("crypter", pattern=True)
80 self.plugins["crypter"] = self.crypterPlugins
81 default_config = config
82
83 self.containerPlugins, config = self.parse("container", pattern=True)
84 self.plugins["container"] = self.containerPlugins
85 merge(default_config, config)
86
87 self.hosterPlugins, config = self.parse("hoster", pattern=True)
88 self.plugins["hoster"] = self.hosterPlugins
89 merge(default_config, config)

Callers 2

startMethod · 0.90
PluginManager.pyFile · 0.85

Calls 1

compileMethod · 0.80

Tested by

no test coverage detected