Skip to content

Commit f5523f8

Browse files
committed
Simplify regex
1 parent 5d6b044 commit f5523f8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

graphviz2drawio/graphviz2drawio.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def _load_pygraphviz_graph(
5959
# is mistakenly identified as a filename.
6060
# https://github.com/pygraphviz/pygraphviz/issues/536
6161
pattern = re.compile(
62-
r"(?:\s*(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/|//[^\r\n]*|\#[^\r\n]*)\s*)*\s*(strict)?\s*(graph|digraph).*?\{.*\}\s*",
63-
re.DOTALL | re.MULTILINE | re.VERBOSE,
62+
pattern=r"^\s*(strict)?\s*(graph|digraph).*{",
63+
flags=re.DOTALL | re.MULTILINE,
6464
)
65-
if pattern.match(graph_to_convert):
65+
if pattern.search(graph_to_convert):
6666
return AGraph(string=graph_to_convert)
6767
return AGraph(filename=graph_to_convert)
6868
# pyrefly: ignore # missing-attribute

0 commit comments

Comments
 (0)