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


Python Notifier.is_subscribed方法代码示例

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


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

示例1: Graph

# 需要导入模块: from notifier import Notifier [as 别名]
# 或者: from notifier.Notifier import is_subscribed [as 别名]
class Graph(object):
    def __init__(self, name, graph_type):
        """Create a Graph instance

        :type name: str
        :type graph_type: str
        :rtype: Graph
        """
        self.name = name
        self.graph_type = graph_type
        self.root_id = None
        self.notifier = Notifier()

    def subscribe(self, function):
        self.notifier.subscribe(function)

    def is_subscribed(self):
        return self.notifier.is_subscribed()

    def get_item(self, item):
        if isinstance(item, Edge):
            return self.get_edge(item.source_id, item.target_id, item.label)
        if isinstance(item, Vertex):
            return self.get_vertex(item.vertex_id)

    @abc.abstractmethod
    def copy(self):
        """Create a copy of the graph

        :return: A copy of the graph
        :rtype: Graph
        """
        pass

    @abc.abstractmethod
    def num_vertices(self):
        """Number of vertices in the graph

        :return:
        :rtype: int
        """
        pass

    @abc.abstractmethod
    def num_edges(self):
        """Number of edges in the graph

        :return:
        :rtype: int
        """
        pass

    @abc.abstractmethod
    def add_vertex(self, v):
        """Add a vertex to the graph

        A copy of Vertex v will be added to the graph.

        Example:
        --------
        graph = Graph()
        v = Vertex(vertex_id=1, properties={prop_key:prop_value})
        graph.add_vertex(v)

        :param v: the vertex to add
        :type v: Vertex
        """
        pass

    @abc.abstractmethod
    def add_edge(self, e):
        """Add an edge to the graph

        A copy of Edge e will be added to the graph.

        Example:
        --------
        graph = Graph()

        v1_prop = {'prop_key':'some value for my first vertex'}
        v2_prop = {'prop_key':'another value for my second vertex'}
        v1 = Vertex(vertex_id=1, properties=v1_prop)
        v2 = Vertex(vertex_id=2, properties=v2_prop)
        graph.add_vertex(v1)
        graph.add_vertex(v2)

        e_prop = {'edge_prop':'and here is my edge property value'}
        e = Edge(source_id=v1.vertex_id, target_id=v2.vertex_id,
                 label='BELONGS', properties=e_prop)
        graph.add_edge(e)

        :param e: the edge to add
        :type e: Edge
        """
        pass

    @abc.abstractmethod
    def get_vertex(self, v_id):
        """Fetch a vertex from the graph

#.........这里部分代码省略.........
开发者ID:Idandos,项目名称:vitrage,代码行数:103,代码来源:graph.py


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