def load_node(node_id): """ Return a SqNode subclass for the given id. Wrap a call to a Graph API that returns a GraphNode and call on sqfactory to parse it into a SqNode subclass. Required: id node_id id of node to fetch Returns: SqNode single instance of concrete SqNode subclass """ node = None try: graph_node = reader.get_node(node_id) if graph_node: factory = sqfactory.get_factory() node = factory.construct_node_and_edges(graph_node) except GraphOutputError as e: #logger.debug(e.reason) print e.reason return node
def load_edges(node_id): """ Return a dict of SqEdge subclasses for the given SqNode ID. Wrap a call to a Graph API that returns a GraphEdge and call on sqfactory to parse it into a SqEdge subclass. Required: id node_id id of edge to fetch Returns: dict concrete SqEdge subclasses keyed on ID """ edges = None try: graph_node = reader.get_node(node_id) edges = {} factory = sqfactory.get_factory() for id, graph_edge in graph_node.edges().items(): edges[id] = factory.construct_edge(graph_edge) except GraphOutputError as e: #logger.debug(e.reason) print e.reason return edges