From faf28672e18121804d40e315a1406b97f80e3145 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Fri, 15 Mar 2013 18:47:14 +0100 Subject: iterate over user classes in a sorted manner to allow a predictive ordering of outputs --- py3status/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'py3status') diff --git a/py3status/__init__.py b/py3status/__init__.py index a4e0dcd..6fea1b2 100644 --- a/py3status/__init__.py +++ b/py3status/__init__.py @@ -158,8 +158,9 @@ def inject(j): then inject the result at the start of the json """ # inject our own functions' results - for my_class in list(USER_CLASSES.keys()): - for my_method in USER_CLASSES[my_class]: + for fn in sorted( USER_CLASSES.keys() ): + my_class, my_methods = USER_CLASSES[fn] + for my_method in my_methods: try: # handle a cache on user class methods results try: @@ -255,10 +256,10 @@ def main(): for fn in os.listdir(INCLUDE_PATH): module, class_inst = load_from_file(INCLUDE_PATH + fn) if module and class_inst: - USER_CLASSES[class_inst] = [] + USER_CLASSES[fn] = (class_inst, []) for method in dir(class_inst): if not method.startswith('__'): - USER_CLASSES[class_inst].append(method) + USER_CLASSES[fn][1].append(method) # run threaded i3status MESSAGE_QUEUE = Queue() -- cgit v1.3