本文整理匯總了Python中datamodel.Library.query方法的典型用法代碼示例。如果您正苦於以下問題:Python Library.query方法的具體用法?Python Library.query怎麽用?Python Library.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類datamodel.Library
的用法示例。
在下文中一共展示了Library.query方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle_get
# 需要導入模塊: from datamodel import Library [as 別名]
# 或者: from datamodel.Library import query [as 別名]
def handle_get(self):
keys = (Library.query()
.filter(Library.kind == 'element')
# pylint: disable=singleton-comparison
.filter(Library.shallow_ingestion == False)
.filter(Library.status == Status.ready)
.fetch(keys_only=True, read_policy=ndb.EVENTUAL_CONSISTENCY))
elements = Sitemap(id='elements')
elements.pages = [key.id() for key in keys]
elements.put()
logging.info('%d elements', len(elements.pages))
keys = (Library.query()
.filter(Library.kind == 'collection')
# pylint: disable=singleton-comparison
.filter(Library.shallow_ingestion == False)
.filter(Library.status == Status.ready)
.fetch(keys_only=True, read_policy=ndb.EVENTUAL_CONSISTENCY))
collections = Sitemap(id='collections')
collections.pages = [key.id() for key in keys]
collections.put()
logging.info('%d collections', len(collections.pages))
keys = Author.query().fetch(keys_only=True, read_policy=ndb.EVENTUAL_CONSISTENCY)
authors = Sitemap(id='authors')
authors.pages = [key.id() for key in keys]
authors.put()
logging.info('%d authors', len(authors.pages))
示例2: handle_get
# 需要導入模塊: from datamodel import Library [as 別名]
# 或者: from datamodel.Library import query [as 別名]
def handle_get(self):
latest = self.request.get('latest', None) is not None
query = Library.query()
cursor = None
more = True
task_count = 0
while more:
keys, cursor, more = query.fetch_page(50, keys_only=True, start_cursor=cursor)
for key in keys:
task_count = task_count + 1
owner, repo = key.id().split('/', 1)
task_url = util.analyze_library_task(owner, repo, latest)
util.new_task(task_url, target='manage')
logging.info('triggered %d analyses', task_count)