From 6062fa5cc245d709c74ec7b6b9e2ed0af3f70224 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Mon, 14 Jul 2025 14:58:26 +0200 Subject: Simplify apply regex in pmatch --- patternutils/commands/pmatch.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/patternutils/commands/pmatch.py b/patternutils/commands/pmatch.py index 62fc256..20f71a1 100644 --- a/patternutils/commands/pmatch.py +++ b/patternutils/commands/pmatch.py @@ -34,13 +34,18 @@ def apply_regex( except ValueError: click.secho(f"'{subject}' did not match!", fg="red", err=True) yield None - else: - match["_path"] = f.path - match["_name"] = f.name - match["_abspath"] = os.path.abspath(f.path) - match["_realpath"] = os.path.realpath(f.path) - match["_relpath"] = os.path.relpath(f.path) - yield match + continue + + match.update( + { + "_path": entry.path, + "_name": entry.name, + "_abspath": os.path.abspath(entry.path), + "_realpath": os.path.realpath(entry.path), + "_relpath": os.path.relpath(entry.path), + } + ) + yield match @click.command(context_settings={"help_option_names": ("-h", "--help", "-?")}) -- cgit v1.3.1