def transformations(self, relationship="all"):
"""Get all the transformations of this info.
Return a list of transformations involving this info. ``relationship``
can be "parent" (in which case only transformations where the info is
the ``info_in`` are returned), "child" (in which case only
transformations where the info is the ``info_out`` are returned) or
``all`` (in which case any transformations where the info is the
``info_out`` or the ``info_in`` are returned). The default is ``all``
"""
if relationship not in ["all", "parent", "child"]:
raise(ValueError(
"You cannot get transformations of relationship {}"
.format(relationship) +
"Relationship can only be parent, child or all."))
if relationship == "all":
return Transformation\
.query\
.filter(and_(Transformation.failed == false(),
or_(Transformation.info_in == self,
Transformation.info_out == self)))\
.all()
if relationship == "parent":
return Transformation\
.query\
.filter_by(info_in_id=self.id,
failed=False)\
.all()
if relationship == "child":
return Transformation\
.query\
.filter_by(info_out_id=self.id,
failed=False)\
.all()
评论列表
文章目录