Improve path resolution.

This commit is contained in:
2026-11-17 13:24:00 -06:00
parent 59cc3263b7
commit 38a0c6aa5f
3 changed files with 11 additions and 8 deletions

View File

@@ -1,2 +1,3 @@
folders:
- extensions
- tests/assets

View File

@@ -111,11 +111,11 @@ def convert(args):
input_subs = yaml.safe_load(args.input_subs)
output_subs = yaml.safe_load(args.output_subs)
input_converter = Converter(input_format_path, input_subs)
input_frame = input_converter.from_file(args.input_file.resolve())
input_frame = input_converter.from_file(find_file(args.input_file))
af = input_converter.to_AF(input_frame)
output_converter = Converter(output_format_path, output_subs)
output_frame = output_converter.from_AF(af)
output_converter.to_file(output_frame, args.output_file.resolve())
output_converter.to_file(output_frame, args.output_file)
def list_configs():

View File

@@ -14,16 +14,18 @@ def find_file(
filepath: PathLike | Path | str, folders: Collection[Path] = ()
) -> Path:
path = Path(filepath)
allfolders = chain(
[] if folders is None else folders,
[Path(getcwd())],
AuDaGe.folders,
allfolders = list(
chain(
[] if folders is None else folders,
[Path(getcwd())],
AuDaGe.folders,
)
)
for folder in allfolders:
fullpath = Path(folder, path).resolve()
if fullpath.exists():
return fullpath
raise FileNotFoundError(
f"The file {filepath} was not found in any of the configured folders "
f"({allfolders})."
f'The file "{filepath}" was not found in any of the configured '
f"folders: {', '.join([str(path) for path in allfolders])}."
)