fxconv: add a generic name_regex parameter to simplify naming

This commit is contained in:
Lephenixnoir 2021-01-29 14:29:36 +01:00
parent 2596a53c6b
commit 8259e2dfc8
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
2 changed files with 9 additions and 2 deletions

View file

@ -66,7 +66,10 @@ def parse_parameters(params):
raise FxconvError(f"invalid parameter {decl}, ignoring") raise FxconvError(f"invalid parameter {decl}, ignoring")
else: else:
name, value = decl.split(":", 1) 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 return d

View file

@ -964,7 +964,11 @@ def convert(input, params, target, output=None, model=None, custom=None):
if output is None: if output is None:
output = os.path.splitext(input)[0] + ".o" 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}'") raise FxconvError(f"no name specified for conversion '{input}'")
if target["arch"] is None: if target["arch"] is None: