From a490535b1e181480007b57f4263a9a62aab76cab Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sun, 27 Oct 2024 15:34:34 +0900 Subject: [PATCH] Simplify code for generating polyfill regex --- nsiqcppstyle_exe.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/nsiqcppstyle_exe.py b/nsiqcppstyle_exe.py index a51e75f..a1543a7 100755 --- a/nsiqcppstyle_exe.py +++ b/nsiqcppstyle_exe.py @@ -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