+ list list
+ """
+ rel = t.lists.list(screen_name=g['original_name'])
+ if rel:
+ print_list(rel)
+ else:
+ printNicely(light_magenta('You belong to no lists :)'))
+
+
+def list_home(t):
+ """
+ List home
+ """
+ # Get list name
+ list_name = raw_input(light_magenta('Give me the list\'s name: '))
+ if not list_name:
+ printNicely(light_magenta('No list specified.'))
+ return
+ # Print timeline
+ l = db.list_name_to_id_query(list_name)[0]
+ res = t.lists.statuses(
+ list_id = l.list_id,
+ count = c['LIST_MAX'],
+ include_entities=False)
+ for tweet in res:
+ draw(t=tweet)
+ printNicely('')
+
+
+def list_members(t):
+ """
+ List members
+ """
+ # Get list name
+ list_name = raw_input(light_magenta('Give me the list\'s name: '))
+ if not list_name:
+ printNicely(light_magenta('No list specified.'))
+ return
+ # Members
+ l = db.list_name_to_id_query(list_name)[0]
+ rel = {}
+ next_cursor = -1
+ while next_cursor != 0 :
+ m = t.lists.members(
+ list_id = l.list_id,
+ cursor = next_cursor,
+ include_entities=False)
+ for u in m['users']:
+ rel[u['name']] = '@' + u['screen_name']
+ next_cursor = m['next_cursor']
+ printNicely('All: ' + str(len(rel)) + ' members.')
+ for name in rel:
+ user = ' ' + cycle_color(name)
+ user += color_func(c['TWEET']['nick'])(' ' + rel[name] + ' ')
+ printNicely(user)
+
+
+def list_subscribers(t):
+ """
+ List subscribers
+ """
+ # Get list name
+ list_name = raw_input(light_magenta('Give me the list\'s name: '))
+ if not list_name:
+ printNicely(light_magenta('No list specified.'))
+ return
+ # Subscribers
+ l = db.list_name_to_id_query(list_name)[0]
+ rel = {}
+ next_cursor = -1
+ while next_cursor != 0 :
+ m = t.lists.subscribers(
+ list_id = l.list_id,
+ cursor = next_cursor,
+ include_entities=False)
+ for u in m['users']:
+ rel[u['name']] = '@' + u['screen_name']
+ next_cursor = m['next_cursor']
+ printNicely('All: ' + str(len(rel)) + ' subscribers.')
+ for name in rel:
+ user = ' ' + cycle_color(name)
+ user += color_func(c['TWEET']['nick'])(' ' + rel[name] + ' ')
+ printNicely(user)
+
+
+def list_remove(t):
+ """
+ Remove specific user from a list
+ """
+ # Get list name
+ list_name = raw_input(light_magenta('Give me the list\'s name: '))
+ if not list_name:
+ printNicely(light_magenta('No list specified.'))
+ return
+ # Remove
+ l = db.list_name_to_id_query(list_name)[0]
+ user_name = raw_input(light_magenta('Give me the name of unlucky man: '))
+ try:
+ t.lists.members.destroy(
+ list_id = l.list_id,
+ screen_name = user_name)
+ printNicely(light_green('Okay he\'s gone :)'))
+ except:
+ printNicely(light_magenta('I\'m sorry we can not remove him.'))
+
+
+def list():
+ """
+ Twitter's list
+ """
+ t = Twitter(auth=authen())
+ # List all lists or base on action
+ try:
+ g['list_action'] = g['stuff'].split()[0]
+ except:
+ show_lists(t)
+ return
+
+ # Sub function
+ action_ary = {
+ 'home': list_home,
+ 'all_mem': list_members,
+ 'all_sub': list_subscribers,
+ 'rm': list_remove,
+ }
+ try:
+ return action_ary[g['list_action']](t)
+ except:
+ printNicely(red('Sorry I can\'t understand.'))
+
+
+def cal():
+ """
+ Unix's command `cal`
+ """
+ # Format
+ rel = os.popen('cal').read().split('\n')
+ month = rel.pop(0)
+ date = rel.pop(0)
+ show_calendar(month, date, rel)
+
+
+def theme():
+ """
+ List and change theme
+ """
+ if not g['stuff']:
+ # List themes
+ for theme in g['themes']:
+ line = ''
+ # Detect custom config
+ if theme == 'custom':
+ line += light_magenta('custom')
+ custom_path = os.environ.get(
+ 'HOME',
+ os.environ.get('USERPROFILE',
+ '')) + os.sep + '.rainbow_config.json'
+ if not os.path.exists(custom_path):
+ line += light_magenta(' (create your own config file at ~/.rainbow_config.json)')
+ else:
+ line += light_magenta(' (loaded)')
+ else:
+ line += light_magenta(theme)
+ if c['theme'] == theme :
+ line = ' '*2 + light_yellow('* ') + line
+ else:
+ line = ' '*4 + line
+ printNicely(line)
+ elif g['stuff'] == 'current_as_default':
+ # Set default
+ path = os.path.dirname(__file__) + '/colorset/init'
+ f = open(path,'w')
+ f.write(c['theme'])
+ f.close()
+ os.system('chmod 777 ' + path)
+ printNicely(light_green('Okay it will be applied from next time :)'))
+ else:
+ # Change theme
+ try:
+ # Load new config
+ if g['stuff'] != 'custom':
+ new_config = os.path.dirname(__file__) + '/colorset/' + g['stuff'] + '.json'
+ else:
+ new_config = os.environ.get(
+ 'HOME',os.environ.get(
+ 'USERPROFILE',
+ '')) + os.sep + '.rainbow_config.json'
+ new_config = load_config(new_config)
+ if new_config:
+ for nc in new_config:
+ c[nc] = new_config[nc]
+ # Update db and reset colors
+ db.theme_update(g['stuff'])
+ c['theme'] = g['stuff']
+ reset_cycle()
+ g['decorated_name'] = color_func(
+ c['DECORATED_NAME'])(
+ '[@' + g['original_name'] + ']: ')
+ printNicely(green('Theme changed.'))
+ except:
+ if g['stuff'] == 'custom':
+ printNicely(red('~/.rainbow_config.json is not exists!'))
+ else:
+ printNicely(red('No such theme exists.'))
+
+
+def help_discover():
+ """
+ Discover the world