當前位置: 首頁>>代碼示例>>Python>>正文


Python Library.query方法代碼示例

本文整理匯總了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))
開發者ID:andymutton,項目名稱:v2,代碼行數:30,代碼來源:manage.py

示例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)
開發者ID:customelements,項目名稱:v2,代碼行數:17,代碼來源:manage.py


注:本文中的datamodel.Library.query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。