当前位置: 首页>>代码示例>>Python>>正文


Python Twython.show_lists方法代码示例

本文整理汇总了Python中twython.Twython.show_lists方法的典型用法代码示例。如果您正苦于以下问题:Python Twython.show_lists方法的具体用法?Python Twython.show_lists怎么用?Python Twython.show_lists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twython.Twython的用法示例。


在下文中一共展示了Twython.show_lists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import show_lists [as 别名]
def main():

    if 3 != len(sys.argv):
        sys.stderr.write("""usage: %s <LIST> <FILE>

LIST : The name of the list you want to import members into.
FILE : A file with newline separated screen names.
""" % os.path.basename(sys.argv[0]))
        exit(1)

    with open('config.json', 'rb') as handle:
        config = json.loads(handle.read())

    list_name = sys.argv[1]
    csv = sys.argv[2]
    users = get_users(csv)
    api = None
    me = None

    print "==> Loading %d users into \"%s\"" % (len(users), list_name)

    if 'access' not in config or 'key' not in config['access'] or 'secret' not in config['access']:
        config = authorize(config)

    while True:
        try:
            api = Twython(config['consumer']['key'], config['consumer']['secret'],
                          config['access']['key'], config['access']['secret'])
            me = api.verify_credentials()
            break
        except:
            print "==> Existing tokens failed, re-authorizing"
            config = authorize(config)

    the_list = None
    for obj in api.show_lists(user_id=me["id_str"]):
        if obj["name"] == list_name:
            the_list = obj
            break

    if not the_list:
        print "==> List doesn't exist, creating it"
        the_list = api.create_list(name=list_name)

    offset = 0
    while offset < len(users):
        print "==> Sending #%d through #%d" % (offset, offset+100)
        api.create_list_members(list_id=the_list["id_str"], screen_name=users[offset:offset+100])
        offset += 100

    print "==> Done!"
开发者ID:jmhobbs,项目名称:Twitty-Lister,代码行数:53,代码来源:twitty-lister.py

示例2: TwythonAPITestCase

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import show_lists [as 别名]

#.........这里部分代码省略.........
        '''Test removing profile banner succeeds'''
        self.api.remove_profile_banner()

    def test_get_profile_banner_sizes(self):
        '''Test getting list of profile banner sizes fails because
        we have not uploaded a profile banner'''
        self.assertRaises(TwythonError, self.api.get_profile_banner_sizes)

    # Suggested Users
    def test_get_user_suggestions_by_slug(self):
        '''Test getting user suggestions by slug succeeds'''
        self.api.get_user_suggestions_by_slug(slug='twitter')

    def test_get_user_suggestions(self):
        '''Test getting user suggestions succeeds'''
        self.api.get_user_suggestions()

    def test_get_user_suggestions_statuses_by_slug(self):
        '''Test getting status of suggested users succeeds'''
        self.api.get_user_suggestions_statuses_by_slug(slug='funny')

    # Favorites
    def test_get_favorites(self):
        '''Test getting list of favorites for the authenticated
        user succeeds'''
        self.api.get_favorites()

    def test_create_and_destroy_favorite(self):
        '''Test creating and destroying a favorite on a tweet succeeds'''
        self.api.create_favorite(id=test_tweet_id)
        self.api.destroy_favorite(id=test_tweet_id)

    # Lists
    def test_show_lists(self):
        '''Test show lists for specified user'''
        self.api.show_lists(screen_name='twitter')

    def test_get_list_statuses(self):
        '''Test timeline of tweets authored by members of the
        specified list succeeds'''
        self.api.get_list_statuses(list_id=test_list_id)

    def test_create_update_destroy_list_add_remove_list_members(self):
        '''Test create a list, adding and removing members then
        deleting the list succeeds'''
        the_list = self.api.create_list(name='Stuff')
        list_id = the_list['id_str']

        self.api.update_list(list_id=list_id, name='Stuff Renamed')

        # Multi add/delete members
        self.api.create_list_members(list_id=list_id,
                                     screen_name='johncena,xbox')
        self.api.delete_list_members(list_id=list_id,
                                     screen_name='johncena,xbox')

        # Single add/delete member
        self.api.add_list_member(list_id=list_id, screen_name='justinbieber')
        self.api.delete_list_member(list_id=list_id, screen_name='justinbieber')

        self.api.delete_list(list_id=list_id)

    def test_get_list_memberships(self):
        '''Test list of lists the authenticated user is a member of succeeds'''
        self.api.get_list_memberships()
开发者ID:chrisbol,项目名称:twython,代码行数:69,代码来源:test_twython.py

示例3: TwythonAPITestCase

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import show_lists [as 别名]

#.........这里部分代码省略.........
        """Test removing profile banner succeeds"""
        self.api.remove_profile_banner()

    def test_get_profile_banner_sizes(self):
        """Test getting list of profile banner sizes fails because
        we have not uploaded a profile banner"""
        self.assertRaises(TwythonError, self.api.get_profile_banner_sizes)

    # Suggested Users
    def test_get_user_suggestions_by_slug(self):
        """Test getting user suggestions by slug succeeds"""
        self.api.get_user_suggestions_by_slug(slug='twitter')

    def test_get_user_suggestions(self):
        """Test getting user suggestions succeeds"""
        self.api.get_user_suggestions()

    def test_get_user_suggestions_statuses_by_slug(self):
        """Test getting status of suggested users succeeds"""
        self.api.get_user_suggestions_statuses_by_slug(slug='funny')

    # Favorites
    def test_get_favorites(self):
        """Test getting list of favorites for the authenticated
        user succeeds"""
        self.api.get_favorites()

    def test_create_and_destroy_favorite(self):
        """Test creating and destroying a favorite on a tweet succeeds"""
        self.api.create_favorite(id=test_tweet_id)
        self.api.destroy_favorite(id=test_tweet_id)

    # Lists
    def test_show_lists(self):
        """Test show lists for specified user"""
        self.api.show_lists(screen_name='twitter')

    def test_get_list_statuses(self):
        """Test timeline of tweets authored by members of the
        specified list succeeds"""
        self.api.get_list_statuses(list_id=test_list_id)

    def test_create_update_destroy_list_add_remove_list_members(self):
        """Test create a list, adding and removing members then
        deleting the list succeeds"""
        the_list = self.api.create_list(name='Stuff')
        list_id = the_list['id_str']

        self.api.update_list(list_id=list_id, name='Stuff Renamed')

        screen_names = ['johncena', 'xbox']
        # Multi add/delete members
        self.api.create_list_members(list_id=list_id,
                                     screen_name=screen_names)
        self.api.delete_list_members(list_id=list_id,
                                     screen_name=screen_names)

        # Single add/delete member
        self.api.add_list_member(list_id=list_id, screen_name='justinbieber')
        self.api.delete_list_member(list_id=list_id, screen_name='justinbieber')

        self.api.delete_list(list_id=list_id)

    def test_get_list_subscribers(self):
        """Test list of subscribers of a specific list succeeds"""
        self.api.get_list_subscribers(list_id=test_list_id)
开发者ID:hungtrv,项目名称:twython,代码行数:70,代码来源:test_core.py

示例4: Twitter

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import show_lists [as 别名]

#.........这里部分代码省略.........
   call_threaded(self.load_saved_searches)
  if self.config['UI']['autoLoadLists']:
   call_threaded(self.load_lists)

 def login_failed (self):
  output.speak(_("Login failed!"), True)
  self.login_required()

 def is_login_required (self):
  return not self.config['oauth']['userData']
 
 def load_saved_searches(self):
  searches = self.api_call('get_saved_searches', report_success=False)
  if not searches:
   return
  s = ""
  if len(searches) > 1:
   s = 'es'
  logging.info("Loading %d saved search%s from twitter." % (len(searches), s))
  output.speak(_("Loading %d saved search%s from twitter.") % (len(searches), s))
  for i in searches:
   try:
    buf = self.register_buffer(_("Search for %s") % i['query'], buffers.Search, store=True, term=i['query'], saved_id=i['id'], announce=False, set_focus=False)
   except:
    logging.exception("%s: Building buffer for saved search %s failed." % (self.name, i))

 def retrieve_lists(self, user = None, include_subscribed = False):
  if user is None:
   user = self.username
   output.speak(_("Retrieving lists"), True)
  else:
   output.speak(_("Retrieving lists for %s") % user, True)
  lists = []
  value = self.TwitterApi.show_lists(screen_name=user)
  lists.extend(value)
  if include_subscribed:
   lists.extend(self.retrieve_subscribed_lists(user))
  return lists

 def retrieve_subscribed_lists(self, user = None):
  lists = []
  nextCursor = -1
  while nextCursor:
   value = self.TwitterApi.get_list_subscriptions(screen_name=user, cursor=nextCursor)
   nextCursor = value['next_cursor']
   lists.extend(value['lists'])
  return lists

 def load_lists (self):
  all_lists = self.retrieve_lists()
  if not all_lists:
   return
  s = ""
  if len(all_lists) > 1:
   s = 's'
  logging.info("Retrieving %d list timeline%s from twitter." % (len(all_lists), s))
  output.speak(_("Retrieving %d list timeline%s from twitter.") % (len(all_lists), s))
  for i in all_lists:
   try:
    self.spawn_list_buffer(i, set_focus=False)
   except:
    logging.exception("Building buffer %s failed." % i)

 def spawn_list_buffer(self, owner = None, which = None, set_focus=True):
  self.register_buffer(_("List timeline for %s") % which['name'], buffers.ListTimeline, owner = owner, list=which, announce=True, set_focus=set_focus)
开发者ID:FBSLikan,项目名称:TheQube,代码行数:69,代码来源:twitter.py

示例5: TwythonEndpointsTestCase

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import show_lists [as 别名]

#.........这里部分代码省略.........
        self.api.destroy_mute(screen_name='justinbieber')

    # Suggested Users
    @unittest.skip('skipping non-updated test')
    def test_get_user_suggestions_by_slug(self):
        """Test getting user suggestions by slug succeeds"""
        self.api.get_user_suggestions_by_slug(slug='twitter')

    @unittest.skip('skipping non-updated test')
    def test_get_user_suggestions(self):
        """Test getting user suggestions succeeds"""
        self.api.get_user_suggestions()

    @unittest.skip('skipping non-updated test')
    def test_get_user_suggestions_statuses_by_slug(self):
        """Test getting status of suggested users succeeds"""
        self.api.get_user_suggestions_statuses_by_slug(slug='funny')

    # Favorites
    @unittest.skip('skipping non-updated test')
    def test_get_favorites(self):
        """Test getting list of favorites for the authenticated
        user succeeds"""
        self.api.get_favorites()

    @unittest.skip('skipping non-updated test')
    def test_create_and_destroy_favorite(self):
        """Test creating and destroying a favorite on a tweet succeeds"""
        self.api.create_favorite(id=test_tweet_id)
        self.api.destroy_favorite(id=test_tweet_id)

    # Lists
    @unittest.skip('skipping non-updated test')
    def test_show_lists(self):
        """Test show lists for specified user"""
        self.api.show_lists(screen_name='twitter')

    @unittest.skip('skipping non-updated test')
    def test_get_list_statuses(self):
        """Test timeline of tweets authored by members of the
        specified list succeeds"""
        self.api.get_list_statuses(slug=test_list_slug,
                                   owner_screen_name=test_list_owner_screen_name)

    @unittest.skip('skipping non-updated test')
    def test_create_update_destroy_list_add_remove_list_members(self):
        """Test create a list, adding and removing members then
        deleting the list succeeds"""
        the_list = self.api.create_list(name='Stuff %s' % int(time.time()))
        list_id = the_list['id_str']

        self.api.update_list(list_id=list_id, name='Stuff Renamed \
                             %s' % int(time.time()))

        screen_names = ['johncena', 'xbox']
        # Multi add/delete members
        self.api.create_list_members(list_id=list_id,
                                     screen_name=screen_names)
        self.api.delete_list_members(list_id=list_id,
                                     screen_name=screen_names)

        # Single add/delete member
        self.api.add_list_member(list_id=list_id, screen_name='justinbieber')
        self.api.delete_list_member(list_id=list_id,
                                    screen_name='justinbieber')
开发者ID:nouvak,项目名称:twython,代码行数:69,代码来源:test_endpoints.py


注:本文中的twython.Twython.show_lists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。