本文整理汇总了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)
示例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']
))
示例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)
示例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)
示例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)
示例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
示例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)
示例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)
示例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']
示例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
示例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)
示例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
示例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()
示例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)
示例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)))