From 1fdd6a5c32958860b8fbdb400a5328f7522c2985 Mon Sep 17 00:00:00 2001 From: Vu Nhat Minh Date: Thu, 3 Jul 2014 17:27:18 +0900 Subject: [PATCH] global for draw --- rainbowstream/draw.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index c2119ff..a44450c 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -15,8 +15,9 @@ from .colors import * from .config import * from .db import * - db = RainbowDB() +g = {} + def init_cycle(): """ @@ -27,7 +28,8 @@ def init_cycle(): else RGB(int(i[4:])) for i in c['CYCLE_COLOR']] return itertools.cycle(colors_shuffle) -cyc = init_cycle() +g['cyc'] = init_cycle() + def order_rainbow(s): """ @@ -64,7 +66,7 @@ def cycle_color(s): """ Cycle the colors_shuffle """ - return next(cyc)(s) + return next(g['cyc'])(s) def ascii_art(text): @@ -73,7 +75,7 @@ def ascii_art(text): """ fi = figlet_format(text, font='doom') print('\n'.join( - [next(cyc)(i) for i in fi.split('\n')] + [next(g['cyc'])(i) for i in fi.split('\n')] )) @@ -99,7 +101,7 @@ def check_theme(): for d in data: c[d] = data[d] # Re-init color cycle - cyc = init_cycle() + g['cyc'] = init_cycle() def color_func(func_name): -- 2.25.1