From 5aaea651b17983216487d5ca0879ac68f3a08e32 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Sat, 16 Oct 2021 14:44:07 +0200 Subject: [PATCH] Automatically include input file directory in list to resolve image paths --- src/wireviz/wireviz.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wireviz/wireviz.py b/src/wireviz/wireviz.py index 6dd90fe..329b3d2 100755 --- a/src/wireviz/wireviz.py +++ b/src/wireviz/wireviz.py @@ -70,6 +70,8 @@ def parse( Required parameter if inp is not a path. image_paths (Path | str | List, optional): Paths to use when resolving any image paths included in the data. + Note: If inp is a path to a YAML file, + its parent directory will automatically be included in the list. Returns: Depending on the return_types parameter, may return: @@ -90,6 +92,12 @@ def parse( output_name = _get_output_name(yaml_file, output_name) output_file = output_dir / output_name + if yaml_file: + # if reading from file, ensure that input file's parent directory is included in image_paths + default_image_path = yaml_file.parent.resolve() + if not default_image_path in [Path(x).resolve() for x in image_paths]: + image_paths.append(default_image_path) + # define variables ========================================================= # containers for parsed component data and connection sets template_connectors = {}