Fix name arrows

I seem to have (re-)implemented them incorrectly and never tested them.
This commit is contained in:
Joscha 2021-06-13 16:32:22 +02:00
parent 70ec64a48b
commit 57aef26217

View File

@ -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):