Improve path resolution.
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
folders:
|
folders:
|
||||||
- extensions
|
- extensions
|
||||||
|
- tests/assets
|
||||||
|
|||||||
@@ -111,11 +111,11 @@ def convert(args):
|
|||||||
input_subs = yaml.safe_load(args.input_subs)
|
input_subs = yaml.safe_load(args.input_subs)
|
||||||
output_subs = yaml.safe_load(args.output_subs)
|
output_subs = yaml.safe_load(args.output_subs)
|
||||||
input_converter = Converter(input_format_path, input_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)
|
af = input_converter.to_AF(input_frame)
|
||||||
output_converter = Converter(output_format_path, output_subs)
|
output_converter = Converter(output_format_path, output_subs)
|
||||||
output_frame = output_converter.from_AF(af)
|
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():
|
def list_configs():
|
||||||
|
|||||||
@@ -14,16 +14,18 @@ def find_file(
|
|||||||
filepath: PathLike | Path | str, folders: Collection[Path] = ()
|
filepath: PathLike | Path | str, folders: Collection[Path] = ()
|
||||||
) -> Path:
|
) -> Path:
|
||||||
path = Path(filepath)
|
path = Path(filepath)
|
||||||
allfolders = chain(
|
allfolders = list(
|
||||||
[] if folders is None else folders,
|
chain(
|
||||||
[Path(getcwd())],
|
[] if folders is None else folders,
|
||||||
AuDaGe.folders,
|
[Path(getcwd())],
|
||||||
|
AuDaGe.folders,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
for folder in allfolders:
|
for folder in allfolders:
|
||||||
fullpath = Path(folder, path).resolve()
|
fullpath = Path(folder, path).resolve()
|
||||||
if fullpath.exists():
|
if fullpath.exists():
|
||||||
return fullpath
|
return fullpath
|
||||||
raise FileNotFoundError(
|
raise FileNotFoundError(
|
||||||
f"The file {filepath} was not found in any of the configured folders "
|
f'The file "{filepath}" was not found in any of the configured '
|
||||||
f"({allfolders})."
|
f"folders: {', '.join([str(path) for path in allfolders])}."
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user