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


Python api.API类代码示例

本文整理汇总了Python中api.API的典型用法代码示例。如果您正苦于以下问题:Python API类的具体用法?Python API怎么用?Python API使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

 def __init__(self, id=None):
     DB_CON.register([TopicDoc])
     datastroe = DB_CON[DB_NAME]
     col_name = TopicDoc.__collection__
     collection = datastroe[col_name]
     doc = collection.TopicDoc()
     API.__init__(self, id=id, col_name=col_name, collection=collection, doc=doc)
开发者ID:yimiqisan,项目名称:xiha,代码行数:7,代码来源:component.py

示例2: show_categories

def show_categories(section_id):
    """
    Categories page
    :param section_id: Selected section ID
    :return:
    """
    api = API()

    for item in api.get_categories(int(section_id)):
        # list item:
        li = ListItem(item['name'].capitalize(),
                      iconImage='{0}/{1}'.format(config['urls']['calm_arts_host'], item['image']),
                      thumbnailImage='{0}/{1}'.format(config['urls']['calm_arts_host'], item['image']))
        li.setArt({
            'fanart': '{0}{1}'.format(config['urls']['calm_blurred_arts_host'], item['image'])
        })
        # directory item:
        addDirectoryItem(
                PLUGIN.handle,
                PLUGIN.url_for(show_channels, section_id=section_id, category_id=item['id']),
                li,
                True
        )
    # end of directory:
    endOfDirectory(PLUGIN.handle)
    executebuiltin('Container.SetViewMode({0})'.format(
            config['viewmodes']['thumbnail'][getSkinDir()
            if getSkinDir() in config['viewmodes']['thumbnail'] else 'skin.confluence']
    ))
开发者ID:gedisony,项目名称:repo-plugins,代码行数:29,代码来源:addon.py

示例3: __init__

 def __init__(self, db_name=DB_NAME):
     DB_CON.register([EventDoc])
     datastore = DB_CON[db_name]
     col_name = EventDoc.__collection__
     collection = datastore[col_name]
     doc = collection.EventDoc()
     API.__init__(self, db_name=db_name, col_name=col_name, collection=collection, doc=doc)
开发者ID:yimiqisan,项目名称:huwai2,代码行数:7,代码来源:event.py

示例4: __init__

 def __init__(self):
     DB_CON.register([UserDoc])
     datastore = DB_CON[DB_NAME]
     col_name = UserDoc.__collection__
     collection = datastore[col_name]
     doc = collection.UserDoc()
     API.__init__(self, col_name=col_name, collection=collection, doc=doc)
开发者ID:yimiqisan,项目名称:huwai,代码行数:7,代码来源:user.py

示例5: __init__

 def __init__(self):
     DB_CON.register([TimeLineDoc])
     datastore = DB_CON[DB_NAME]
     col_name = TimeLineDoc.__collection__
     collection = datastore[col_name]
     doc = collection.TimeLineDoc()
     self.staff = StaffAPI()
     API.__init__(self, col_name=col_name, collection=collection, doc=doc)
开发者ID:yimiqisan,项目名称:vision,代码行数:8,代码来源:reply.py

示例6: handle_delete

    def handle_delete(self):
        if self.resource_id is None:
            return

        api = API(self._url(), self._auth(), self.properties["verify"])

        api.application_delete(self.resource_id)
        return self.resource_id
开发者ID:RedHatEMEA,项目名称:openshift-heat,代码行数:8,代码来源:openshift.py

示例7: __init__

 def __init__(self):
     DB_CON.register([StaffDoc])
     datastore = DB_CON[DB_NAME]
     col_name = StaffDoc.__collection__
     collection = datastore[col_name]
     doc = collection.StaffDoc()
     self.p = Permission()
     API.__init__(self, col_name=col_name, collection=collection, doc=doc)
开发者ID:yimiqisan,项目名称:vision,代码行数:8,代码来源:staff.py

示例8: __init__

 def __init__(self):
     DB_CON.register([CollectDoc])
     datastore = DB_CON[DB_NAME]
     col_name = CollectDoc.__collection__
     collection = datastore[col_name]
     doc = collection.CollectDoc()
     self.vol = Volume()
     API.__init__(self, col_name=col_name, collection=collection, doc=doc)
开发者ID:yimiqisan,项目名称:vision,代码行数:8,代码来源:collect.py

示例9: get_audio_list

def get_audio_list(owner_id, count=6000):
    api = API()
    params = {
        'method': 'audio.get',
        'owner_id': owner_id,
        'count': count,
        }
    return api.call_api(**params)['response']
开发者ID:EugeneRymarev,项目名称:VKWorker,代码行数:8,代码来源:audio.py

示例10: get_username

 def get_username(self):
     if self.username is None:
         api = API(self)
         user = api.verify_credentials()
         if user:
             self.username = user.screen_name
         else:
             raise WeibopError("Unable to get username, invalid oauth token!")
     return self.username
开发者ID:FashtimeDotCom,项目名称:sinaapp,代码行数:9,代码来源:auth.py

示例11: __init__

 def __init__(self):
     DB_CON.register([ItemDoc])
     datastore = DB_CON[DB_NAME]
     col_name = ItemDoc.__collection__
     collection = datastore[col_name]
     doc = collection.ItemDoc()
     self.rpl = Reply()
     self.stf = Staff()
     self.alt = Alert()
     API.__init__(self, col_name=col_name, collection=collection, doc=doc)
开发者ID:yimiqisan,项目名称:vision,代码行数:10,代码来源:item.py

示例12: update_userpage

def update_userpage(username, cache_minutes=20):
    try:
        cachetime = UserInfo.objects.get(pk=username).cache
    except UserInfo.DoesNotExist:
        # Force updating cache
        cachetime = timezone.now() - datetime.timedelta(days=1)
    if cachetime + datetime.timedelta(minutes=cache_minutes) < timezone.now():
        API.userpage(username=username)
        return None
    else:
        return cachetime
开发者ID:duvholt,项目名称:Hacker-News-Reader,代码行数:11,代码来源:cache.py

示例13: main

def main():
	global api
	
	root_app = bottle.Bottle()
	result = config.validate(validator, copy = True)

	if result is False:
		print "Config file validation failed"
		sys.exit(1)

	api = API(app, config, VERSION)
	ConfigAPI(api, config)
	tellstick = TellstickAPI(api, config, VERSION)
	
	scheduler = Scheduler(config, tellstick)
	SchedulerAPI(api, config)
	
	class ConfigWatcher(object):
		def notify(self, observable, key):
			print "writing"
			config.write()

	watcher = ConfigWatcher()
	config.observe(watcher)
	
	if config['installed'] != VERSION:
		api.install()
	
	if config['webroot']:
		root_app.mount(config['webroot'], app)
	else:
		root_app.merge(app)

	session_opts = {
		'session.type': 'cookie',
		'session.validate_key': config['cookieKey'],
		'session.auto': True,
	}

	bottle.run(SessionMiddleware(root_app, session_opts),
		host = config['host'],
		port = config['port'],
		debug = config['debug'],
		reloader = False,
		server = 'cherrypy')

	if scheduler:
		scheduler.stop()
	
	# The goal was to have all changes to the config call the watcher
	# method which writes to file. Unfortunately subsections wouldn't
	# play along, so write to file once we've finished with the service
	config.write()
开发者ID:elastikiets,项目名称:tellprox,代码行数:53,代码来源:__main__.py

示例14: main_game

def main_game(game_id):
    global API
    API.clear()
    last_command_id = 0
    end = False
    data_user = API.user()
    while not end:
        pipes = API.pipes(game_id, last_command_id)
        last_command_id = pipes["last_id"]
        for command in pipes["commands"]:
            if command["type"] == "1" and command["user_id"] == data_user["id"] or command["type"] == "0":
                exec(command["command"])
        if not pipes["commands"]:
            time.sleep(1)
开发者ID:plafrance,项目名称:TP4,代码行数:14,代码来源:start.py

示例15: show_favorites

def show_favorites():
    """
    User's favorite channels list
    :return:
    """
    api = API()
    user = User()
    is_authenticated = user.authenticate()

    if is_authenticated:
        favorites = api.get_favorites(user.username, user.token)
        if len(favorites) > 0:
            for item in favorites:
                # list item:
                li = ListItem(u'{0} {1}'.format(item['title'].replace('CALM RADIO -', '').title(),
                                                '(VIP)' if 'free' not in item['streams'] else '',
                                                item['description']),
                              iconImage='{0}/{1}'.format(config['urls']['calm_arts_host'], item['image']),
                              thumbnailImage='{0}/{1}'.format(config['urls']['calm_arts_host'], item['image']))
                li.setArt({
                    'fanart': '{0}{1}'.format(config['urls']['calm_blurred_arts_host'], item['image'])
                })
                li.addContextMenuItems(
                        [(ADDON.getLocalizedString(32301), 'RunPlugin(plugin://{0}/favorites/remove/{1})'
                          .format(ADDON_ID, item['id']))]
                )
                # directory item:
                addDirectoryItem(
                        PLUGIN.handle,
                        PLUGIN.url_for(play_channel,
                                       category_id=item['category'],
                                       channel_id=item['id']),
                        li
                )
            # set the content of the directory
            setContent(ADDON_HANDLE, 'songs')
            # end of directory:
            endOfDirectory(PLUGIN.handle)
            executebuiltin('Container.SetViewMode({0})'.format(
                    config['viewmodes']['thumbnail'][getSkinDir()
                    if getSkinDir() in config['viewmodes']['thumbnail'] else 'skin.confluence']
            ))
        # favorites list is empty:
        else:
            executebuiltin('Notification("{0}", "{1}")'
                           .format(ADDON.getLocalizedString(30000), ADDON.getLocalizedString(32306)))
    # user is not authenticated:
    else:
        executebuiltin('Notification("{0}", "{1}")'
                       .format(ADDON.getLocalizedString(30000), ADDON.getLocalizedString(32110)))
开发者ID:gedisony,项目名称:repo-plugins,代码行数:50,代码来源:addon.py


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