From 8e09cb98413643f463a750ad88701e48cbe83484 Mon Sep 17 00:00:00 2001 From: KV Date: Sun, 3 Oct 2021 18:37:55 +0200 Subject: [PATCH] Rename Look attribute color to bordercolor --- src/wireviz/DataClasses.py | 10 +++++----- src/wireviz/Harness.py | 2 +- src/wireviz/wv_gv_html.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index a82d624..87f9a6b 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -36,7 +36,7 @@ class Metadata(dict): @dataclass class Look: """Colors and font that defines how an element should look like.""" - color: Optional[Color] = None + bordercolor: Optional[Color] = None bgcolor: Optional[Color] = None fontcolor: Optional[Color] = None fontname: Optional[PlainText] = None @@ -51,17 +51,17 @@ class Look: def graph_args(self) -> dict: """Return dict with arguments to a dot graph.""" - return {k:v for k,v in self._2dict().items() if k != 'color'} + return {k:v for k,v in self._2dict().items() if k != 'bordercolor'} def node_args(self) -> dict: """Return dict with arguments to a dot node with filled style.""" - return {k.replace('bg', 'fill'):v for k,v in self._2dict().items()} + return {k.replace('border', '').replace('bg', 'fill'):v for k,v in self._2dict().items()} def html_style(self, color_prefix: Optional[str] = None, include_all: bool = True) -> str: """Return HTML style value containing all non-empty option values.""" translated = Look(**self._2dict()) return ' '.join(value for value in ( - f'{color_prefix} {translated.color};' if self.color and color_prefix else None, + f'{color_prefix} {translated.bordercolor};' if self.bordercolor and color_prefix else None, f'background-color: {translated.bgcolor};' if self.bgcolor and include_all else None, f'color: {translated.fontcolor};' if self.fontcolor and include_all else None, f'font-family: {self.fontname};' if self.fontname and include_all else None, @@ -69,7 +69,7 @@ class Look: ) if value) DEFAULT_LOOK = Look( - color = 'BK', + bordercolor = 'BK', bgcolor = 'WH', fontcolor = 'BK', fontname = 'arial', diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index a147503..9002dd9 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -106,7 +106,7 @@ class Harness: dot.attr('edge', style='bold', **self.options.base.node_args()) - wire_border_hex = wv_colors.get_color_hex(self.options.base.color)[0] + wire_border_hex = wv_colors.get_color_hex(self.options.base.bordercolor)[0] # prepare ports on connectors depending on which side they will connect for _, cable in self.cables.items(): diff --git a/src/wireviz/wv_gv_html.py b/src/wireviz/wv_gv_html.py index f1fc0f8..4cc9953 100644 --- a/src/wireviz/wv_gv_html.py +++ b/src/wireviz/wv_gv_html.py @@ -40,7 +40,7 @@ def nested_html_table(rows: List[Union[GvHtml, List[Optional[GvHtmlX]], None]], def table_attr(look: Optional[Look]) -> GvHtmlAttr: """Return table tag attributes containing all non-empty table option values.""" return '' if not look else ''.join({ - f' {k}="{v}"' for k,v in look._2dict().items() if v and 'font' not in k}) + f' {k.replace("border", "")}="{v}"' for k,v in look._2dict().items() if v and 'font' not in k}) def font_attr(look: Optional[Look]) -> GvHtmlAttr: """Return font tag attributes containing all non-empty font option values."""