[] and id=
authorOrakaro <nhatminh_179@hotmail.com>
Sun, 27 Jul 2014 05:18:43 +0000 (14:18 +0900)
committerOrakaro <nhatminh_179@hotmail.com>
Sun, 27 Jul 2014 05:18:43 +0000 (14:18 +0900)
rainbowstream/colorset/config
rainbowstream/draw.py
setup.py

index c047f9436cf020307c94354b81218430ec6f6245..d2388d8b6401751a4e789eceb528bca0872c98d6 100644 (file)
     "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"
         }
     }
 }
index 6352d3a0f7209bd60debb5fca91e1063c8d59772..0140137639a703df502d5e8b3178857857ae5a48 100644 (file)
@@ -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
index 994505cf9f5db6f0c055565c4530163b9e9bdb6a..8367f994b1f98928ceea5a1fa22ef269bda39ffe 100644 (file)
--- 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 = [