Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version number to output files with meta info #177

Merged
merged 3 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import os
from setuptools import setup, find_packages

from src.wireviz import __version__

project_name = 'wireviz'
from src.wireviz import __version__, CMD_NAME, APP_URL

# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
Expand All @@ -16,7 +14,7 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(
name=project_name,
name=CMD_NAME,
version=__version__,
author='Daniel Rojas',
#author_email='',
Expand All @@ -30,7 +28,7 @@ def read(fname):
],
license='GPLv3',
keywords='cable connector hardware harness wiring wiring-diagram wiring-harness',
url='https://github.com/formatc1702/WireViz',
url=APP_URL,
package_dir={'': 'src'},
packages=find_packages('src'),
entry_points={
Expand Down
18 changes: 11 additions & 7 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from wireviz.DataClasses import Connector, Cable
from graphviz import Graph
from wireviz import wv_colors, wv_helper
from wireviz import wv_colors, wv_helper, __version__, APP_NAME, APP_URL
from wireviz.wv_colors import get_color_hex
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, \
nested_html_table, flatten2d, index_if_list, html_line_breaks, \
Expand Down Expand Up @@ -63,8 +63,8 @@ def connect(self, from_name: str, from_pin: (int, str), via_name: str, via_pin:

def create_graph(self) -> Graph:
dot = Graph()
dot.body.append('// Graph generated by WireViz')
dot.body.append('// https://github.com/formatc1702/WireViz')
dot.body.append(f'// Graph generated by {APP_NAME} {__version__}')
dot.body.append(f'// {APP_URL}')
font = 'arial'
dot.attr('graph', rankdir='LR',
ranksep='2',
Expand Down Expand Up @@ -296,7 +296,11 @@ def output(self, filename: (str, Path), view: bool = False, cleanup: bool = True
# HTML output
with open_file_write(f'{filename}.html') as file:
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="{APP_NAME} {__version__} - {APP_URL}">\n')
file.write(f' <title>{APP_NAME} Diagram and BOM</title>\n')
file.write('</head><body style="font-family:Arial">\n')

file.write('<h1>Diagram</h1>')
with open_file_read(f'{filename}.svg') as svg:
Expand All @@ -312,14 +316,14 @@ def output(self, filename: (str, Path), view: bool = False, cleanup: bool = True
file.write('<table style="border:1px solid #000000; font-size: 14pt; border-spacing: 0px">')
file.write('<tr>')
for item in listy[0]:
file.write(f'<th align="left" style="border:1px solid #000000; padding: 8px">{item}</th>')
file.write(f'<th style="text-align:left; border:1px solid #000000; padding: 8px">{item}</th>')
file.write('</tr>')
for row in listy[1:]:
file.write('<tr>')
for i, item in enumerate(row):
item_str = item.replace('\u00b2', '&sup2;')
align = 'align="right"' if listy[0][i] == 'Qty' else ''
file.write(f'<td {align} style="border:1px solid #000000; padding: 4px">{item_str}</td>')
align = 'text-align:right; ' if listy[0][i] == 'Qty' else ''
file.write(f'<td style="{align}border:1px solid #000000; padding: 4px">{item_str}</td>')
file.write('</tr>')
file.write('</table>')

Expand Down
4 changes: 4 additions & 0 deletions src/wireviz/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Please don't import anything in this file to avoid issues when it is imported in setup.py

__version__ = '0.1.1'

CMD_NAME = 'wireviz' # Lower case command and module name
APP_NAME = 'WireViz' # Application name in texts meant to be human readable
APP_URL = 'https://github.com/formatc1702/WireViz'
8 changes: 4 additions & 4 deletions src/wireviz/build_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
script_path = Path(__file__).absolute()

sys.path.insert(0, str(script_path.parent.parent)) # to find wireviz module
from wireviz import wireviz, __version__
from wireviz import wireviz, __version__, APP_NAME
from wv_helper import open_file_write, open_file_read, open_file_append


Expand All @@ -26,7 +26,7 @@
'path': dir / 'tutorial',
'prefix': 'tutorial',
readme: ['md', 'yml'], # Include .md and .yml files
'title': 'WireViz Tutorial',
'title': f'{APP_NAME} Tutorial',
},
'demos' : {
'path': dir / 'examples',
Expand Down Expand Up @@ -127,8 +127,8 @@ def restore_generated(groupkeys, branch = ''):


def parse_args():
parser = argparse.ArgumentParser(description='Wireviz Example Manager',)
parser.add_argument('-V', '--version', action='version', version='%(prog)s - wireviz ' + __version__)
parser = argparse.ArgumentParser(description=f'{APP_NAME} Example Manager',)
parser.add_argument('-V', '--version', action='version', version=f'%(prog)s - {APP_NAME} {__version__}')
parser.add_argument('action', nargs='?', action='store',
choices=['build','clean','compare','diff','restore'], default='build',
help='what to do with the generated files (default: build)')
Expand Down