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


Python History.back方法代码示例

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


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

示例1: __init__

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import back [as 别名]

#.........这里部分代码省略.........
        """Return subjects of current if predicate given, return current subjects-predicates if no uri is given."""
        if uri:
            ref = self.model.to_uriref(uri)
            if ref and self.current:
                return self.model.get_subjects(ref, self.current)
        elif self.current:
            return self.model.get_reverse_properties(self.current)
        return None

    def go(self, uri):
        """Set current to given resource uri, or to None if no uri is given."""
        if uri:
            ref = self.model.to_uriref(uri)
            self.model.load(str(ref))
            if self.model.contains_resource(ref):
                self.current = ref
                self.history.push(ref)
                return ref
            return False
        else:
            self.current = None
            self.history.push(None)
            return None

    def get_objects(self, uri):
        if uri:
            ref = self.model.to_uriref(uri)
            if ref and self.current:
                return self.model.get_resource_objects(self.current, ref)
            return False
        else:
            return False

    def fw(self, uri, index=0):
        """Set current to object of given predicate of current."""
        if uri:
            ref = self.model.to_uriref(uri)
            if ref and self.current:
                objs = self.model.get_resource_objects(self.current, ref)
                if len(objs) > 0:
                    obj = objs[index]
                    self.model.load(str(obj))
                    self.current = obj
                    self.history.push(obj)
                    return obj
            return False
        else:
            return False

    def get_subjects(self, uri):
        if uri:
            ref = self.model.to_uriref(uri)
            if ref and self.current:
                return self.model.get_subjects(ref, self.current)
            return False
        else:
            return False

    def bw(self, uri, index=0):
        """Set current to subject of given predicate pointing to current."""
        if uri:
            ref = self.model.to_uriref(uri)
            if ref and self.current:
                subjs = self.model.get_subjects(ref, self.current)
                if len(subjs) > 0:
                    subj = subjs[index]
                    self.model.load(str(subj))
                    self.current = subj
                    self.history.push(subj)
                    return subj
            return False
        else:
            return False

    def forward(self):
        ref = self.history.forward()
        if ref != False:
            self.current = ref
        return ref

    def back(self):
        ref = self.history.back()
        if ref != False:
            self.current = ref
        return ref

    def this(self):
        """Return current."""
        return self.current

    def pred(self):
        """Return predicates of current."""
        return self.model.pred(self.current)

    def types(self):
        """Return all terms that exist as objects of rdf:type."""
        return self.model.types()

    def norm(self, ref):
        return self.model.norm(ref)
开发者ID:rrasmo,项目名称:rdfcli,代码行数:104,代码来源:controller.py


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