本文整理汇总了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)