本文整理汇总了Python中osf.models.Guid.find方法的典型用法代码示例。如果您正苦于以下问题:Python Guid.find方法的具体用法?Python Guid.find怎么用?Python Guid.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osf.models.Guid
的用法示例。
在下文中一共展示了Guid.find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_file_guids
# 需要导入模块: from osf.models import Guid [as 别名]
# 或者: from osf.models.Guid import find [as 别名]
def get_file_guids(cls, materialized_path, provider, node=None):
guids = []
path = materialized_path.strip('/')
file_obj = cls.load(path)
if not file_obj:
file_obj = TrashedFileNode.load(path)
# At this point, file_obj may be an OsfStorageFile, an OsfStorageFolder, or a
# TrashedFileNode. TrashedFileNodes do not have *File and *Folder subclasses, since
# only osfstorage trashes folders. To search for children of TrashFileNodes
# representing ex-OsfStorageFolders, we will reimplement the `children` method of the
# Folder class here.
if not file_obj.is_file:
children = []
if isinstance(file_obj, TrashedFileNode):
children = file_obj.trashed_children.all()
else:
children = file_obj.children
for item in children:
guids.extend(cls.get_file_guids(item.path, provider, node=node))
else:
try:
guid = Guid.find(Q('referent', 'eq', file_obj))[0]
except IndexError:
guid = None
if guid:
guids.append(guid._id)
return sorted(guids)