summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Fink2025-07-14 14:58:26 +0200
committerDennis Fink2025-07-14 14:58:26 +0200
commit6062fa5cc245d709c74ec7b6b9e2ed0af3f70224 (patch)
tree5dae523b985eabdc90803bfc2f1bd1e36a76181c
parent7f98df02693578f69266e8f2630a50787bc06041 (diff)
downloadpatternutils-6062fa5cc245d709c74ec7b6b9e2ed0af3f70224.tar.gz
patternutils-6062fa5cc245d709c74ec7b6b9e2ed0af3f70224.zip
Simplify apply regex in pmatch
-rw-r--r--patternutils/commands/pmatch.py19
1 files 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", "-?")})