Skip to content

Commit

Permalink
Use fr'..{var}...' to simplify creating regex strings (#429)
Browse files Browse the repository at this point in the history
Using fr'....{var}...' makes for shorter and more readable string creation.

Now that TriBITS requires Python 3 (or at least it is only tested with Python
3), it is good to be able to start using these newer language features.

I tested this manaully locally and it seems to work correctly.
  • Loading branch information
bartlettroscoe committed Feb 25, 2023
1 parent ec4532b commit 28a5c83
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions refactoring/token-replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def getCmndLineOptions():
inOptions = getCmndLineOptions()

beginLineTokenPattern = re.compile(
r'^' + inOptions.tokenToReplace + r'([^A-Za-z0-9_])' )
fr'^{inOptions.tokenToReplace}([^A-Za-z0-9_])' )
midLineTokenPattern = re.compile(
r'([^A-Za-z0-9_])' + inOptions.tokenToReplace + r'([^A-Za-z0-9_])' )
fr'([^A-Za-z0-9_]){inOptions.tokenToReplace}([^A-Za-z0-9_])' )

with open(inOptions.inputFile, 'r') as file:
lines = file.readlines()
Expand Down

0 comments on commit 28a5c83

Please sign in to comment.