diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2013-06-19 17:47:50 +0200 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2013-06-19 17:47:50 +0200 |
| commit | 875acdedb7f87fa86f731e897cb84c4e5022ba7e (patch) | |
| tree | b35dbee3715d8a8a9303b5146ce0d0574b60ea02 | |
| parent | eabade5d8491d7088cc166c55907962e5f1e0ec3 (diff) | |
dont call private and special methods on Py3status classes
| -rwxr-xr-x | py3status/__init__.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/py3status/__init__.py b/py3status/__init__.py index 33dd7a5..31d57b3 100755 --- a/py3status/__init__.py +++ b/py3status/__init__.py @@ -283,21 +283,29 @@ class UserModules(Thread): for include_path in self.include_paths: include_path = os.path.abspath(include_path) + '/' if os.path.isdir(include_path): - for file_name in os.listdir(include_path): + for f_name in os.listdir(include_path): try: module, class_inst = self.load_from_file( - include_path + file_name + include_path + f_name ) if module and class_inst: - self.classes[file_name] = (class_inst, []) - self.cache[file_name] = {} + self.classes[f_name] = (class_inst, []) + self.cache[f_name] = {} for method in dir(class_inst): - if not method.startswith('__'): - self.classes[file_name][1].append(method) + # ignore private methods + if '_Py3status' in method: + continue + try: + cl = eval("class_inst.%s.im_class" % method) + if 'Py3status' in str(cl): + self.classes[f_name][1].append(method) + except: + # ignore non Py3status-wide methods + pass except Exception: err = sys.exc_info()[1] syslog(LOG_ERR, "loading %s failed (%s)" \ - % (file_name, str(err))) + % (f_name, str(err))) def execute_classes(self): """ |
