From 6a7f1fdcd83ad5ee2a6d72e3fd14c2ee82428ca2 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Sat, 27 Mar 2021 15:45:48 +0100 Subject: [PATCH] Generalize metadata filling for nested dicts useful for authors and revisions --- src/wireviz/templates/din-6771.html | 82 ++++++++++++++--------------- src/wireviz/wv_html.py | 38 ++++--------- 2 files changed, 51 insertions(+), 69 deletions(-) diff --git a/src/wireviz/templates/din-6771.html b/src/wireviz/templates/din-6771.html index efc2618..0fcb59b 100644 --- a/src/wireviz/templates/din-6771.html +++ b/src/wireviz/templates/din-6771.html @@ -203,70 +203,70 @@
- - - - + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + diff --git a/src/wireviz/wv_html.py b/src/wireviz/wv_html.py index 8e51e51..4ebfd08 100644 --- a/src/wireviz/wv_html.py +++ b/src/wireviz/wv_html.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from pathlib import Path -from typing import List, Union +from typing import List, Dict, Union import re from wireviz import __version__, APP_NAME, APP_URL, wv_colors @@ -62,28 +62,6 @@ def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]], if metadata: html = html.replace('', f'{APP_NAME} {__version__} - {APP_URL}') - - # fill out authors - for i, (k, v) in enumerate(metadata.get('authors', {}).items(), 1): - title = k - name = v['name'] - date = v['date'].strftime('%Y-%m-%d') - html = html.replace(f'', title) - html = html.replace(f'', name) - html = html.replace(f'', date) - - # fill out revisions - for i, (k, v) in enumerate(metadata.get('revisions', {}).items(), 1): - # TODO: for more than 8 revisions, keep only the 8 most recent ones - number = k - changelog = v['changelog'] - name = v['name'] - date = v['date'].strftime('%Y-%m-%d') - html = html.replace(f'', '{:02d}'.format(number)) - html = html.replace(f'', changelog) - html = html.replace(f'', name) - html = html.replace(f'', date) - html = html.replace(f'"sheetsize_default"', '"{}"'.format(metadata.get('template',{}).get('sheetsize', ''))) # include quotes so no replacement happens within
Date Name