From 8259e2dfc8d26d9b486338284a9e2deaa1d9ad13 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Fri, 29 Jan 2021 14:29:36 +0100 Subject: [PATCH] fxconv: add a generic name_regex parameter to simplify naming --- fxconv/fxconv-main.py | 5 ++++- fxconv/fxconv.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fxconv/fxconv-main.py b/fxconv/fxconv-main.py index eea828c..4afe40a 100755 --- a/fxconv/fxconv-main.py +++ b/fxconv/fxconv-main.py @@ -66,7 +66,10 @@ def parse_parameters(params): raise FxconvError(f"invalid parameter {decl}, ignoring") else: name, value = decl.split(":", 1) - insert(d, name.split("."), value.strip()) + value = value.strip() + if name == "name_regex": + value = value.split(" ", 1) + insert(d, name.split("."), value) return d diff --git a/fxconv/fxconv.py b/fxconv/fxconv.py index 0a0d310..b4de5d2 100644 --- a/fxconv/fxconv.py +++ b/fxconv/fxconv.py @@ -964,7 +964,11 @@ def convert(input, params, target, output=None, model=None, custom=None): if output is None: output = os.path.splitext(input)[0] + ".o" - if "name" not in params: + if "name" in params: + pass + elif "name_regex" in params: + params["name"] = re.sub(*params["name_regex"], os.path.basename(input)) + else: raise FxconvError(f"no name specified for conversion '{input}'") if target["arch"] is None: