returns dict with information home contains parsed plugins from module. { name : {path, version, config, (pattern, re), (plugin, class)} }
(self, folder, pattern=False, home={})
| 115 | self.log.debug("created index of plugins") |
| 116 | |
| 117 | def parse(self, folder, pattern=False, home={}): |
| 118 | """ |
| 119 | returns dict with information |
| 120 | home contains parsed plugins from module. |
| 121 | |
| 122 | { |
| 123 | name : {path, version, config, (pattern, re), (plugin, class)} |
| 124 | } |
| 125 | |
| 126 | """ |
| 127 | plugins = {} |
| 128 | if home: |
| 129 | pfolder = join("userplugins", folder) |
| 130 | if not exists(pfolder): |
| 131 | makedirs(pfolder) |
| 132 | if not exists(join(pfolder, "__init__.py")): |
| 133 | f = open(join(pfolder, "__init__.py"), "wb") |
| 134 | f.close() |
| 135 | |
| 136 | else: |
| 137 | pfolder = join(pypath, "module", "plugins", folder) |
| 138 | |
| 139 | configs = {} |
| 140 | for f in listdir(pfolder): |
| 141 | if (isfile(join(pfolder, f)) and f.endswith(".py") or f.endswith("_25.pyc") or |
| 142 | f.endswith("_26.pyc") or f.endswith("_27.pyc")) and not f.startswith("_"): |
| 143 | |
| 144 | data = open(join(pfolder, f)) |
| 145 | content = data.read() |
| 146 | data.close() |
| 147 | |
| 148 | if f.endswith("_25.pyc") and version_info[0:2] != (2, 5): |
| 149 | continue |
| 150 | elif f.endswith("_26.pyc") and version_info[0:2] != (2, 6): |
| 151 | continue |
| 152 | elif f.endswith("_27.pyc") and version_info[0:2] != (2, 7): |
| 153 | continue |
| 154 | |
| 155 | name = f[:-3] |
| 156 | if name[-1] == ".": name = name[:-4] |
| 157 | |
| 158 | version = self.VERSION.findall(content) |
| 159 | if version: |
| 160 | version = float(version[0][1]) |
| 161 | else: |
| 162 | version = 0 |
| 163 | |
| 164 | # home contains plugins from pyload root |
| 165 | if isinstance(home, dict) and name in home: |
| 166 | if home[name]["v"] >= version: |
| 167 | continue |
| 168 | |
| 169 | if name in IGNORE or (folder, name) in IGNORE: |
| 170 | continue |
| 171 | |
| 172 | plugins[name] = {} |
| 173 | plugins[name]["v"] = version |
| 174 |