X-Git-Url: https://vcs.fsf.org/?p=rainbowstream.git;a=blobdiff_plain;f=rainbowstream%2Frainbow.py;h=eca57943cb0489f4963f40c5987325f80b502349;hp=7671143b5812d068ee94de0e347fe84d67a14a69;hb=6df5cc3a8750e5b3f888b50e5cd7bf76d72589de;hpb=66fe9f758d24e00cc7f4264a420e2a1507aac0af diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 7671143..eca5794 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -183,6 +183,13 @@ def init(args): # Image on term c['IMAGE_ON_TERM'] = args.image_on_term set_config('IMAGE_ON_TERM', str(c['IMAGE_ON_TERM'])) + # Check type of ONLY_LIST and IGNORE_LIST + if not isinstance(c['ONLY_LIST'], list): + printNicely(red('ONLY_LIST is not a valid list value.')) + c['ONLY_LIST'] = [] + if not isinstance(c['IGNORE_LIST'], list): + printNicely(red('IGNORE_LIST is not a valid list value.')) + c['IGNORE_LIST'] = [] # Mute dict c['IGNORE_LIST'] += build_mute_dict() @@ -903,7 +910,7 @@ def list_home(t): owner_screen_name=owner, count=c['LIST_MAX'], include_entities=False) - for tweet in res: + for tweet in reversed(res): draw(t=tweet) printNicely('') @@ -1177,9 +1184,6 @@ def switch(): ignore = raw_input('Ignore nicks [Ex: @xxx,@yy]: ') args.filter = filter(None, only.split(',')) args.ignore = filter(None, ignore.split(',')) - elif g['stuff'].split()[-1] == '-d': - args.filter = c['ONLY_LIST'] - args.ignore = c['IGNORE_LIST'] except: printNicely(red('Sorry, wrong format.')) return @@ -1216,7 +1220,7 @@ def switch(): elif target == 'list': owner, slug = get_slug() # Force python 2 not redraw readline buffer - g['cmd'] = '/'.join([owner, slug]) + g['PREFIX'] = g['cmd'] = '/'.join([owner, slug]) printNicely(light_yellow('getting list members ...')) # Get members t = Twitter(auth=authen()) @@ -1251,7 +1255,7 @@ def switch(): if args.ignore: printNicely(red('Ignore: ' + str(len(args.ignore)) + ' people.')) printNicely('') - except Exception: + except: debug_option() printNicely(red('Sorry I can\'t understand.')) @@ -1326,16 +1330,18 @@ def config(): value = get_default_config(key) line = ' ' * 2 + green(key) + ': ' + light_magenta(value) printNicely(line) - except Exception as e: - printNicely(red(e)) + except: + debug_option() + printNicely(red('Just can not get the default.')) # Delete specific config key in config file elif len(g['stuff'].split()) == 2 and g['stuff'].split()[-1] == 'drop': key = g['stuff'].split()[0] try: delete_config(key) printNicely(green('Config key is dropped.')) - except Exception as e: - printNicely(red(e)) + except: + debug_option() + printNicely(red('Just can not drop the key.')) # Set specific config elif len(g['stuff'].split()) == 3 and g['stuff'].split()[1] == '=': key = g['stuff'].split()[0] @@ -1345,15 +1351,18 @@ def config(): return try: set_config(key, value) - # Apply theme immediately + # Keys that needs to be apply immediately if key == 'THEME': c['THEME'] = reload_theme(value, c['THEME']) g['decorated_name'] = lambda x: color_func( c['DECORATED_NAME'])('[' + x + ']: ') + elif key == 'PREFIX': + g['PREFIX'] = u2str(emojize(c['PREFIX'])) reload_config() printNicely(green('Updated successfully.')) - except Exception as e: - printNicely(red(e)) + except: + debug_option() + printNicely(red('Just can not set the key.')) else: printNicely(light_magenta('Sorry I can\'s understand.')) @@ -1536,8 +1545,6 @@ def help_stream(): ' filter will decide nicks will be INCLUDE ONLY.\n' usage += s * 3 + light_yellow('Ignore nicks') + \ ' filter will decide nicks will be EXCLUDE.\n' - usage += s * 2 + light_green('switch mine -d') + \ - ' will use the config\'s ONLY_LIST and IGNORE_LIST.\n' usage += s * 2 + light_green('switch list') + \ ' will switch to a Twitter list\'s stream. You will be asked for list name\n' printNicely(usage)