From 813a5d803a4e611f9270845ab6f0115e5583cfff Mon Sep 17 00:00:00 2001 From: vunhat_minh Date: Fri, 27 Jun 2014 18:00:52 +0900 Subject: [PATCH] cal --- rainbowstream/rainbow.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index d98d1e0..554e27e 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -57,6 +57,7 @@ cmdset = [ 'block', 'unblock', 'report', + 'cal', 'h', 'c', 'q' @@ -938,6 +939,26 @@ def report(): printNicely(red('Sorry I can\'t understand.')) +def cal(): + """ + Unix's command `cal` + """ + # Format + rel = os.popen('cal').read().split('\n') + month = rel.pop(0) + month = random_rainbow(month) + date = rel.pop(0) + date = ' '.join([cycle_color(i) for i in date.split(' ')]) + today = os.popen('date +\'%d\'').read().strip() + # Display + print month + print date + for line in rel: + ary = line.split(' ') + ary = map(lambda x:on_grey(x) if x==today else grey(x),ary) + print ' '.join(ary) + + def help(): """ Help @@ -1126,6 +1147,7 @@ def process(cmd): block, unblock, report, + cal, help, clear, quit @@ -1167,6 +1189,7 @@ def listen(): ['@'], # block ['@'], # unblock ['@'], # report + [], # cal [], # help [], # clear [], # quit -- 2.25.1