From 57aef262179f72795e30f1c93254a32f084c0e23 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 13 Jun 2021 16:32:22 +0200 Subject: [PATCH] Fix name arrows I seem to have (re-)implemented them incorrectly and never tested them. --- PFERD/transformer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PFERD/transformer.py b/PFERD/transformer.py index bf51d6a..a37443a 100644 --- a/PFERD/transformer.py +++ b/PFERD/transformer.py @@ -142,18 +142,23 @@ class RenamingPartsTf(Transformation): def transform(self, path: PurePath) -> TransformResult: result = PurePath() + any_part_matched = False for part in path.parts: transformed = self.sub_tf.transform(PurePath(part)) if not transformed: result /= part elif isinstance(transformed, Transformed): result /= transformed.path + any_part_matched = True elif isinstance(transformed, Ignored): return transformed else: raise RuntimeError(f"Invalid transform result of type {type(transformed)}: {transformed}") - return None + if any_part_matched: + return Transformed(result) + else: + return None class RuleParseError(Exception):