mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-28 20:43:37 +01:00
fxconv: resolve name_regex in the fxconv-metadata.txt API
This commit is contained in:
parent
4d46661d3b
commit
bbf716b031
1 changed files with 9 additions and 7 deletions
|
@ -1178,11 +1178,7 @@ 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" in params:
|
if "name" not 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:
|
||||||
|
@ -1448,7 +1444,8 @@ class Metadata:
|
||||||
def rules_for(self, path):
|
def rules_for(self, path):
|
||||||
"""
|
"""
|
||||||
Returns the parameters that apply to the specified path, or None if no
|
Returns the parameters that apply to the specified path, or None if no
|
||||||
wildcard matches it.
|
wildcard matches it. The special key "name_regex" is also resolved into
|
||||||
|
the regular key "name".
|
||||||
"""
|
"""
|
||||||
|
|
||||||
basename = os.path.basename(path)
|
basename = os.path.basename(path)
|
||||||
|
@ -1460,4 +1457,9 @@ class Metadata:
|
||||||
params.update(**p)
|
params.update(**p)
|
||||||
matched = True
|
matched = True
|
||||||
|
|
||||||
return params if matched else None
|
if not matched:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if "name_regex" in params and not "name" in params:
|
||||||
|
params["name"] = re.sub(*params["name_regex"], basename)
|
||||||
|
return params
|
||||||
|
|
Loading…
Reference in a new issue