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