diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 6e87bb6..d6ccf75 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -69,7 +69,6 @@ class Tweak: @dataclass class Image: - gv_dir: InitVar[Path] # Directory of .gv file injected as context during parsing # Attributes of the image object : src: str scale: Optional[ImageScale] = None @@ -82,7 +81,7 @@ class Image: caption: Optional[MultilineHypertext] = None # See also HTML doc at https://graphviz.org/doc/info/shapes.html#html - def __post_init__(self, gv_dir): + def __post_init__(self): if self.fixedsize is None: # Default True if any dimension specified unless self.scale also is specified. @@ -98,10 +97,10 @@ class Image: # because Graphviz requires both when fixedsize=True. if self.height: if not self.width: - self.width = self.height * aspect_ratio(gv_dir.joinpath(self.src)) + self.width = self.height * aspect_ratio(self.src) else: if self.width: - self.height = self.width / aspect_ratio(gv_dir.joinpath(self.src)) + self.height = self.width / aspect_ratio(self.src) @dataclass diff --git a/src/wireviz/wireviz.py b/src/wireviz/wireviz.py index c448f5d..8d0c58b 100755 --- a/src/wireviz/wireviz.py +++ b/src/wireviz/wireviz.py @@ -12,7 +12,7 @@ if __name__ == '__main__': from wireviz.DataClasses import Metadata, Options, Tweak from wireviz.Harness import Harness -from wireviz.wv_helper import expand, get_single_key_and_value, is_arrow, open_file_read +from wireviz.wv_helper import expand, get_single_key_and_value, is_arrow, open_file_read, smart_file_resolve def parse_text(yaml_str: str, file_out: (str, Path) = None, return_types: (None, str, Tuple[str]) = ('html','png','svg','tsv'), image_paths: List = []) -> Any: @@ -82,7 +82,6 @@ def parse(yaml_data: Dict, file_out: (str, Path) = None, return_types: (None, st # The Image dataclass might need to open an image file with a relative path. image = attribs.get('image') if isinstance(image, dict): - image['gv_dir'] = Path(file_out if file_out else '').parent # Inject context # TODO: remove image_path = image['src'] if image_path and not Path(image_path).is_absolute(): # resolve relative image path image['src'] = smart_file_resolve(image_path, image_paths)