db = RainbowDB()
+def check_theme():
+ """
+ Check current theme and update if necessary
+ """
+ exists = db.theme_query()
+ themes = [t.theme_name for t in exists]
+ if c['theme'] != themes[0]:
+ c['theme'] = themes[0]
+ # Determine path
+ if c['theme'] == 'custom':
+ config = os.environ.get(
+ 'HOME',
+ os.environ.get(
+ 'USERPROFILE',
+ '')) + os.sep + '.rainbow_config.json'
+ else:
+ config = 'rainbowstream/colorset/'+c['theme']+'.json'
+ # Load new config
+ data = load_config(config)
+ if data:
+ for d in data:
+ c[d] = data[d]
+
def color_func(func_name):
"""
Draw the rainbow
"""
+ check_theme()
# Retrieve tweet
tid = t['id']
text = t['text']
for topic in trends[:c['TREND_MAX']]:
name = topic['name']
url = topic['url']
- line = cycle_color(name) + ': ' + color_func(TREND['url'])(url)
+ line = cycle_color(name) + ': ' + color_func(c['TREND']['url'])(url)
printNicely(line)
printNicely('')