Add version number to output files with meta info

Tag the .gv and .html output files with generator and version number.
This commit is contained in:
KV 2020-10-10 21:43:27 +02:00 committed by Daniel Rojas
parent 1809f73d58
commit b00040cdd9

View File

@ -3,7 +3,7 @@
from wireviz.DataClasses import Connector, Cable from wireviz.DataClasses import Connector, Cable
from graphviz import Graph from graphviz import Graph
from wireviz import wv_colors, wv_helper from wireviz import wv_colors, wv_helper, __version__
from wireviz.wv_colors import get_color_hex from wireviz.wv_colors import get_color_hex
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, \ from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, \
nested_html_table, flatten2d, index_if_list, html_line_breaks, \ nested_html_table, flatten2d, index_if_list, html_line_breaks, \
@ -63,7 +63,7 @@ class Harness:
def create_graph(self) -> Graph: def create_graph(self) -> Graph:
dot = Graph() dot = Graph()
dot.body.append('// Graph generated by WireViz') dot.body.append('// Graph generated by WireViz ' + __version__)
dot.body.append('// https://github.com/formatc1702/WireViz') dot.body.append('// https://github.com/formatc1702/WireViz')
font = 'arial' font = 'arial'
dot.attr('graph', rankdir='LR', dot.attr('graph', rankdir='LR',
@ -296,7 +296,12 @@ class Harness:
# HTML output # HTML output
with open_file_write(f'{filename}.html') as file: with open_file_write(f'{filename}.html') as file:
file.write('<!DOCTYPE html>\n') file.write('<!DOCTYPE html>\n')
file.write('<html><head><meta charset="UTF-8"></head><body style="font-family:Arial">') file.write('<html lang="en"><head>\n')
file.write(' <meta charset="UTF-8">\n')
file.write(f' <meta name="generator" content="WireViz {__version__}'
' - https://github.com/formatc1702/WireViz">\n')
file.write(' <title>Wireviz Diagram and BOM</title>\n')
file.write('</head><body style="font-family:Arial">\n')
file.write('<h1>Diagram</h1>') file.write('<h1>Diagram</h1>')
with open_file_read(f'{filename}.svg') as svg: with open_file_read(f'{filename}.svg') as svg: