Skip to content

Commit

Permalink
Use search instead of match
Browse files Browse the repository at this point in the history
  • Loading branch information
dhadka committed Sep 5, 2024
1 parent e29310e commit 73d5d25
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rhodium/test/plot_to_savefig.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

with open(sys.argv[1], "r") as f:
for line in f:
m = re.match(r"import matplotlib.pyplot as ([a-zA-Z_]+)", line)
m = re.search(r"import matplotlib.pyplot as ([a-zA-Z_]+)", line)
if m:
pyplot_alias = m.group(1)

m = re.match(pyplot_alias + r".show\(\)", line)
m = re.search(pyplot_alias + r".show\(\)", line)
if m:
line = line[:m.start()] + pyplot_alias + ".savefig('" + str(fig_basename) + "." + str(fig_index) + ".png')" + line[m.end():]
fig_index += 1
Expand Down

0 comments on commit 73d5d25

Please sign in to comment.