From 0d9977c739e5e448af4b49332bd6df1aa9edafc3 Mon Sep 17 00:00:00 2001 From: Orakaro Date: Sun, 27 Jul 2014 14:18:43 +0900 Subject: [PATCH] [] and id= --- rainbowstream/colorset/config | 4 +-- rainbowstream/draw.py | 57 +++++++++++++++++++++++------------ setup.py | 2 +- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/rainbowstream/colorset/config b/rainbowstream/colorset/config index c047f94..d2388d8 100644 --- a/rainbowstream/colorset/config +++ b/rainbowstream/colorset/config @@ -35,11 +35,11 @@ "FORMAT": { "TWEET": { "CLOCK_FORMAT" : "%Y/%m/%d %H:%M:%S", - "DISPLAY" : "\n #name #nick:\n #clock #id #fav\n #tweet" + "DISPLAY" : "\n #name #nick:\n [#clock] [id=#id] #fav\n #tweet" }, "MESSAGE": { "CLOCK_FORMAT" : "%Y/%m/%d %H:%M:%S", - "DISPLAY" : "\n #sender_name #sender_nick #to #recipient_name #recipient_nick :\n #clock #id\n #message" + "DISPLAY" : "\n #sender_name #sender_nick #to #recipient_name #recipient_nick :\n [#clock] [message_id=#id]\n #message" } } } diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index 6352d3a..0140137 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -235,8 +235,8 @@ def draw(t, keyword=None, check_semaphore=False, fil=[], ig=[]): # Format info name = cycle_color(name) nick = color_func(c['TWEET']['nick'])(' ' + screen_name + ' ') - clock = color_func(c['TWEET']['clock'])('[' + clock + ']') - id = color_func(c['TWEET']['id'])('[id=' + str(rid) + ']') + clock = clock + id = str(rid) fav = '' if favorited: fav = color_func(c['TWEET']['favorited'])(u'\u2605') @@ -275,12 +275,21 @@ def draw(t, keyword=None, check_semaphore=False, fil=[], ig=[]): # Load config formater try: formater = c['FORMAT']['TWEET']['DISPLAY'] - formater = name.join(formater.split("#name")) - formater = nick.join(formater.split("#nick")) - formater = clock.join(formater.split("#clock")) - formater = id.join(formater.split("#id")) - formater = fav.join(formater.split("#fav")) - formater = tweet.join(formater.split("#tweet")) + formater = name.join(formater.split("#name")) + formater = nick.join(formater.split("#nick")) + formater = fav.join(formater.split("#fav")) + 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'))) + formater = delimiter.join(formater.split(word)) + # Change id word + word = [w for w in formater.split() if '#id' in w][0] + delimiter = color_func(c['TWEET']['id'])(id.join(word.split('#id'))) + formater = delimiter.join(formater.split(word)) except: printNicely(red('Wrong format in config.')) return @@ -333,24 +342,34 @@ def print_message(m): sender_name = cycle_color(sender_name) sender_nick = color_func(c['MESSAGE']['sender'])(sender_screen_name) recipient_name = cycle_color(recipient_name) - recipient_nick = color_func(c['MESSAGE']['recipient'])(recipient_screen_name) + recipient_nick = color_func( + c['MESSAGE']['recipient'])(recipient_screen_name) to = color_func(c['MESSAGE']['to'])('>>>') - clock = color_func(c['MESSAGE']['clock'])('[' + clock + ']') - id = color_func(c['MESSAGE']['id'])('[message_id=' + str(rid) + ']') + clock = clock + id = str(rid) text = ''.join(lmap(lambda x: x + ' ' if x == '\n' else x, text)) # Load config formater try: formater = c['FORMAT']['MESSAGE']['DISPLAY'] - formater = sender_name.join(formater.split("#sender_name")) - formater = sender_nick.join(formater.split("#sender_nick")) - formater = to.join(formater.split("#to")) - formater = recipient_name.join(formater.split("#recipient_name")) - formater = recipient_nick.join(formater.split("#recipient_nick")) - formater = clock.join(formater.split("#clock")) - formater = id.join(formater.split("#id")) - formater = text.join(formater.split("#message")) + formater = sender_name.join(formater.split("#sender_name")) + formater = sender_nick.join(formater.split("#sender_nick")) + formater = to.join(formater.split("#to")) + formater = recipient_name.join(formater.split("#recipient_name")) + formater = recipient_nick.join(formater.split("#recipient_nick")) + 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'))) + formater = delimiter.join(formater.split(word)) + # Change id word + word = [w for w in formater.split() if '#id' in w][0] + delimiter = color_func(c['MESSAGE']['id'])(id.join(word.split('#id'))) + formater = delimiter.join(formater.split(word)) except: printNicely(red('Wrong format in config.')) return diff --git a/setup.py b/setup.py index 994505c..8367f99 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages import os, os.path, sys # Bumped version -version = '0.5.0' +version = '0.5.1' # Require install_requires = [ -- 2.25.1