arrow
authorvunhat_minh <vunhat_minh@dwango.co.jp>
Tue, 19 Aug 2014 04:41:13 +0000 (13:41 +0900)
committervunhat_minh <vunhat_minh@dwango.co.jp>
Tue, 19 Aug 2014 04:41:13 +0000 (13:41 +0900)
docs/conf.py
rainbowstream/colorset/config
rainbowstream/draw.py
rainbowstream/rainbow.py
setup.py

index 0b9888b..91b9a2a 100644 (file)
@@ -48,9 +48,9 @@ copyright = u'2014, Vu Nhat Minh'
 # built documents.
 #
 # The short X.Y version.
-version = '0.7.8'
+version = '0.8.0'
 # The full version, including alpha/beta/rc tags.
-release = '0.7.8'
+release = '0.8.0'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
index 9859d90..6845ed1 100644 (file)
     "FORMAT": {
         "TWEET": {
             "CLOCK_FORMAT" : "%Y/%m/%d %H:%M:%S",
-            "DISPLAY" : "\n  #name #nick :\n  [#clock] [rt:#rt_count] [fav:#fa_count] [id=#id] #fav\n  #tweet"
+            "DISPLAY" : "\n  #name #nick #clock \n  Retweets:#rt_count Favorites:#fa_count 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] [message_id=#id]\n  #message"
+            "DISPLAY" : "\n  #sender_name #sender_nick #to #recipient_name #recipient_nick :\n  #clock message_id:#id\n  #message"
         }
     }
 }
index 262fe4f..11fa000 100644 (file)
@@ -3,13 +3,14 @@ import itertools
 import requests
 import datetime
 import time
+import locale
+import arrow
 import re
 
 from twitter.util import printNicely
 from functools import wraps
 from pyfiglet import figlet_format
 from dateutil import parser
-from tzlocal import get_localzone
 from .c_image import *
 from .colors import *
 from .config import *
@@ -144,7 +145,7 @@ def color_func(func_name):
     return globals()[func_name]
 
 
-def draw(t, keyword=None, check_semaphore=False, fil=[], ig=[]):
+def draw(t, keyword=None, humanize=True, check_semaphore=False, fil=[], ig=[]):
     """
     Draw the rainbow
     """
@@ -169,13 +170,16 @@ def draw(t, keyword=None, check_semaphore=False, fil=[], ig=[]):
     retweet_count = t['retweet_count']
     favorite_count = t['favorite_count']
     date = parser.parse(created_at)
-    date = date.astimezone(get_localzone())
-    clock_format = '%Y/%m/%d %H:%M:%S'
-    try:
-        clock_format = c['FORMAT']['TWEET']['CLOCK_FORMAT']
-    except:
-        pass
-    clock = date.strftime(clock_format)
+    date = arrow.get(date).to('local')
+    if humanize:
+        lang, encode = locale.getdefaultlocale()
+        clock = arrow.get(date).to('local').humanize(locale=lang)
+    else:
+        try:
+            clock_format = c['FORMAT']['TWEET']['CLOCK_FORMAT']
+        except:
+            clock_format = '%Y/%m/%d %H:%M:%S'
+        clock = date.datetime.strftime(clock_format)
 
     # Pull extended retweet text
     try:
@@ -335,7 +339,7 @@ def print_message(m, check_semaphore=False):
     recipient_name = m['recipient']['name']
     mid = m['id']
     date = parser.parse(m['created_at'])
-    date = date.astimezone(get_localzone())
+    date = arrow.get(date).to('local').datetime
     clock_format = '%Y/%m/%d %H:%M:%S'
     try:
         clock_format = c['FORMAT']['MESSAGE']['CLOCK_FORMAT']
@@ -428,8 +432,8 @@ def show_profile(u):
     location = 'Location : ' + color_func(c['PROFILE']['location'])(location)
     url = 'URL : ' + (color_func(c['PROFILE']['url'])(url) if url else '')
     date = parser.parse(created_at)
-    date = date.astimezone(get_localzone())
-    clock = date.strftime('%Y/%m/%d %H:%M:%S')
+    lang, encode = locale.getdefaultlocale()
+    clock = arrow.get(date).to('local').humanize(locale=lang)
     clock = 'Join at ' + color_func(c['PROFILE']['clock'])(clock)
 
     # Format
@@ -507,8 +511,8 @@ def print_list(group):
         mode = color_func(c['GROUP']['mode'])('Type: ' + mode)
         created_at = grp['created_at']
         date = parser.parse(created_at)
-        date = date.astimezone(get_localzone())
-        clock = date.strftime('%Y/%m/%d %H:%M:%S')
+        lang, encode = locale.getdefaultlocale()
+        clock = arrow.get(date).to('local').humanize(locale=lang)
         clock = 'Created at ' + color_func(c['GROUP']['clock'])(clock)
 
         # Create lines
index 7add557..df32fb7 100644 (file)
@@ -1014,7 +1014,7 @@ def list_delete(t):
     """
     Delete a list
     """
-    slug = raw_input(light_magenta('Your list that you want to update: '))
+    slug = raw_input(light_magenta('Your list that you want to delete: '))
     try:
         t.lists.destroy(
             slug='-'.join(slug.split()),
@@ -1732,6 +1732,7 @@ def stream(domain, args, name='Rainbow Stream'):
                 draw(
                     t=tweet,
                     keyword=args.track_keywords,
+                    humanize=False,
                     check_semaphore=True,
                     fil=args.filter,
                     ig=args.ignore,
index eae5ce8..77c7de5 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -3,16 +3,16 @@ import os
 import os.path
 
 # Bumped version
-version = '0.7.8'
+version = '0.8.0'
 
 # Require
 install_requires = [
     "python-dateutil",
+    "arrow",
     "requests",
     "pyfiglet",
     "twitter",
     "Pillow",
-    "tzlocal",
 ]
 
 # Copy default config if not exists