init_db()
self.engine = create_engine('sqlite:///rainbow.db', echo=False)
-
def tweet_store(self, tweet_id):
"""
Store tweet id
session.add(t)
session.commit()
-
def rainbow_to_tweet_query(self, rid):
"""
Query base of rainbow id
res = session.query(Tweet).filter_by(rainbow_id=rid).all()
return res
-
def tweet_to_rainbow_query(self, tid):
"""
Query base of tweet id
res = session.query(Tweet).filter_by(tweet_id=tid).all()
return res
-
def message_store(self, message_id):
"""
Store message id
session.add(m)
session.commit()
-
def rainbow_to_message_query(self, rid):
"""
Query base of rainbow id
res = session.query(Message).filter_by(rainbow_id=rid).all()
return res
-
def message_to_rainbow_query(self, mid):
"""
Query base of message id
res = session.query(Message).filter_by(message_id=mid).all()
return res
-
def theme_store(self, theme_name):
"""
Store theme
session.add(th)
session.commit()
-
def theme_update(self, theme_name):
"""
Update theme
r.theme_name = theme_name
session.commit()
-
def theme_query(self):
"""
Query theme
res = session.query(Theme).all()
return res
-
def semaphore_store(self, lock, pause):
"""
Store semaphore lock
session.add(th)
session.commit()
-
def semaphore_update_lock(self, lock):
"""
Update semaphore lock
r.lock = lock
session.commit()
-
def semaphore_update_pause(self, pause):
"""
Update semaphore pause
r.pause = pause
session.commit()
-
def semaphore_query_lock(self):
"""
Query semaphore lock
res = session.query(Semaphore).all()
return res[0].lock
-
def semaphore_query_pause(self):
"""
Query semaphore pause
))
-def show_calendar(month, date, rel):
- """
- Show the calendar in rainbow mode
- """
- month = random_rainbow(month)
- date = ' '.join([cycle_color(i) for i in date.split(' ')])
- today = str(int(os.popen('date +\'%d\'').read().strip()))
- # Display
- printNicely(month)
- printNicely(date)
- for line in rel:
- ary = line.split(' ')
- ary = lmap(lambda x: color_func(c['CAL']['today'])(x)
- if x == today
- else color_func(c['CAL']['days'])(x), ary)
- printNicely(' '.join(ary))
-
-
def check_config():
"""
Check if config is changed
if expanded_url:
for index in range(len(expanded_url)):
tweet = lmap(
- lambda x: expanded_url[index] if x == url[index] else x,
+ lambda x: expanded_url[index]
+ if x == url[index]
+ else x,
tweet)
# Highlight RT
tweet = lmap(
- lambda x: color_func(
- c['TWEET']['rt'])(x) if x == 'RT' else x,
+ lambda x: color_func(c['TWEET']['rt'])(x)
+ if x == 'RT'
+ else x,
tweet)
# Highlight screen_name
tweet = lmap(lambda x: cycle_color(x) if x[0] == '@' else x, tweet)
# Highlight link
tweet = lmap(
- lambda x: color_func(
- c['TWEET']['link'])(x) if x[
- 0:4] == 'http' else x,
+ lambda x: color_func(c['TWEET']['link'])(x)
+ if x[0:4] == 'http'
+ else x,
tweet)
# Highlight hashtag
tweet = lmap(
- lambda x: color_func(
- c['TWEET']['hashtag'])(x) if x.startswith('#') else x,
+ lambda x: color_func(c['TWEET']['hashtag'])(x)
+ if x.startswith('#')
+ else x,
tweet)
# Highlight keyword
tweet = ' '.join(tweet)
formater = tweet.join(formater.split("#tweet"))
# Change clock word
word = [w for w in formater.split() if '#clock' in w][0]
- delimiter = color_func(
- c['TWEET']['clock'])(
- clock.join(
- word.split('#clock')))
+ delimiter = color_func(c['TWEET']['clock'])(
+ clock.join(word.split('#clock')))
formater = delimiter.join(formater.split(word))
# Change id word
word = [w for w in formater.split() if '#id' in w][0]
formater = text.join(formater.split("#message"))
# Change clock word
word = [w for w in formater.split() if '#clock' in w][0]
- delimiter = color_func(
- c['MESSAGE']['clock'])(
- clock.join(
- word.split('#clock')))
+ delimiter = color_func(c['MESSAGE']['clock'])(
+ clock.join(word.split('#clock')))
formater = delimiter.join(formater.split(word))
# Change id word
word = [w for w in formater.split() if '#id' in w][0]
printNicely('')
+def show_calendar(month, date, rel):
+ """
+ Show the calendar in rainbow mode
+ """
+ month = random_rainbow(month)
+ date = ' '.join([cycle_color(i) for i in date.split(' ')])
+ today = str(int(os.popen('date +\'%d\'').read().strip()))
+ # Display
+ printNicely(month)
+ printNicely(date)
+ for line in rel:
+ ary = line.split(' ')
+ ary = lmap(
+ lambda x: color_func(c['CAL']['today'])(x)
+ if x == today
+ else color_func(c['CAL']['days'])(x),
+ ary)
+ printNicely(' '.join(ary))
+
+
# Start the color cycle
start_cycle()