本文整理汇总了Python中source.Source.invalidate方法的典型用法代码示例。如果您正苦于以下问题:Python Source.invalidate方法的具体用法?Python Source.invalidate怎么用?Python Source.invalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类source.Source
的用法示例。
在下文中一共展示了Source.invalidate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Derivative
# 需要导入模块: from source import Source [as 别名]
# 或者: from source.Source import invalidate [as 别名]
class Derivative(Asset):
def __init__(self, inflate=None, _id=None, submission=None):
super(Derivative, self).__init__(
inflate=inflate,
_id=_id,
db="derivatives",
extra_omits=['submission','source','j3m']
)
if not hasattr(self, 'submission_id'):
self.invalidate(
invalidate['codes']['submission_undefined'],
invalidate['reasons']['submission_undefined']
)
return
from submission import Submission
if submission is None:
self.submission = Submission(_id=self.submission_id)
else:
self.submission = submission
j3m = open(
os.path.join(self.submission.asset_path, self.submission.j3m), 'r'
).read()
try:
self.j3m = json.loads(j3m)
except:
self.submission.invalidate(
invalidate['codes']['submission_invalid_j3m'],
invalidate['reasons']['submission_invalid_j3m']
)
self.invalidate(
invalidate['codes']['submission_invalid_j3m'],
invalidate['reasons']['submission_invalid_j3m']
)
return
self.getSource()
if _id is None:
setattr(self, 'date_created', self.j3m['genealogy']['dateCreated'])
setattr(self, 'mime_type', self.submission.mime_type)
self.save()
self.parseLocationEntries()
self.parseAnnotationEntries()
def getSource(self):
from source import Source
if hasattr(self, 'source_id'):
self.source = Source(_id=self.source_id)
else:
fingerprint = None
try:
fingerprint = self.j3m['intent']['pgpKeyFingerprint'].lower()
except KeyError as e:
print "NO FINGERPRINT???"
self.source = Source(inflate={
'invalid': {
'error_code' : invalidate['codes']['source_missing_pgp_key'],
'reason' : invalidate['reasons']['source_missing_pgp_key']
}
})
if fingerprint is not None:
source = self.submission.db.query(
'_design/sources/_view/getSourceByFingerprint',
params={
'fingerprint' : fingerprint
}
)[0]
if source:
self.source = Source(_id=source['_id'])
else:
# we didn't have the pgp key.
# so init a new source and set an invalid flag about that.
inflate = {
'fingerprint' : fingerprint
}
## TODO: ACTUALLY THIS IS CASE-SENSITIVE! MUST BE UPPERCASE!
self.source = Source(inflate=inflate)
self.source.invalidate(
invalidate['codes']['source_missing_pgp_key'],
invalidate['reasons']['source_missing_pgp_key']
)
setattr(self, 'source_id', self.source._id)
self.save()
if hasattr(self, 'source_id'):
return True
else:
#.........这里部分代码省略.........