From 875acdedb7f87fa86f731e897cb84c4e5022ba7e Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Wed, 19 Jun 2013 17:47:50 +0200 Subject: dont call private and special methods on Py3status classes --- py3status/__init__.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'py3status/__init__.py') 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): """ -- cgit v1.3