models.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Dallinger 作者: Dallinger 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号