本文整理匯總了Python中datamodel.Library.get_or_insert方法的典型用法代碼示例。如果您正苦於以下問題:Python Library.get_or_insert方法的具體用法?Python Library.get_or_insert怎麽用?Python Library.get_or_insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類datamodel.Library
的用法示例。
在下文中一共展示了Library.get_or_insert方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: init_library
# 需要導入模塊: from datamodel import Library [as 別名]
# 或者: from datamodel.Library import get_or_insert [as 別名]
def init_library(self, owner, repo, create=True):
self.owner = owner.lower()
self.repo = repo.lower()
if create:
self.library = Library.get_or_insert(Library.id(owner, repo))
self.is_new = self.library.metadata is None and self.library.error is None
else:
self.library = Library.get_by_id(Library.id(owner, repo))
if self.library.status == Status.suppressed:
raise RequestAborted('library is suppressed')
示例2: init_library
# 需要導入模塊: from datamodel import Library [as 別名]
# 或者: from datamodel.Library import get_or_insert [as 別名]
def init_library(self, scope, package, create=True):
self.scope = scope.lower()
self.package = package.lower()
if create:
self.library = Library.get_or_insert(Library.id(self.scope, self.package))
self.is_new = self.library.metadata is None and self.library.error is None
else:
self.library = Library.get_by_id(Library.id(self.scope, self.package))
if self.library.status == Status.suppressed:
raise RequestAborted('library is suppressed')