From 3bcc0277a83c04dfa9cf4970153893c4a89f8c19 Mon Sep 17 00:00:00 2001 From: lkk7 Date: Sun, 14 Apr 2024 16:58:09 +0200 Subject: [PATCH] Fixup: rerun black --- src/pydot/dot_parser.py | 55 +++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/src/pydot/dot_parser.py b/src/pydot/dot_parser.py index e479e5c2..89cbf573 100644 --- a/src/pydot/dot_parser.py +++ b/src/pydot/dot_parser.py @@ -159,7 +159,9 @@ def update_parent_graph_hierarchy(g, parent_graph=None, level=0): if vertex["parent_graph"] is g: pass else: - vertex["parent_graph"].set_parent_graph(parent_graph) + vertex["parent_graph"].set_parent_graph( + parent_graph + ) def add_defaults(element, defaults): @@ -169,7 +171,9 @@ def add_defaults(element, defaults): d[key] = value -def add_elements(g, toks, defaults_graph=None, defaults_node=None, defaults_edge=None): +def add_elements( + g, toks, defaults_graph=None, defaults_node=None, defaults_edge=None +): if defaults_graph is None: defaults_graph = {} if defaults_node is None: @@ -192,7 +196,9 @@ def add_elements(g, toks, defaults_graph=None, defaults_node=None, defaults_edge elif isinstance(element, ParseResults): for e in element: - add_elements(g, [e], defaults_graph, defaults_node, defaults_edge) + add_elements( + g, [e], defaults_graph, defaults_node, defaults_edge + ) elif isinstance(element, DefaultStatement): if element.default_type == "graph": @@ -209,7 +215,9 @@ def add_elements(g, toks, defaults_graph=None, defaults_node=None, defaults_edge defaults_edge.update(element.attrs) else: - raise ValueError(f"Unknown DefaultStatement: {element.default_type}") + raise ValueError( + f"Unknown DefaultStatement: {element.default_type}" + ) elif isinstance(element, P_AttrList): g.obj_dict["attributes"].update(element.attrs) @@ -300,7 +308,9 @@ def push_edge_stmt(s, loc, toks): e.append(pydot.Edge(n_prev, n_next[0] + n_next_port, **attrs)) elif isinstance(toks[2][0], pydot.Graph): - e.append(pydot.Edge(n_prev, pydot.frozendict(toks[2][0].obj_dict), **attrs)) + e.append( + pydot.Edge(n_prev, pydot.frozendict(toks[2][0].obj_dict), **attrs) + ) elif isinstance(toks[2][0], pydot.Node): node = toks[2][0] @@ -315,7 +325,9 @@ def push_edge_stmt(s, loc, toks): # if the target of this edge is the name of a node elif isinstance(toks[2][0], str): for n_next in [n for n in tuple(toks)[2::2]]: - if isinstance(n_next, P_AttrList) or not isinstance(n_next[0], str): + if isinstance(n_next, P_AttrList) or not isinstance( + n_next[0], str + ): continue n_next_port = do_node_ports(n_next) @@ -390,9 +402,9 @@ def graph_definition(): ID = (identifier | html_text | double_quoted_string).setName("ID") - float_number = Combine(Optional(minus) + OneOrMore(Word(nums + "."))).setName( - "float_number" - ) + float_number = Combine( + Optional(minus) + OneOrMore(Word(nums + ".")) + ).setName("float_number") righthand_id = (float_number | ID).setName("righthand_id") @@ -417,7 +429,9 @@ def graph_definition(): lbrack.suppress() + Optional(a_list) + rbrack.suppress() ).setName("attr_list") - attr_stmt = (Group(graph_ | node_ | edge_) + attr_list).setName("attr_stmt") + attr_stmt = (Group(graph_ | node_ | edge_) + attr_list).setName( + "attr_stmt" + ) edgeop = (Literal("--") | Literal("->")).setName("edgeop") @@ -434,17 +448,26 @@ def graph_definition(): edgeRHS = OneOrMore(edgeop + edge_point) edge_stmt = edge_point + edgeRHS + Optional(attr_list) - subgraph = Group(subgraph_ + Optional(ID) + graph_stmt).setName("subgraph") - - edge_point << Group(subgraph | graph_stmt | node_id).setName("edge_point") + subgraph = Group(subgraph_ + Optional(ID) + graph_stmt).setName( + "subgraph" + ) - node_stmt = (node_id + Optional(attr_list) + Optional(semi.suppress())).setName( - "node_stmt" + edge_point << Group(subgraph | graph_stmt | node_id).setName( + "edge_point" ) + node_stmt = ( + node_id + Optional(attr_list) + Optional(semi.suppress()) + ).setName("node_stmt") + assignment = (ID + equals + righthand_id).setName("assignment") stmt = ( - assignment | edge_stmt | attr_stmt | subgraph | graph_stmt | node_stmt + assignment + | edge_stmt + | attr_stmt + | subgraph + | graph_stmt + | node_stmt ).setName("stmt") stmt_list << OneOrMore(stmt + Optional(semi.suppress()))