コード例 #1
0
ファイル: graph.py プロジェクト: JackB1ack/vipe
    def from_dot(dot_string):
        """Read graph from a string defining a graph in a simplified dot format.

        Args:
            dot_string (string): description of the graph in a simplified
                version of dot format. Among other things, the graph definition
                doesn't have to be surrounded by `digraph{ ... }` and available
                ports of a node don't have to be specified explicitly in the
                definition of the node.

        Return:
            SimplifiedDotGraph
        """
        nodes = set()
        connections = set()
        for line in dot_string.split('\n'):
            node = LineParser.parse_node(line)
            if node is not None:
                nodes = nodes.union({node})
                continue
            connection = LineParser.parse_connection(line)
            if connection is not None:
                connections = connections.union({connection})
                if connection.start_node not in nodes:
                    nodes = nodes.union({connection.start_node})
                if connection.end_node not in nodes:
                    nodes = nodes.union({connection.end_node})
                continue
        return SimplifiedDotGraph(nodes, connections)
コード例 #2
0
ファイル: graph.py プロジェクト: openaire/vipe
    def from_dot(dot_string):
        """Read graph from a string defining a graph in a simplified dot format.

        Args:
            dot_string (string): description of the graph in a simplified
                version of dot format. Among other things, the graph definition
                doesn't have to be surrounded by `digraph{ ... }` and available
                ports of a node don't have to be specified explicitly in the
                definition of the node.

        Return:
            SimplifiedDotGraph
        """
        nodes = set()
        connections = set()
        for line in dot_string.split('\n'):
            node = LineParser.parse_node(line)
            if node is not None:
                nodes = nodes.union({node})
                continue
            connection = LineParser.parse_connection(line)
            if connection is not None:
                connections = connections.union({connection})
                if connection.start_node not in nodes:
                    nodes = nodes.union({connection.start_node})
                if connection.end_node not in nodes:
                    nodes = nodes.union({connection.end_node})
                continue
        return SimplifiedDotGraph(nodes, connections)
コード例 #3
0
def check_connection(line, expected_connection):
    actual_connection = LineParser.parse_connection(line)
    if expected_connection is None:
        assert actual_connection is None
    else:
        assert expected_connection == actual_connection, \
            '{} != {}'.format(expected_connection, actual_connection)
コード例 #4
0
ファイル: test_line_parser.py プロジェクト: openaire/vipe
def check_connection(line, expected_connection):
    actual_connection = LineParser.parse_connection(line)
    if expected_connection is None:
        assert actual_connection is None
    else:
        assert expected_connection == actual_connection, \
            '{} != {}'.format(expected_connection, actual_connection)
コード例 #5
0
def check_node(line, expected_node):
    actual_node = LineParser.parse_node(line)
    if expected_node is None:
        assert actual_node is None
    else:
        assert expected_node == actual_node
コード例 #6
0
ファイル: test_line_parser.py プロジェクト: openaire/vipe
def check_node(line, expected_node):
    actual_node = LineParser.parse_node(line)
    if expected_node is None:
        assert actual_node is None
    else:
        assert expected_node == actual_node