printNicely(red('Sorry I can\'t understand.'))
+def get_slug():
+ """
+ Get Slug Decorator
+ """
+ # Get list name
+ list_name = raw_input(light_magenta('Give me the list\'s name: '))
+ # Get list name and owner
+ try:
+ owner, slug = list_name.split('/')
+ if slug.startswith('@'):
+ slug = slug[1:]
+ return owner, slug
+ except:
+ printNicely(light_magenta('List name should follow "@owner/list_name" format.'))
+ raise Exception('Wrong list name')
+
+
def show_lists(t):
"""
List list
"""
List home
"""
- # Get list name
- list_name = raw_input(light_magenta('Give me the list\'s name: '))
- # Get list name and owner
- try:
- owner, slug = list_name.split('/')
- if slug.startswith('@'):
- slug = slug[1:]
- except:
- printNicely(light_magenta('Please follow "@owner/list_name" format.'))
- return
+ owner, slug = get_slug()
res = t.lists.statuses(
slug=slug,
owner_screen_name=owner,
"""
List members
"""
- # Get list name
- list_name = raw_input(light_magenta('Give me the list\'s name: '))
- # Get list name and owner
- try:
- owner, slug = list_name.split('/')
- if slug.startswith('@'):
- slug = slug[1:]
- except:
- printNicely(light_magenta('Please follow "@owner/list_name" format.'))
- return
+ owner, slug = get_slug()
# Get members
rel = {}
next_cursor = -1
"""
List subscribers
"""
- # Get list name
- list_name = raw_input(light_magenta('Give me the list\'s name: '))
- # Get list name and owner
- try:
- owner, slug = list_name.split('/')
- if slug.startswith('@'):
- slug = slug[1:]
- except:
- printNicely(light_magenta('Please follow "@owner/list_name" format.'))
- return
+ owner, slug = get_slug()
# Get subscribers
rel = {}
next_cursor = -1
"""
Add specific user to a list
"""
- # Get list name
- list_name = raw_input(light_magenta('Give me the list\'s name: '))
- # Get list name and owner
- try:
- owner, slug = list_name.split('/')
- if slug.startswith('@'):
- slug = slug[1:]
- except:
- printNicely(light_magenta('Please follow "@owner/list_name" format.'))
- return
+ owner, slug = get_slug()
# Add
user_name = raw_input(light_magenta('Give me name of the newbie: '))
if user_name.startswith('@'):
"""
Remove specific user from a list
"""
- # Get list name
- list_name = raw_input(light_magenta('Give me the list\'s name: '))
- # Get list name and owner
- try:
- owner, slug = list_name.split('/')
- if slug.startswith('@'):
- slug = slug[1:]
- except:
- printNicely(light_magenta('Please follow "@owner/list_name" format.'))
- return
+ owner, slug = get_slug()
# Remove
user_name = raw_input(light_magenta('Give me name of the unlucky one: '))
if user_name.startswith('@'):
"""
Subscribe to a list
"""
- # Get list name
- list_name = raw_input(light_magenta('Give me the list\'s name: '))
- # Get list name and owner
- try:
- owner, slug = list_name.split('/')
- if slug.startswith('@'):
- slug = slug[1:]
- except:
- printNicely(light_magenta('Please follow "@owner/list_name" format.'))
- return
+ owner, slug = get_slug()
# Subscribe
try:
t.lists.subscribers.create(
"""
Unsubscribe a list
"""
- # Get list name
- list_name = raw_input(light_magenta('Give me the list\'s name: '))
- # Get list name and owner
- try:
- owner, slug = list_name.split('/')
- if slug.startswith('@'):
- slug = slug[1:]
- except:
- printNicely(light_magenta('Please follow "@owner/list_name" format.'))
- return
+ owner, slug = get_slug()
# Subscribe
try:
t.lists.subscribers.destroy(
try:
return action_ary[g['list_action']](t)
except:
- printNicely(red('Sorry I can\'t understand.'))
+ printNicely(red('Please try again.'))
def cal():