Skip to content

Commit

Permalink
Simplify code for generating polyfill regex (#77)
Browse files Browse the repository at this point in the history
* Simplify code for generating polyfill regex

* Fix lint error
  • Loading branch information
kunaltyagi authored Oct 27, 2024
1 parent 1348e64 commit 145b812
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions nsiqcppstyle_exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,8 @@ def recursive_star_replace(string):
msg = f"Except the beginning, the pattern (**) must be sandwitched between directory separator ({os.sep})"
raise ValueError(msg)
post_star = post_star.removeprefix(os.sep) # ** = recursive, including no subdirectories
if not top_level:
pre_star = recursive_star_replace(remainder)
pre_star = pre_star.removesuffix(os.sep)
string = rf"{pre_star}({os.sep}.*{os.sep}|{os.sep}){post_star}"
else:
string = rf"(.*{os.sep}|){post_star}"
pre_star = recursive_star_replace(remainder) if not top_level else ""
string = rf"{pre_star}(.+{os.sep})?{post_star}"
return string


Expand Down

0 comments on commit 145b812

Please sign in to comment.