当前位置: 首页>>代码示例>>Python>>正文


Python PackageRelationship.reverse_type方法代码示例

本文整理汇总了Python中package_relationship.PackageRelationship.reverse_type方法的典型用法代码示例。如果您正苦于以下问题:Python PackageRelationship.reverse_type方法的具体用法?Python PackageRelationship.reverse_type怎么用?Python PackageRelationship.reverse_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在package_relationship.PackageRelationship的用法示例。


在下文中一共展示了PackageRelationship.reverse_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_relationships

# 需要导入模块: from package_relationship import PackageRelationship [as 别名]
# 或者: from package_relationship.PackageRelationship import reverse_type [as 别名]
 def get_relationships(self, with_package=None, type=None, active=True,
                       direction='both'):
     '''Returns relationships this package has.
     Keeps stored type/ordering (not from pov of self).'''
     assert direction in ('both', 'forward', 'reverse')
     if with_package:
         assert isinstance(with_package, Package)
     from package_relationship import PackageRelationship
     forward_filters = [PackageRelationship.subject==self]
     reverse_filters = [PackageRelationship.object==self]
     if with_package:
         forward_filters.append(PackageRelationship.object==with_package)
         reverse_filters.append(PackageRelationship.subject==with_package)
     if active:
         forward_filters.append(PackageRelationship.state==core.State.ACTIVE)
         reverse_filters.append(PackageRelationship.state==core.State.ACTIVE)
     if type:
         forward_filters.append(PackageRelationship.type==type)
         reverse_type = PackageRelationship.reverse_type(type)
         reverse_filters.append(PackageRelationship.type==reverse_type)
     q = meta.Session.query(PackageRelationship)
     if direction == 'both':
         q = q.filter(or_(
         and_(*forward_filters),
         and_(*reverse_filters),
         ))
     elif direction == 'forward':
         q = q.filter(and_(*forward_filters))
     elif direction == 'reverse':
         q = q.filter(and_(*reverse_filters))
     return q.all()
开发者ID:HatemAlSum,项目名称:ckan,代码行数:33,代码来源:package.py

示例2: get_relationships

# 需要导入模块: from package_relationship import PackageRelationship [as 别名]
# 或者: from package_relationship.PackageRelationship import reverse_type [as 别名]
    def get_relationships(self, with_package=None, type=None, active=True, direction="both"):
        """Returns relationships this package has.
        Keeps stored type/ordering (not from pov of self)."""
        assert direction in ("both", "forward", "reverse")
        if with_package:
            assert isinstance(with_package, Package)
        from package_relationship import PackageRelationship

        forward_filters = [PackageRelationship.subject == self]
        reverse_filters = [PackageRelationship.object == self]
        if with_package:
            forward_filters.append(PackageRelationship.object == with_package)
            reverse_filters.append(PackageRelationship.subject == with_package)
        if active:
            forward_filters.append(PackageRelationship.state == State.ACTIVE)
            reverse_filters.append(PackageRelationship.state == State.ACTIVE)
        if type:
            forward_filters.append(PackageRelationship.type == type)
            reverse_type = PackageRelationship.reverse_type(type)
            reverse_filters.append(PackageRelationship.type == reverse_type)
        q = Session.query(PackageRelationship)
        if direction == "both":
            q = q.filter(or_(and_(*forward_filters), and_(*reverse_filters)))
        elif direction == "forward":
            q = q.filter(and_(*forward_filters))
        elif direction == "reverse":
            q = q.filter(and_(*reverse_filters))
        return q.all()
开发者ID:jakebarnwell,项目名称:PythonGenerator,代码行数:30,代码来源:package.py


注:本文中的package_relationship.PackageRelationship.reverse_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。