From: Orakaro Date: Sun, 20 Jul 2014 10:16:42 +0000 (+0900) Subject: autopep8 and bumped version X-Git-Url: https://vcs.fsf.org/?p=rainbowstream.git;a=commitdiff_plain;h=a8c5fce4b567697790144ec15546ce68e5469963;hp=cd9ecfd554fafd9f1d485ce4dda8d716099725a0 autopep8 and bumped version --- diff --git a/rainbowstream/config.py b/rainbowstream/config.py index 2e79c9a..7032504 100644 --- a/rainbowstream/config.py +++ b/rainbowstream/config.py @@ -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) diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index 4360d46..2441662 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -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) diff --git a/rainbowstream/py3patch.py b/rainbowstream/py3patch.py index 83e5f0a..6dc213f 100644 --- a/rainbowstream/py3patch.py +++ b/rainbowstream/py3patch.py @@ -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 diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index c424e84..b33ffbb 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -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', diff --git a/setup.py b/setup.py index ab8a711..2223acb 100644 --- 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 = [