Improve path resolution.
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
folders:
|
||||
- extensions
|
||||
- tests/assets
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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])}."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user