| 56 | self._unload(type, plugin) |
| 57 | |
| 58 | def get_pattern(self, type, plugin): |
| 59 | if self.config.get('use_%s_list' % type): |
| 60 | plugin_list = self.config.get('%s_list' % type) |
| 61 | plugin_list = plugin_list.replace(' ', '').replace('\\', '') |
| 62 | plugin_list = plugin_list.replace('|', ',').replace(';', ',') |
| 63 | plugin_list = plugin_list.lower().split(',') |
| 64 | |
| 65 | plugin_set = set(plugin_list) |
| 66 | |
| 67 | if self.config.get('use_builtin_list'): |
| 68 | builtin_list = getattr(self, "BUILTIN_%sS" % type.upper()) |
| 69 | plugin_set.update(builtin_list) |
| 70 | |
| 71 | plugin_set.difference_update(('', u'')) |
| 72 | |
| 73 | if not plugin_set: |
| 74 | self.log_info(_("No %s to handle") % type) |
| 75 | return |
| 76 | |
| 77 | match_list = '|'.join(sorted(plugin_set)).replace('.', '\.') |
| 78 | pattern = self._regexmap[type][1] % match_list |
| 79 | |
| 80 | self.log_info(_("Handle %d %s%s: %s") % |
| 81 | (len(plugin_set), |
| 82 | type, |
| 83 | "" if len(plugin_set) == 1 else "s", |
| 84 | match_list.replace('\.', '.').replace('|', ', '))) |
| 85 | else: |
| 86 | plugin_list = [] |
| 87 | isXFS = lambda klass: any(k.__name__.startswith("XFS") |
| 88 | for k in inspect.getmro(klass)) |
| 89 | |
| 90 | for p in self.pyload.pluginManager.plugins[type].values(): |
| 91 | try: |
| 92 | klass = self.pyload.pluginManager.loadClass(type, p[ |
| 93 | 'name']) |
| 94 | |
| 95 | except AttributeError, e: |
| 96 | self.log_debug(e, trace=True) |
| 97 | continue |
| 98 | |
| 99 | if hasattr(klass, "PLUGIN_DOMAIN") and klass.PLUGIN_DOMAIN and isXFS( |
| 100 | klass): |
| 101 | plugin_list.append(klass.PLUGIN_DOMAIN) |
| 102 | |
| 103 | if plugin_list: |
| 104 | unmatch_list = '|'.join(sorted(plugin_list)).replace('.', '\.') |
| 105 | pattern = self._regexmap[type][0] % unmatch_list |
| 106 | else: |
| 107 | pattern = self._regexmap[type][0] |
| 108 | |
| 109 | self.log_info(_("Auto-discover new %ss") % type) |
| 110 | |
| 111 | return pattern |
| 112 | |
| 113 | def _load(self, type, plugin): |
| 114 | dict = self.pyload.pluginManager.plugins[type][plugin] |