autopep8 and bumped version
authorOrakaro <nhatminh_179@hotmail.com>
Sun, 20 Jul 2014 10:16:42 +0000 (19:16 +0900)
committerOrakaro <nhatminh_179@hotmail.com>
Sun, 20 Jul 2014 10:16:42 +0000 (19:16 +0900)
rainbowstream/config.py
rainbowstream/draw.py
rainbowstream/py3patch.py
rainbowstream/rainbow.py
setup.py

index 2e79c9aea768e210c76c3fedcae1b7b5246b3ae1..70325044e9ff3af1fd42bce06e968a20ad660562 100644 (file)
@@ -10,6 +10,7 @@ comment_re = re.compile(
     re.DOTALL | re.MULTILINE
 )
 
+
 def fixup(adict, k, v):
     """
     Fix up a key in json format
@@ -17,7 +18,7 @@ def fixup(adict, k, v):
     for key in adict.keys():
         if key == k:
             adict[key] = v
-        elif type(adict[key]) is dict:
+        elif isinstance(adict[key], dict):
             fixup(adict[key], k, v)
 
 
@@ -45,8 +46,8 @@ def get_all_config():
             '')) + os.sep + '.rainbow_config.json'
     data = load_config(path)
     # Hard to set from prompt
-    data.pop('ONLY_LIST',None)
-    data.pop('IGNORE_LIST',None)
+    data.pop('ONLY_LIST', None)
+    data.pop('IGNORE_LIST', None)
     return data
 
 
@@ -67,7 +68,7 @@ def get_config(key):
     return c[key]
 
 
-def set_config(key,value):
+def set_config(key, value):
     """
     Set a config key with specific value
     """
@@ -88,7 +89,7 @@ def set_config(key,value):
     fixup(data, key, value)
     # Save
     with open(path, 'w') as out:
-        json.dump(data, out, indent = 4)
+        json.dump(data, out, indent=4)
     os.system('chmod 777 ' + path)
 
 
index 4360d469c6b859e948f930f817cffa86787e4dca..24416623de480802460c92dfd56d31944c96625e 100644 (file)
@@ -232,7 +232,7 @@ def draw(t, iot=False, keyword=None, check_semaphore=False, fil=[], ig=[]):
     # Highlight keyword
     tweet = ' '.join(tweet)
     if keyword:
-        roj = re.search(keyword,tweet,re.IGNORECASE)
+        roj = re.search(keyword, tweet, re.IGNORECASE)
         if roj:
             occur = roj.group()
             ary = tweet.split(occur)
index 83e5f0a1845bc4d781d2192a10f66ba71c77e208..6dc213fdf084d92ca029c14b0ac487f7ecfb9c7f 100644 (file)
@@ -10,12 +10,9 @@ except:
     from io import StringIO, BytesIO
 
 # HTMLParser module
-
 try:
     from HTMLParser import HTMLParser
-    def unescape(s):
-        p = HTMLParser()
-        return p.unescape(s)
+    unescape = HTMLParser().unescape
 except:
     from html import unescape
 
index c424e841e779c640b60a12c6364f80e62fa776ba..b33ffbbbb451cf29587abc7e7765f643fcd76c17 100644 (file)
@@ -805,7 +805,7 @@ def get_slug():
     """
     Get Slug Decorator
     """
-     # Get list name
+    # Get list name
     list_name = raw_input(light_magenta('Give me the list\'s name: '))
     # Get list name and owner
     try:
@@ -814,7 +814,8 @@ def get_slug():
             slug = slug[1:]
         return owner, slug
     except:
-        printNicely(light_magenta('List name should follow "@owner/list_name" format.'))
+        printNicely(
+            light_magenta('List name should follow "@owner/list_name" format.'))
         raise Exception('Wrong list name')
 
 
@@ -1089,16 +1090,19 @@ def config():
     # List all config
     if not g['stuff']:
         for k in all_config:
-            line = ' '*2 + light_green(k) + ': ' + light_yellow(str(all_config[k]))
+            line = ' ' * 2 + \
+                light_green(k) + ': ' + light_yellow(str(all_config[k]))
             printNicely(line)
         guide = 'Detailed explanation can be found at ' + \
-            color_func(c['TWEET']['link'])('http://rainbowstream.readthedocs.org/en/latest/#config-explanation')
+            color_func(c['TWEET']['link'])(
+                'http://rainbowstream.readthedocs.org/en/latest/#config-explanation')
         printNicely(guide)
     # Print specific config
     elif len(g['stuff'].split()) == 1:
         if g['stuff'] in all_config:
             k = g['stuff']
-            line = ' '*2 + light_green(k) + ': ' + light_yellow(str(all_config[k]))
+            line = ' ' * 2 + \
+                light_green(k) + ': ' + light_yellow(str(all_config[k]))
             printNicely(line)
         else:
             printNicely(red('No config key like this.'))
@@ -1106,14 +1110,14 @@ def config():
     elif len(g['stuff'].split()) == 2 and g['stuff'].split()[-1] == 'default':
         key = g['stuff'].split()[0]
         value = get_default_config(key)
-        line = ' '*2 + light_green(key) + ': ' + light_magenta(value)
+        line = ' ' * 2 + light_green(key) + ': ' + light_magenta(value)
         printNicely(line)
     # Set specific config
-    elif len(g['stuff'].split()) == 3 and g['stuff'].split()[1] == '=' :
+    elif len(g['stuff'].split()) == 3 and g['stuff'].split()[1] == '=':
         key = g['stuff'].split()[0]
         value = g['stuff'].split()[-1]
         try:
-            set_config(key,value)
+            set_config(key, value)
             printNicely(light_green('Updated successfully.'))
         except:
             printNicely(light_magenta('Not valid value.'))
@@ -1138,7 +1142,7 @@ def theme():
             printNicely(line)
     elif g['stuff'] == 'current_as_default':
         # Set as default
-        set_config('THEME',c['THEME'])
+        set_config('THEME', c['THEME'])
         printNicely(light_green('Okay it will be applied from next time :)'))
     else:
         # Change theme
@@ -1394,13 +1398,14 @@ def help():
     usage += s * 2 + light_green('config') + ' will list all config.\n'
     usage += s * 3 + \
         light_green('config ASCII_ART') + ' will output current value of ' +\
-        light_yellow('ASCII_ART') +' config key.\n'
+        light_yellow('ASCII_ART') + ' config key.\n'
     usage += s * 3 + \
         light_green('config ASCII_ART default') + ' will output default value of ' + \
-        light_yellow('ASCII_ART') +' config key.\n'
+        light_yellow('ASCII_ART') + ' config key.\n'
     usage += s * 3 + \
         light_green('config ASCII_ART = False') + ' will set value of ' + \
-        light_yellow('ASCII_ART') +' config key to ' + light_yellow('False') + '.\n'
+        light_yellow('ASCII_ART') + ' config key to ' + \
+        light_yellow('False') + '.\n'
 
     # Screening
     usage += '\n'
@@ -1558,7 +1563,7 @@ def listen():
                 'del'
             ],  # list
             [],  # cal
-            [key for key in dict(get_all_config())], # config
+            [key for key in dict(get_all_config())],  # config
             g['themes'] + ['current_as_default'],  # theme
             [
                 'discover',
index ab8a7111c3f60d4efd54ed7d887d0a5340f793da..2223acbf74072870390eb9933ede4ca5f9378353 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
 import os, sys
 
 # Bumped version
-version = '0.4.0'
+version = '0.4.1'
 
 # Require
 install_requires = [