Compare commits
13 Commits
master
...
issue349tw
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78434969cd | ||
|
|
7cf9244af1 | ||
|
|
6c87c27cfc | ||
|
|
336bea8b0d | ||
|
|
590504130c | ||
|
|
a3281b07a2 | ||
|
|
b85bd0cd0a | ||
|
|
81ed3fa12b | ||
|
|
8e3014911a | ||
|
|
684f6f0064 | ||
|
|
0c73e57267 | ||
|
|
49c7685bb2 | ||
|
|
d680361556 |
@ -1,31 +1,6 @@
|
||||
# Change Log
|
||||
|
||||
## [0.4.1] (2024-07-13)
|
||||
|
||||
### Improvements to help reported issues
|
||||
|
||||
- Print Python & OS versions when raising unexpected OSError related to #346 & #392 (bugfixes below)
|
||||
- Explain unexpeced top-level type ([#342](https://github.com/wireviz/WireViz/issues/342), [#383](https://github.com/wireviz/WireViz/pull/383))
|
||||
- Add non-empty label to reduce over-sized loops ([#286](https://github.com/wireviz/WireViz/issues/286), [#381](https://github.com/wireviz/WireViz/pull/381))
|
||||
- Improve placeholder name consistency ([#377](https://github.com/wireviz/WireViz/issues/377), [#380](https://github.com/wireviz/WireViz/pull/380))
|
||||
- Add work-around for Graphviz SVG bug ([#175](https://github.com/wireviz/WireViz/issues/175), [#371](https://github.com/wireviz/WireViz/pull/371))
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- Avoid ResourceWarning: unclosed file ([#309 (comment)](https://github.com/wireviz/WireViz/pull/309#issuecomment-2170988381), [#395](https://github.com/wireviz/WireViz/pull/395))
|
||||
- Catch ValueError and OSError(errno=None) ([#318 (review)](https://github.com/wireviz/WireViz/pull/318#pullrequestreview-1457016602), [#391](https://github.com/wireviz/WireViz/issues/391), [#392](https://github.com/wireviz/WireViz/pull/392))
|
||||
- Add minor missing doc entry ([#186 (comment)](https://github.com/wireviz/WireViz/pull/186#issuecomment-2139037434), [#186 (comment)](https://github.com/wireviz/WireViz/pull/186#issuecomment-2155032522))
|
||||
- Avoid Graphviz error when hiding all pins ([#257](https://github.com/wireviz/WireViz/issues/257), [#375](https://github.com/wireviz/WireViz/pull/375))
|
||||
- Avoid decimal point and trailing zero for integer BOM quantities ([#340](https://github.com/wireviz/WireViz/issues/340), [#374](https://github.com/wireviz/WireViz/pull/374))
|
||||
- Update project URL references ([#316 (comment)](https://github.com/wireviz/WireViz/issues/316#issuecomment-1568748914), [#364](https://github.com/wireviz/WireViz/pull/364))
|
||||
- Add missing import of embed_svg_images ([#363](https://github.com/wireviz/WireViz/pull/363))
|
||||
- Use correct default title ([#360](https://github.com/wireviz/WireViz/issues/360), [#361](https://github.com/wireviz/WireViz/pull/361))
|
||||
- Fix bugs in mate processing ([#355](https://github.com/wireviz/WireViz/issues/355), [#358](https://github.com/wireviz/WireViz/pull/358))
|
||||
- Include missing files in published package ([#345](https://github.com/wireviz/WireViz/issues/345), [#347](https://github.com/wireviz/WireViz/pull/347))
|
||||
- Catch OSError(errno=EINVAL) ([#344](https://github.com/wireviz/WireViz/issues/344), [#346](https://github.com/wireviz/WireViz/pull/346))
|
||||
|
||||
|
||||
## [0.4](https://github.com/wireviz/WireViz/tree/v0.4) (2024-05-12)
|
||||
## [0.4](https://github.com/formatc1702/WireViz/tree/v0.4) (2024-05-12)
|
||||
|
||||
### Backward-incompatible changes
|
||||
- New syntax for autogenerated components ([#184](https://github.com/wireviz/WireViz/issues/184), [#186](https://github.com/wireviz/WireViz/pull/186))
|
||||
@ -34,6 +9,7 @@
|
||||
- The path specified with the `-o`/`--output-dir` option no longer includes the filename (without extension) of the generated files. Use the `-O`/`--output-name` option to specify a different filename for the generated files.
|
||||
- The `.gv` file is no longer included as a default output format (only as an intermediate file during processing) unless specified with the new `-f` option described below.
|
||||
|
||||
|
||||
### New features
|
||||
|
||||
- Allow mates between connectors ([#134](https://github.com/wireviz/WireViz/issues/134), [#186](https://github.com/wireviz/WireViz/pull/186))
|
||||
@ -49,89 +25,91 @@
|
||||
- Minor adjustments ([#256](https://github.com/wireviz/WireViz/pull/256))
|
||||
|
||||
|
||||
## [0.3.2](https://github.com/wireviz/WireViz/tree/v0.3.2) (2021-11-27)
|
||||
## [0.3.2](https://github.com/formatc1702/WireViz/tree/v0.3.2) (2021-11-27)
|
||||
|
||||
### Hotfix
|
||||
|
||||
- Adjust GraphViz generation code for compatibility with v0.18 of the `graphviz` Python package ([#258](https://github.com/wireviz/WireViz/issues/258), [#261](https://github.com/wireviz/WireViz/pull/261))
|
||||
- Adjust GraphViz generation code for compatibility with v0.18 of the `graphviz` Python package ([#258](https://github.com/formatc1702/WireViz/issues/258), [#261](https://github.com/formatc1702/WireViz/pull/261))
|
||||
|
||||
|
||||
## [0.3.1](https://github.com/wireviz/WireViz/tree/v0.3.1) (2021-10-25)
|
||||
## [0.3.1](https://github.com/formatc1702/WireViz/tree/v0.3.1) (2021-10-25)
|
||||
|
||||
### Hotfix
|
||||
|
||||
- Assign generic harness title when using WireViz as a module and not specifying an output file name ([#253](https://github.com/wireviz/WireViz/issues/253), [#254](https://github.com/wireviz/WireViz/pull/254))
|
||||
- Assign generic harness title when using WireViz as a module and not specifying an output file name ([#253](https://github.com/formatc1702/WireViz/issues/253), [#254](https://github.com/formatc1702/WireViz/pull/254))
|
||||
|
||||
|
||||
## [0.3](https://github.com/wireviz/WireViz/tree/v0.3) (2021-10-11)
|
||||
## [0.3](https://github.com/formatc1702/WireViz/tree/v0.3) (2021-10-11)
|
||||
|
||||
### New features
|
||||
|
||||
- Allow referencing a cable's/bundle's wires by color or by label ([#70](https://github.com/wireviz/WireViz/issues/70), [#169](https://github.com/wireviz/WireViz/issues/169), [#193](https://github.com/wireviz/WireViz/issues/193), [#194](https://github.com/wireviz/WireViz/pull/194))
|
||||
- Allow additional BOM items within components ([#50](https://github.com/wireviz/WireViz/issues/50), [#115](https://github.com/wireviz/WireViz/pull/115))
|
||||
- Add support for length units in cables and wires ([#7](https://github.com/wireviz/WireViz/issues/7), [#196](https://github.com/wireviz/WireViz/pull/196) (with work from [#161](https://github.com/wireviz/WireViz/pull/161), [#162](https://github.com/wireviz/WireViz/pull/162), [#171](https://github.com/wireviz/WireViz/pull/171)), [#198](https://github.com/wireviz/WireViz/pull/198), [#205](https://github.com/wireviz/WireViz/issues/205). [#206](https://github.com/wireviz/WireViz/pull/206))
|
||||
- Add option to define connector pin colors ([#53](https://github.com/wireviz/WireViz/issues/53), [#141](https://github.com/wireviz/WireViz/pull/141))
|
||||
- Remove HTML links from the input attributes ([#164](https://github.com/wireviz/WireViz/pull/164))
|
||||
- Add harness metadata section ([#158](https://github.com/wireviz/WireViz/issues/158), [#214](https://github.com/wireviz/WireViz/pull/214))
|
||||
- Add support for supplier and supplier part number information ([#240](https://github.com/wireviz/WireViz/issues/240), [#241](https://github.com/wireviz/WireViz/pull/241/))
|
||||
- Add graph rendering options (background colors, fontname, color name display style, ...) ([#158](https://github.com/wireviz/WireViz/issues/158), [#214](https://github.com/wireviz/WireViz/pull/214))
|
||||
- Add support for background colors for cables and connectors, as well as for some individual cells ([#210](https://github.com/wireviz/WireViz/issues/210), [#219](https://github.com/wireviz/WireViz/pull/219))
|
||||
- Add optional tweaking of the .gv output ([#215](https://github.com/wireviz/WireViz/pull/215)) (experimental)
|
||||
- Allow referencing a cable's/bundle's wires by color or by label ([#70](https://github.com/formatc1702/WireViz/issues/70), [#169](https://github.com/formatc1702/WireViz/issues/169), [#193](https://github.com/formatc1702/WireViz/issues/193), [#194](https://github.com/formatc1702/WireViz/pull/194))
|
||||
- Allow additional BOM items within components ([#50](https://github.com/formatc1702/WireViz/issues/50), [#115](https://github.com/formatc1702/WireViz/pull/115))
|
||||
- Add support for length units in cables and wires ([#7](https://github.com/formatc1702/WireViz/issues/7), [#196](https://github.com/formatc1702/WireViz/pull/196) (with work from [#161](https://github.com/formatc1702/WireViz/pull/161), [#162](https://github.com/formatc1702/WireViz/pull/162), [#171](https://github.com/formatc1702/WireViz/pull/171)), [#198](https://github.com/formatc1702/WireViz/pull/198), [#205](https://github.com/formatc1702/WireViz/issues/205). [#206](https://github.com/formatc1702/WireViz/pull/206))
|
||||
- Add option to define connector pin colors ([#53](https://github.com/formatc1702/WireViz/issues/53), [#141](https://github.com/formatc1702/WireViz/pull/141))
|
||||
- Remove HTML links from the input attributes ([#164](https://github.com/formatc1702/WireViz/pull/164))
|
||||
- Add harness metadata section ([#158](https://github.com/formatc1702/WireViz/issues/158), [#214](https://github.com/formatc1702/WireViz/pull/214))
|
||||
- Add support for supplier and supplier part number information ([#240](https://github.com/formatc1702/WireViz/issues/240), [#241](https://github.com/formatc1702/WireViz/pull/241/))
|
||||
- Add graph rendering options (background colors, fontname, color name display style, ...) ([#158](https://github.com/formatc1702/WireViz/issues/158), [#214](https://github.com/formatc1702/WireViz/pull/214))
|
||||
- Add support for background colors for cables and connectors, as well as for some individual cells ([#210](https://github.com/formatc1702/WireViz/issues/210), [#219](https://github.com/formatc1702/WireViz/pull/219))
|
||||
- Add optional tweaking of the .gv output ([#215](https://github.com/formatc1702/WireViz/pull/215)) (experimental)
|
||||
|
||||
|
||||
### Misc. fixes
|
||||
|
||||
- Remove case-sensitivity issues with pin names and labels ([#160](https://github.com/wireviz/WireViz/issues/160), [#229](https://github.com/wireviz/WireViz/pull/229))
|
||||
- Improve type hinting ([#156](https://github.com/wireviz/WireViz/issues/156), [#163](https://github.com/wireviz/WireViz/pull/163))
|
||||
- Move BOM management and HTML functions to separate modules ([#151](https://github.com/wireviz/WireViz/issues/151), [#192](https://github.com/wireviz/WireViz/pull/192))
|
||||
- Simplify BOM code ([#197](https://github.com/wireviz/WireViz/pull/197))
|
||||
- Bug fixes ([#218](https://github.com/wireviz/WireViz/pull/218), [#221](https://github.com/wireviz/WireViz/pull/221))
|
||||
- Remove case-sensitivity issues with pin names and labels ([#160](https://github.com/formatc1702/WireViz/issues/160), [#229](https://github.com/formatc1702/WireViz/pull/229))
|
||||
- Improve type hinting ([#156](https://github.com/formatc1702/WireViz/issues/156), [#163](https://github.com/formatc1702/WireViz/pull/163))
|
||||
- Move BOM management and HTML functions to separate modules ([#151](https://github.com/formatc1702/WireViz/issues/151), [#192](https://github.com/formatc1702/WireViz/pull/192))
|
||||
- Simplify BOM code ([#197](https://github.com/formatc1702/WireViz/pull/197))
|
||||
- Bug fixes ([#218](https://github.com/formatc1702/WireViz/pull/218), [#221](https://github.com/formatc1702/WireViz/pull/221))
|
||||
|
||||
### Known issues
|
||||
|
||||
- Including images in the harness may lead to issues in the following cases: ([#189](https://github.com/wireviz/WireViz/pull/189), [#220](https://github.com/wireviz/WireViz/issues/220))
|
||||
- Including images in the harness may lead to issues in the following cases: ([#189](https://github.com/formatc1702/WireViz/pull/189), [#220](https://github.com/formatc1702/WireViz/issues/220))
|
||||
- When using the `-o`/`--output_file` CLI option, specifying an output path in a different directory from the input file
|
||||
- When using the `--prepend-file` CLI option, specifying a prepend file in a different directory from the mail input file
|
||||
|
||||
|
||||
## [0.2](https://github.com/wireviz/WireViz/tree/v0.2) (2020-10-17)
|
||||
## [0.2](https://github.com/formatc1702/WireViz/tree/v0.2) (2020-10-17)
|
||||
|
||||
### Backward incompatible changes
|
||||
|
||||
- Change names of connector attributes ([#77](https://github.com/wireviz/WireViz/issues/77), [#105](https://github.com/wireviz/WireViz/pull/105))
|
||||
- Change names of connector attributes ([#77](https://github.com/formatc1702/WireViz/issues/77), [#105](https://github.com/formatc1702/WireViz/pull/105))
|
||||
- `pinnumbers` is now `pins`
|
||||
- `pinout` is now `pinlabels`
|
||||
- Remove ferrules as a separate connector type ([#78](https://github.com/wireviz/WireViz/issues/78), [#102](https://github.com/wireviz/WireViz/pull/102))
|
||||
- Remove ferrules as a separate connector type ([#78](https://github.com/formatc1702/WireViz/issues/78), [#102](https://github.com/formatc1702/WireViz/pull/102))
|
||||
- Simple connectors like ferrules are now defined using the `style: simple` attribute
|
||||
- Change the way loops are defined ([#79](https://github.com/wireviz/WireViz/issues/79), [#75](https://github.com/wireviz/WireViz/pull/75))
|
||||
- Change the way loops are defined ([#79](https://github.com/formatc1702/WireViz/issues/79), [#75](https://github.com/formatc1702/WireViz/pull/75))
|
||||
- Wires looping between two pins of the same connector are now handled via the connector's `loops` attribute.
|
||||
|
||||
See the [syntax description](syntax.md) for details.
|
||||
|
||||
|
||||
### New features
|
||||
|
||||
- Add bidirectional AWG/mm2 conversion ([#40](https://github.com/wireviz/WireViz/issues/40), [#41](https://github.com/wireviz/WireViz/pull/41))
|
||||
- Add support for part numbers ([#11](https://github.com/wireviz/WireViz/pull/11), [#114](https://github.com/wireviz/WireViz/issues/114), [#121](https://github.com/wireviz/WireViz/pull/121))
|
||||
- Add support for multicolored wires ([#12](https://github.com/wireviz/WireViz/issues/12), [#17](https://github.com/wireviz/WireViz/pull/17), [#96](https://github.com/wireviz/WireViz/pull/96), [#131](https://github.com/wireviz/WireViz/issues/131), [#132](https://github.com/wireviz/WireViz/pull/132))
|
||||
- Add support for images ([#27](https://github.com/wireviz/WireViz/issues/27), [#153](https://github.com/wireviz/WireViz/pull/153))
|
||||
- Add ability to export data directly to other programs ([#55](https://github.com/wireviz/WireViz/pull/55))
|
||||
- Add support for line breaks in various fields ([#49](https://github.com/wireviz/WireViz/issues/49), [#64](https://github.com/wireviz/WireViz/pull/64))
|
||||
- Allow using connector pin names to define connections ([#72](https://github.com/wireviz/WireViz/issues/72), [#139](https://github.com/wireviz/WireViz/issues/139), [#140](https://github.com/wireviz/WireViz/pull/140))
|
||||
- Make defining connection sets easier and more flexible ([#67](https://github.com/wireviz/WireViz/issues/67), [#75](https://github.com/wireviz/WireViz/pull/75))
|
||||
- Add new command line options ([#167](https://github.com/wireviz/WireViz/issues/167), [#173](https://github.com/wireviz/WireViz/pull/173))
|
||||
- Add new features to `build_examples.py` ([#118](https://github.com/wireviz/WireViz/pull/118))
|
||||
- Add new colors ([#103](https://github.com/wireviz/WireViz/pull/103), [#113](https://github.com/wireviz/WireViz/pull/113), [#144](https://github.com/wireviz/WireViz/issues/144), [#145](https://github.com/wireviz/WireViz/pull/145))
|
||||
- Improve documentation ([#107](https://github.com/wireviz/WireViz/issues/107), [#111](https://github.com/wireviz/WireViz/pull/111))
|
||||
- Add bidirectional AWG/mm2 conversion ([#40](https://github.com/formatc1702/WireViz/issues/40), [#41](https://github.com/formatc1702/WireViz/pull/41))
|
||||
- Add support for part numbers ([#11](https://github.com/formatc1702/WireViz/pull/11), [#114](https://github.com/formatc1702/WireViz/issues/114), [#121](https://github.com/formatc1702/WireViz/pull/121))
|
||||
- Add support for multicolored wires ([#12](https://github.com/formatc1702/WireViz/issues/12), [#17](https://github.com/formatc1702/WireViz/pull/17), [#96](https://github.com/formatc1702/WireViz/pull/96), [#131](https://github.com/formatc1702/WireViz/issues/131), [#132](https://github.com/formatc1702/WireViz/pull/132))
|
||||
- Add support for images ([#27](https://github.com/formatc1702/WireViz/issues/27), [#153](https://github.com/formatc1702/WireViz/pull/153))
|
||||
- Add ability to export data directly to other programs ([#55](https://github.com/formatc1702/WireViz/pull/55))
|
||||
- Add support for line breaks in various fields ([#49](https://github.com/formatc1702/WireViz/issues/49), [#64](https://github.com/formatc1702/WireViz/pull/64))
|
||||
- Allow using connector pin names to define connections ([#72](https://github.com/formatc1702/WireViz/issues/72), [#139](https://github.com/formatc1702/WireViz/issues/139), [#140](https://github.com/formatc1702/WireViz/pull/140))
|
||||
- Make defining connection sets easier and more flexible ([#67](https://github.com/formatc1702/WireViz/issues/67), [#75](https://github.com/formatc1702/WireViz/pull/75))
|
||||
- Add new command line options ([#167](https://github.com/formatc1702/WireViz/issues/167), [#173](https://github.com/formatc1702/WireViz/pull/173))
|
||||
- Add new features to `build_examples.py` ([#118](https://github.com/formatc1702/WireViz/pull/118))
|
||||
- Add new colors ([#103](https://github.com/formatc1702/WireViz/pull/103), [#113](https://github.com/formatc1702/WireViz/pull/113), [#144](https://github.com/formatc1702/WireViz/issues/144), [#145](https://github.com/formatc1702/WireViz/pull/145))
|
||||
- Improve documentation ([#107](https://github.com/formatc1702/WireViz/issues/107), [#111](https://github.com/formatc1702/WireViz/pull/111))
|
||||
|
||||
|
||||
### Misc. fixes
|
||||
|
||||
- Improve BOM generation
|
||||
- Add various input sanity checks
|
||||
- Improve HTML output ([#66](https://github.com/wireviz/WireViz/issues/66), [#136](https://github.com/wireviz/WireViz/pull/136), [#95](https://github.com/wireviz/WireViz/pull/95), [#177](https://github.com/wireviz/WireViz/pull/177))
|
||||
- Fix node rendering bug ([#69](https://github.com/wireviz/WireViz/issues/69), [#104](https://github.com/wireviz/WireViz/pull/104))
|
||||
- Improve shield rendering ([#125](https://github.com/wireviz/WireViz/issues/125), [#126](https://github.com/wireviz/WireViz/pull/126))
|
||||
- Add GitHub Linguist overrides ([#146](https://github.com/wireviz/WireViz/issues/146), [#154](https://github.com/wireviz/WireViz/pull/154))
|
||||
- Improve HTML output ([#66](https://github.com/formatc1702/WireViz/issues/66), [#136](https://github.com/formatc1702/WireViz/pull/136), [#95](https://github.com/formatc1702/WireViz/pull/95), [#177](https://github.com/formatc1702/WireViz/pull/177))
|
||||
- Fix node rendering bug ([#69](https://github.com/formatc1702/WireViz/issues/69), [#104](https://github.com/formatc1702/WireViz/pull/104))
|
||||
- Improve shield rendering ([#125](https://github.com/formatc1702/WireViz/issues/125), [#126](https://github.com/formatc1702/WireViz/pull/126))
|
||||
- Add GitHub Linguist overrides ([#146](https://github.com/formatc1702/WireViz/issues/146), [#154](https://github.com/formatc1702/WireViz/pull/154))
|
||||
|
||||
|
||||
## [0.1](https://github.com/wireviz/WireViz/tree/v0.1) (2020-06-29)
|
||||
## [0.1](https://github.com/formatc1702/WireViz/tree/v0.1) (2020-06-29)
|
||||
|
||||
- Initial release
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Contribution Guidelines
|
||||
|
||||
When contributing to this repository, please [submit a new issue](https://github.com/wireviz/WireViz/issues) first to discuss the proposed change, before submitting a pull request.
|
||||
When contributing to this repository, please [submit a new issue](https://github.com/formatc1702/WireViz/issues) first to discuss the proposed change, before submitting a pull request.
|
||||
|
||||
## Submitting a new Issue
|
||||
|
||||
@ -27,7 +27,7 @@ When contributing to this repository, please [submit a new issue](https://github
|
||||
1. Push the changes to your fork.
|
||||
1. Please format your code using [`isort`](https://pycqa.github.io/isort/) and [`black`](https://black.readthedocs.io) before submitting.
|
||||
1. Submit a new pull request, using `dev` as the base branch.
|
||||
- If your code changes or extends the WireViz YAML syntax, be sure to update the [syntax description document](https://github.com/wireviz/WireViz/blob/dev/docs/syntax.md) in your PR.
|
||||
- If your code changes or extends the WireViz YAML syntax, be sure to update the [syntax description document](https://github.com/formatc1702/WireViz/blob/dev/docs/syntax.md) in your PR.
|
||||
1. Please include in the PR description (and optionally also in the commit message body) a reference (# followed by issue number) to the issue where the suggested changes are discussed.
|
||||
|
||||
### Hints
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
<!--
|
||||
The following text is taken from #118
|
||||
https://github.com/wireviz/WireViz/pull/118
|
||||
https://github.com/formatc1702/WireViz/pull/118
|
||||
|
||||
TODO: write a better explaination -->
|
||||
|
||||
|
||||
@ -85,6 +85,10 @@ tweak: # optional tweaking of .gv output
|
||||
# loops
|
||||
loops: <List> # every list item is itself a list of exactly two pins
|
||||
# on the connector that are to be shorted
|
||||
|
||||
# optional tweaking of .gv output executed for each instance of this connector
|
||||
tweak: # see below
|
||||
|
||||
```
|
||||
|
||||
## Cable attributes
|
||||
@ -148,6 +152,9 @@ tweak: # optional tweaking of .gv output
|
||||
show_wirecount: <bool> # defaults to true
|
||||
show_wirenumbers: <bool> # defaults to true for cables; false for bundles
|
||||
|
||||
# optional tweaking of .gv output executed for each instance of this cable
|
||||
tweak: # see below
|
||||
|
||||
```
|
||||
|
||||
## Connection sets
|
||||
@ -355,7 +362,6 @@ If any component is defined in the `connectors` or `cables` sections but not ref
|
||||
# If no value is specified for 'title', then the
|
||||
# output filename without extension is used.
|
||||
```
|
||||
See [HTML Output Templates](../src/wireviz/templates/) for how metadata entries can be inserted into the HTML output.
|
||||
|
||||
## Options
|
||||
|
||||
@ -452,6 +458,13 @@ Alternatively items can be added to just the BOM by putting them in the section
|
||||
# This feature is experimental and might change
|
||||
# or be removed in future versions.
|
||||
|
||||
placeholder: <str> # Substring to be replaced with node name
|
||||
# An empty string as placeholder disable replacements.
|
||||
# When placeholder is absent, the global placeholder is used.
|
||||
# For tweak sections in connectors and cables, all substrings
|
||||
# matching the placeholder text will be replaced with the name
|
||||
# of connector/cable in all override and append entries.
|
||||
|
||||
override: # dict of .gv entries to override
|
||||
# Each entry is identified by its leading string
|
||||
# in lines beginning with a TAB character.
|
||||
|
||||
4
examples/demo01.gv
generated
4
examples/demo01.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/demo01.html
generated
2
examples/demo01.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>demo01</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/demo02.gv
generated
4
examples/demo02.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/demo02.html
generated
2
examples/demo02.html
generated
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>WireViz Demo 2</title>
|
||||
<style>
|
||||
body {
|
||||
|
||||
4
examples/ex01.gv
generated
4
examples/ex01.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex01.html
generated
2
examples/ex01.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex01</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/ex02.gv
generated
4
examples/ex02.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex02.html
generated
2
examples/ex02.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex02</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/ex03.gv
generated
4
examples/ex03.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex03.html
generated
2
examples/ex03.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex03</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/ex04.gv
generated
4
examples/ex04.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex04.html
generated
2
examples/ex04.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex04</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/ex05.gv
generated
4
examples/ex05.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex05.html
generated
2
examples/ex05.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex05</title>
|
||||
<style>
|
||||
|
||||
|
||||
8
examples/ex06.bom.tsv
generated
8
examples/ex06.bom.tsv
generated
@ -1,6 +1,6 @@
|
||||
Id Description Qty Unit Designators
|
||||
1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6
|
||||
2 Wire, 0.25 mm², PK 1 m W1, W2, W3, W4, W5
|
||||
3 Wire, 0.25 mm², TQ 1 m W1, W2, W3, W4, W5
|
||||
4 Wire, 0.25 mm², VT 1 m W1, W2, W3, W4, W5
|
||||
5 Wire, 0.25 mm², YE 1 m W1, W2, W3, W4, W5
|
||||
2 Wire, 0.25 mm², PK 1.0 m W1, W2, W3, W4, W5
|
||||
3 Wire, 0.25 mm², TQ 1.0 m W1, W2, W3, W4, W5
|
||||
4 Wire, 0.25 mm², VT 1.0 m W1, W2, W3, W4, W5
|
||||
5 Wire, 0.25 mm², YE 1.0 m W1, W2, W3, W4, W5
|
||||
|
||||
|
4
examples/ex06.gv
generated
4
examples/ex06.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
10
examples/ex06.html
generated
10
examples/ex06.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex06</title>
|
||||
<style>
|
||||
|
||||
@ -716,28 +716,28 @@
|
||||
<tr>
|
||||
<td class="bom_col_id">2</td>
|
||||
<td class="bom_col_description">Wire, 0.25 mm², PK</td>
|
||||
<td class="bom_col_qty">1</td>
|
||||
<td class="bom_col_qty">1.0</td>
|
||||
<td class="bom_col_unit">m</td>
|
||||
<td class="bom_col_designators">W1, W2, W3, W4, W5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="bom_col_id">3</td>
|
||||
<td class="bom_col_description">Wire, 0.25 mm², TQ</td>
|
||||
<td class="bom_col_qty">1</td>
|
||||
<td class="bom_col_qty">1.0</td>
|
||||
<td class="bom_col_unit">m</td>
|
||||
<td class="bom_col_designators">W1, W2, W3, W4, W5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="bom_col_id">4</td>
|
||||
<td class="bom_col_description">Wire, 0.25 mm², VT</td>
|
||||
<td class="bom_col_qty">1</td>
|
||||
<td class="bom_col_qty">1.0</td>
|
||||
<td class="bom_col_unit">m</td>
|
||||
<td class="bom_col_designators">W1, W2, W3, W4, W5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="bom_col_id">5</td>
|
||||
<td class="bom_col_description">Wire, 0.25 mm², YE</td>
|
||||
<td class="bom_col_qty">1</td>
|
||||
<td class="bom_col_qty">1.0</td>
|
||||
<td class="bom_col_unit">m</td>
|
||||
<td class="bom_col_designators">W1, W2, W3, W4, W5</td>
|
||||
</tr>
|
||||
|
||||
4
examples/ex07.gv
generated
4
examples/ex07.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex07.html
generated
2
examples/ex07.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex07</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/ex08.gv
generated
4
examples/ex08.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex08.html
generated
2
examples/ex08.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex08</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/ex09.gv
generated
4
examples/ex09.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex09.html
generated
2
examples/ex09.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex09</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/ex10.gv
generated
4
examples/ex10.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex10.html
generated
2
examples/ex10.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex10</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/ex11.gv
generated
4
examples/ex11.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex11.html
generated
2
examples/ex11.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex11</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/ex12.gv
generated
4
examples/ex12.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex12.html
generated
2
examples/ex12.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex12</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/ex13.gv
generated
4
examples/ex13.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex13.html
generated
2
examples/ex13.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex13</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
examples/ex14.gv
generated
4
examples/ex14.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
examples/ex14.html
generated
2
examples/ex14.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>ex14</title>
|
||||
<style>
|
||||
|
||||
|
||||
5
setup.py
5
setup.py
@ -27,7 +27,6 @@ setup(
|
||||
keywords="cable connector hardware harness wiring wiring-diagram wiring-harness",
|
||||
url=APP_URL,
|
||||
package_dir={"": "src"},
|
||||
package_data={CMD_NAME: ["templates/*.html"]},
|
||||
packages=find_packages("src"),
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
@ -40,6 +39,10 @@ setup(
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Topic :: Utilities",
|
||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
||||
],
|
||||
|
||||
@ -72,6 +72,7 @@ class Options:
|
||||
|
||||
@dataclass
|
||||
class Tweak:
|
||||
placeholder: Optional[PlainText] = None
|
||||
override: Optional[Dict[Designator, Dict[str, Optional[str]]]] = None
|
||||
append: Union[str, List[str], None] = None
|
||||
|
||||
@ -91,6 +92,7 @@ class Image:
|
||||
# See also HTML doc at https://graphviz.org/doc/info/shapes.html#html
|
||||
|
||||
def __post_init__(self):
|
||||
|
||||
if self.fixedsize is None:
|
||||
# Default True if any dimension specified unless self.scale also is specified.
|
||||
self.fixedsize = (self.width or self.height) and self.scale is None
|
||||
@ -163,10 +165,14 @@ class Connector:
|
||||
loops: List[List[Pin]] = field(default_factory=list)
|
||||
ignore_in_bom: bool = False
|
||||
additional_components: List[AdditionalComponent] = field(default_factory=list)
|
||||
tweak: Optional[Tweak] = None
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
|
||||
if isinstance(self.image, dict):
|
||||
self.image = Image(**self.image)
|
||||
if self.tweak is not None:
|
||||
self.tweak = Tweak(**self.tweak)
|
||||
|
||||
self.ports_left = False
|
||||
self.ports_right = False
|
||||
@ -272,10 +278,14 @@ class Cable:
|
||||
show_wirenumbers: Optional[bool] = None
|
||||
ignore_in_bom: bool = False
|
||||
additional_components: List[AdditionalComponent] = field(default_factory=list)
|
||||
tweak: Optional[Tweak] = None
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
|
||||
if isinstance(self.image, dict):
|
||||
self.image = Image(**self.image)
|
||||
if self.tweak is not None:
|
||||
self.tweak = Tweak(**self.tweak)
|
||||
|
||||
if isinstance(self.gauge, str): # gauge and unit specified
|
||||
try:
|
||||
@ -383,6 +393,7 @@ class Cable:
|
||||
to_name: Optional[Designator],
|
||||
to_pin: NoneOrMorePinIndices,
|
||||
) -> None:
|
||||
|
||||
from_pin = int2tuple(from_pin)
|
||||
via_wire = int2tuple(via_wire)
|
||||
to_pin = int2tuple(to_pin)
|
||||
|
||||
@ -8,6 +8,7 @@ from pathlib import Path
|
||||
from typing import Any, List, Union
|
||||
|
||||
from graphviz import Graph
|
||||
|
||||
from wireviz import APP_NAME, APP_URL, __version__, wv_colors
|
||||
from wireviz.DataClasses import (
|
||||
Cable,
|
||||
@ -19,7 +20,7 @@ from wireviz.DataClasses import (
|
||||
Side,
|
||||
Tweak,
|
||||
)
|
||||
from wireviz.svgembed import embed_svg_images, embed_svg_images_file
|
||||
from wireviz.svgembed import embed_svg_images_file
|
||||
from wireviz.wv_bom import (
|
||||
HEADER_MPN,
|
||||
HEADER_PN,
|
||||
@ -28,6 +29,7 @@ from wireviz.wv_bom import (
|
||||
component_table_entry,
|
||||
generate_bom,
|
||||
get_additional_component_table,
|
||||
make_list,
|
||||
pn_info_string,
|
||||
)
|
||||
from wireviz.wv_colors import get_color_hex, translate_color
|
||||
@ -43,10 +45,11 @@ from wireviz.wv_gv_html import (
|
||||
)
|
||||
from wireviz.wv_helper import (
|
||||
awg_equiv,
|
||||
file_write_text,
|
||||
flatten2d,
|
||||
is_arrow,
|
||||
mm2_equiv,
|
||||
open_file_read,
|
||||
open_file_write,
|
||||
tuplelist2tsv,
|
||||
)
|
||||
from wireviz.wv_html import generate_html_output
|
||||
@ -57,14 +60,12 @@ OLD_CONNECTOR_ATTR = {
|
||||
"autogenerate": "is replaced with new syntax in v0.4",
|
||||
}
|
||||
|
||||
|
||||
def check_old(node: str, old_attr: dict, args: dict) -> None:
|
||||
"""Raise exception for any outdated attributes in args."""
|
||||
for attr, descr in old_attr.items():
|
||||
if attr in args:
|
||||
raise ValueError(f"'{attr}' in {node}: '{attr}' {descr}")
|
||||
|
||||
|
||||
@dataclass
|
||||
class Harness:
|
||||
metadata: Metadata
|
||||
@ -78,12 +79,42 @@ class Harness:
|
||||
self._bom = [] # Internal Cache for generated bom
|
||||
self.additional_bom_items = []
|
||||
|
||||
def extend_tweak(self, node: Union[Connector, Cable]) -> None:
|
||||
"""Extend self.tweak with node.tweak after replacing placeholders."""
|
||||
if node.tweak:
|
||||
ph = node.tweak.placeholder
|
||||
# An empty string is a legal value to avoid the global placeholder
|
||||
if ph is None: # This must therefore be a test for None!
|
||||
ph = self.tweak.placeholder # Use the global placeholder
|
||||
# Create function rph() to replace any placeholder with node name
|
||||
rph = (lambda s: s.replace(ph, node.name)) if ph else lambda s: s
|
||||
n_override = node.tweak.override or {}
|
||||
s_override = self.tweak.override or {}
|
||||
for id, n_dict in n_override.items():
|
||||
id = rph(id)
|
||||
s_dict = s_override.get(id, {})
|
||||
for k, v in n_dict.items():
|
||||
k, v = rph(k), rph(v)
|
||||
if k in s_dict and v != s_dict[k]:
|
||||
raise ValueError(
|
||||
f"{node.name}.tweak.override.{id}.{k} conflicts with another"
|
||||
)
|
||||
s_dict[k] = v
|
||||
s_override[id] = s_dict or None # Will never be None?
|
||||
self.tweak.override = s_override or None
|
||||
self.tweak.append = (
|
||||
make_list(self.tweak.append)
|
||||
+ [rph(v) for v in make_list(node.tweak.append)]
|
||||
) or None
|
||||
|
||||
def add_connector(self, name: str, *args, **kwargs) -> None:
|
||||
check_old(f"Connector '{name}'", OLD_CONNECTOR_ATTR, kwargs)
|
||||
self.connectors[name] = Connector(name, *args, **kwargs)
|
||||
self.extend_tweak(self.connectors[name])
|
||||
|
||||
def add_cable(self, name: str, *args, **kwargs) -> None:
|
||||
self.cables[name] = Cable(name, *args, **kwargs)
|
||||
self.extend_tweak(self.cables[name])
|
||||
|
||||
def add_mate_pin(self, from_name, from_pin, to_name, to_pin, arrow_type) -> None:
|
||||
self.mates.append(MatePin(from_name, from_pin, to_name, to_pin, arrow_type))
|
||||
@ -172,7 +203,7 @@ class Harness:
|
||||
bgcolor=wv_colors.translate_color(self.options.bgcolor, "HEX"),
|
||||
nodesep="0.33",
|
||||
fontname=self.options.fontname,
|
||||
) # TODO: Add graph attribute: charset="utf-8",
|
||||
)
|
||||
dot.attr(
|
||||
"node",
|
||||
shape="none",
|
||||
@ -186,6 +217,7 @@ class Harness:
|
||||
dot.attr("edge", style="bold", fontname=self.options.fontname)
|
||||
|
||||
for connector in self.connectors.values():
|
||||
|
||||
# If no wires connected (except maybe loop wires)?
|
||||
if not (connector.ports_left or connector.ports_right):
|
||||
connector.ports_left = True # Use left side pins.
|
||||
@ -252,9 +284,6 @@ class Harness:
|
||||
|
||||
pinhtml.append(" </table>")
|
||||
|
||||
if len(pinhtml) == 2: # Table start and end with no rows between?
|
||||
pinhtml = ["<!-- all pins hidden -->"] # Avoid Graphviz error
|
||||
|
||||
html = [
|
||||
row.replace("<!-- connector table -->", "\n".join(pinhtml))
|
||||
for row in html
|
||||
@ -283,7 +312,6 @@ class Harness:
|
||||
dot.edge(
|
||||
f"{connector.name}:p{loop[0]}{loop_side}:{loop_dir}",
|
||||
f"{connector.name}:p{loop[1]}{loop_side}:{loop_dir}",
|
||||
label=" ", # Work-around to avoid over-sized loops.
|
||||
)
|
||||
|
||||
# determine if there are double- or triple-colored wires in the harness;
|
||||
@ -295,6 +323,7 @@ class Harness:
|
||||
)
|
||||
|
||||
for cable in self.cables.values():
|
||||
|
||||
html = []
|
||||
|
||||
awg_fmt = ""
|
||||
@ -532,38 +561,6 @@ class Harness:
|
||||
fillcolor=translate_color(bgcolor, "HEX"),
|
||||
)
|
||||
|
||||
# mates
|
||||
for mate in self.mates:
|
||||
if mate.shape[-1] == ">":
|
||||
dir = "both" if mate.shape[0] == "<" else "forward"
|
||||
else:
|
||||
dir = "back" if mate.shape[0] == "<" else "none"
|
||||
|
||||
if isinstance(mate, MatePin):
|
||||
color = "#000000"
|
||||
elif isinstance(mate, MateComponent):
|
||||
color = "#000000:#000000"
|
||||
else:
|
||||
raise Exception(f"{mate} is an unknown mate")
|
||||
|
||||
from_connector = self.connectors[mate.from_name]
|
||||
to_connector = self.connectors[mate.to_name]
|
||||
if isinstance(mate, MatePin) and from_connector.style != "simple":
|
||||
from_pin_index = from_connector.pins.index(mate.from_pin)
|
||||
from_port_str = f":p{from_pin_index+1}r"
|
||||
else: # MateComponent or style == 'simple'
|
||||
from_port_str = ""
|
||||
if isinstance(mate, MatePin) and to_connector.style != "simple":
|
||||
to_pin_index = to_connector.pins.index(mate.to_pin)
|
||||
to_port_str = f":p{to_pin_index+1}l"
|
||||
else: # MateComponent or style == 'simple'
|
||||
to_port_str = ""
|
||||
code_from = f"{mate.from_name}{from_port_str}:e"
|
||||
code_to = f"{mate.to_name}{to_port_str}:w"
|
||||
|
||||
dot.attr("edge", color=color, style="dashed", dir=dir)
|
||||
dot.edge(code_from, code_to)
|
||||
|
||||
def typecheck(name: str, value: Any, expect: type) -> None:
|
||||
if not isinstance(value, expect):
|
||||
raise Exception(
|
||||
@ -629,9 +626,51 @@ class Harness:
|
||||
typecheck("tweak.append", self.tweak.append, str)
|
||||
dot.body.append(self.tweak.append)
|
||||
|
||||
# Tweak processing above must be the last before returning dot.
|
||||
# Please don't insert any code that might change the dot contents
|
||||
# after tweak processing.
|
||||
for mate in self.mates:
|
||||
if mate.shape[0] == "<" and mate.shape[-1] == ">":
|
||||
dir = "both"
|
||||
elif mate.shape[0] == "<":
|
||||
dir = "back"
|
||||
elif mate.shape[-1] == ">":
|
||||
dir = "forward"
|
||||
else:
|
||||
dir = "none"
|
||||
|
||||
if isinstance(mate, MatePin):
|
||||
color = "#000000"
|
||||
elif isinstance(mate, MateComponent):
|
||||
color = "#000000:#000000"
|
||||
else:
|
||||
raise Exception(f"{mate} is an unknown mate")
|
||||
|
||||
from_connector = self.connectors[mate.from_name]
|
||||
if (
|
||||
isinstance(mate, MatePin)
|
||||
and self.connectors[mate.from_name].style != "simple"
|
||||
):
|
||||
from_pin_index = from_connector.pins.index(mate.from_pin)
|
||||
from_port_str = f":p{from_pin_index+1}r"
|
||||
else: # MateComponent or style == 'simple'
|
||||
from_port_str = ""
|
||||
if (
|
||||
isinstance(mate, MatePin)
|
||||
and self.connectors[mate.to_name].style != "simple"
|
||||
):
|
||||
to_pin_index = to_connector.pins.index(mate.to_pin)
|
||||
to_port_str = (
|
||||
f":p{to_pin_index+1}l"
|
||||
if isinstance(mate, MatePin)
|
||||
and self.connectors[mate.to_name].style != "simple"
|
||||
else ""
|
||||
)
|
||||
else: # MateComponent or style == 'simple'
|
||||
to_port_str = ""
|
||||
code_from = f"{mate.from_name}{from_port_str}:e"
|
||||
to_connector = self.connectors[mate.to_name]
|
||||
code_to = f"{mate.to_name}{to_port_str}:w"
|
||||
|
||||
dot.attr("edge", color=color, style="dashed", dir=dir)
|
||||
dot.edge(code_from, code_to)
|
||||
|
||||
return dot
|
||||
|
||||
@ -656,7 +695,7 @@ class Harness:
|
||||
return data.read()
|
||||
|
||||
@property
|
||||
def svg(self): # TODO?: Verify xml encoding="utf-8" in SVG?
|
||||
def svg(self):
|
||||
graph = self.graph
|
||||
return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd())
|
||||
|
||||
@ -691,7 +730,7 @@ class Harness:
|
||||
# BOM output
|
||||
bomlist = bom_list(self.bom())
|
||||
if "tsv" in fmt:
|
||||
file_write_text(f"{filename}.bom.tsv", tuplelist2tsv(bomlist))
|
||||
open_file_write(f"{filename}.bom.tsv").write(tuplelist2tsv(bomlist))
|
||||
if "csv" in fmt:
|
||||
# TODO: implement CSV output (preferrably using CSV library)
|
||||
print("CSV output is not yet supported")
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Please don't import anything in this file to avoid issues when it is imported in setup.py
|
||||
|
||||
__version__ = "0.4.1"
|
||||
__version__ = "0.5-dev"
|
||||
|
||||
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/wireviz/WireViz"
|
||||
APP_URL = "https://github.com/formatc1702/WireViz"
|
||||
|
||||
@ -8,20 +8,6 @@ from typing import Union
|
||||
mime_subtype_replacements = {"jpg": "jpeg", "tif": "tiff"}
|
||||
|
||||
|
||||
# TODO: Share cache and code between data_URI_base64() and embed_svg_images()
|
||||
def data_URI_base64(file: Union[str, Path], media: str = "image") -> str:
|
||||
"""Return Base64-encoded data URI of input file."""
|
||||
file = Path(file)
|
||||
b64 = base64.b64encode(file.read_bytes()).decode("utf-8")
|
||||
uri = f"data:{media}/{get_mime_subtype(file)};base64, {b64}"
|
||||
# print(f"data_URI_base64('{file}', '{media}') -> {len(uri)}-character URI")
|
||||
if len(uri) > 65535:
|
||||
print(
|
||||
"data_URI_base64(): Warning: Browsers might have different URI length limitations"
|
||||
)
|
||||
return uri
|
||||
|
||||
|
||||
def embed_svg_images(svg_in: str, base_path: Union[str, Path] = Path.cwd()) -> str:
|
||||
images_b64 = {} # cache of base64-encoded images
|
||||
|
||||
@ -59,8 +45,8 @@ def embed_svg_images_file(
|
||||
) -> None:
|
||||
filename_in = Path(filename_in).resolve()
|
||||
filename_out = filename_in.with_suffix(".b64.svg")
|
||||
filename_out.write_text( # TODO?: Verify xml encoding="utf-8" in SVG?
|
||||
filename_out.write_text(
|
||||
embed_svg_images(filename_in.read_text(), filename_in.parent)
|
||||
) # TODO: Use encoding="utf-8" in both read_text() and write_text()
|
||||
)
|
||||
if overwrite:
|
||||
filename_out.replace(filename_in)
|
||||
|
||||
@ -1,52 +0,0 @@
|
||||
# HTML Output Templates
|
||||
|
||||
This is the standard folder where WireViz looks for an HTML output template file.
|
||||
|
||||
## Which HTML Output Template File is Used?
|
||||
|
||||
A named HTML output template can optionally be specified as
|
||||
`metadata.template.name` in the YAML input:
|
||||
```yaml
|
||||
metadata:
|
||||
template:
|
||||
name: din-6771
|
||||
```
|
||||
In the case above, WireViz will search for a template file named
|
||||
`din-6771.html` in these folders:
|
||||
1. In the same folder as the YAML input file.
|
||||
2. In this standard template folder.
|
||||
|
||||
If no HTML output template is specified, the `simple` template is assumed
|
||||
(i.e. filename `simple.html`, and in this case,
|
||||
only the standard template folder is searched).
|
||||
|
||||
## Placeholders in HTML Output Templates
|
||||
|
||||
HTML output template files might contain placeholders that will be replaced by
|
||||
generated text by WireViz when producing HTML output based on such a template.
|
||||
A placeholder starts with `<!-- %`, followed by a keyword, and finally `% -->`.
|
||||
Note that there must be one single space between `--` and `%` at both ends.
|
||||
|
||||
| Placeholder | Replaced by |
|
||||
| --- | --- |
|
||||
| `<!-- %generator% -->` | The application name, version, and URL |
|
||||
| `<!-- %fontname% -->` | The value of `options.fontname` |
|
||||
| `<!-- %bgcolor% -->` | The HEX color translation of `options.bgcolor` |
|
||||
| `<!-- %filename% -->` | The output path and filename without extension |
|
||||
| `<!-- %filename_stem% -->` | The output filename without path nor extension |
|
||||
| `<!-- %bom% -->` | BOM as HTML table with headers at top |
|
||||
| `<!-- %bom_reversed% -->` | Reversed BOM as HTML table with headers at bottom |
|
||||
| `<!-- %sheet_current% -->` | `1` (multi-page documents not yet supported) |
|
||||
| `<!-- %sheet_total% -->` | `1` (multi-page documents not yet supported) |
|
||||
| `<!-- %diagram% -->` | Embedded SVG diagram as valid HTML |
|
||||
| `<!-- %diagram_png_b64% -->` | Embedded base64 encoded PNG diagram as URI |
|
||||
| `<!-- %{item}% -->` | String or numeric value of `metadata.{item}` |
|
||||
| `<!-- %{item}_{i}% -->` | Category number `{i}` within dict value of `metadata.{item}` |
|
||||
| `<!-- %{item}_{i}_{key}% -->` | Value of `metadata.{item}.{category}.{key}` |
|
||||
| `<!-- %template_sheetsize% -->` | Value of `metadata.template.sheetsize` |
|
||||
|
||||
Note that `{item}`, `{category}` and `{key}` in the description above can be
|
||||
any valid YAML key, and `{i}` is an integer representing the 1-based index of
|
||||
category entries in a dict `metadata.{item}` entry.
|
||||
The `{` and `}` characters are not literally part of the syntax, just used in
|
||||
this documentation to enclose the variable parts of the keywords.
|
||||
2
src/wireviz/templates/din-6771.html
generated
2
src/wireviz/templates/din-6771.html
generated
@ -179,7 +179,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div id="frame" class="<!-- %template_sheetsize% -->">
|
||||
<div id="frame" class="sheetsize_default">
|
||||
|
||||
<div id="diagram">
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import platform
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Tuple, Union
|
||||
@ -15,14 +14,12 @@ from wireviz.DataClasses import Metadata, Options, Tweak
|
||||
from wireviz.Harness import Harness
|
||||
from wireviz.wv_helper import (
|
||||
expand,
|
||||
file_read_text,
|
||||
get_single_key_and_value,
|
||||
is_arrow,
|
||||
open_file_read,
|
||||
smart_file_resolve,
|
||||
)
|
||||
|
||||
from . import APP_NAME
|
||||
|
||||
|
||||
def parse(
|
||||
inp: Union[Path, str, Dict],
|
||||
@ -89,10 +86,6 @@ def parse(
|
||||
raise Exception("No output formats or return types specified")
|
||||
|
||||
yaml_data, yaml_file = _get_yaml_data_and_path(inp)
|
||||
if not isinstance(yaml_data, dict):
|
||||
raise TypeError(
|
||||
f"Expected a dict as top-level YAML input, but got: {type(yaml_data)}"
|
||||
)
|
||||
if output_formats:
|
||||
# need to write data to file, determine output directory and filename
|
||||
output_dir = _get_output_dir(yaml_file, output_dir)
|
||||
@ -124,7 +117,9 @@ def parse(
|
||||
|
||||
# When title is not given, either deduce it from filename, or use default text.
|
||||
if "title" not in harness.metadata:
|
||||
harness.metadata["title"] = output_name or f"{APP_NAME} diagram and BOM"
|
||||
harness.metadata["title"] = (
|
||||
Path(yaml_file).stem if yaml_file else "WireViz diagram and BOM"
|
||||
)
|
||||
|
||||
# add items
|
||||
# parse YAML input file ====================================================
|
||||
@ -408,21 +403,14 @@ def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path):
|
||||
try:
|
||||
yaml_path = Path(inp).expanduser().resolve(strict=True)
|
||||
# if no FileNotFoundError exception happens, get file contents
|
||||
yaml_str = file_read_text(yaml_path)
|
||||
except (FileNotFoundError, OSError, ValueError) as e:
|
||||
# if inp is a long YAML string, Pathlib will normally raise
|
||||
# FileNotFoundError or OSError(errno = ENAMETOOLONG) when
|
||||
# trying to expand and resolve it as a path, but in Windows
|
||||
# might ValueError or OSError(errno = EINVAL or None) be raised
|
||||
# instead in some cases (depending on the Python version).
|
||||
# Catch these specific errors, but raise any others.
|
||||
yaml_str = open_file_read(yaml_path).read()
|
||||
except (FileNotFoundError, OSError) as e:
|
||||
# if inp is a long YAML string, Pathlib will raise OSError: [errno.ENAMETOOLONG]
|
||||
# when trying to expand and resolve it as a path.
|
||||
# Catch this error, but raise any others
|
||||
from errno import ENAMETOOLONG
|
||||
|
||||
from errno import EINVAL, ENAMETOOLONG
|
||||
|
||||
if type(e) is OSError and e.errno not in (EINVAL, ENAMETOOLONG, None):
|
||||
print(
|
||||
f"OSError(errno={e.errno}) in Python {sys.version} at {platform.platform()}"
|
||||
)
|
||||
if type(e) is OSError and e.errno != ENAMETOOLONG:
|
||||
raise e
|
||||
# file does not exist; assume inp is a YAML string
|
||||
yaml_str = inp
|
||||
|
||||
@ -204,9 +204,7 @@ def generate_bom(harness: "Harness") -> List[BOMEntry]:
|
||||
bom.append(
|
||||
{
|
||||
**group_entries[0],
|
||||
"qty": int(total_qty)
|
||||
if float(total_qty).is_integer()
|
||||
else round(total_qty, 3),
|
||||
"qty": round(total_qty, 3),
|
||||
"designators": sorted(set(designators)),
|
||||
}
|
||||
)
|
||||
|
||||
@ -11,7 +11,7 @@ if __name__ == "__main__":
|
||||
|
||||
import wireviz.wireviz as wv
|
||||
from wireviz import APP_NAME, __version__
|
||||
from wireviz.wv_helper import file_read_text
|
||||
from wireviz.wv_helper import open_file_read
|
||||
|
||||
format_codes = {
|
||||
# "c": "csv",
|
||||
@ -111,7 +111,7 @@ def wireviz(file, format, prepend, output_dir, output_name, version):
|
||||
raise Exception(f"File does not exist:\n{prepend_file}")
|
||||
print("Prepend file:", prepend_file)
|
||||
|
||||
prepend_input += file_read_text(prepend_file) + "\n"
|
||||
prepend_input += open_file_read(prepend_file).read() + "\n"
|
||||
else:
|
||||
prepend_input = ""
|
||||
|
||||
@ -130,7 +130,7 @@ def wireviz(file, format, prepend, output_dir, output_name, version):
|
||||
"Output file: ", f"{Path(_output_dir / _output_name)}.{output_formats_str}"
|
||||
)
|
||||
|
||||
yaml_input = file_read_text(file)
|
||||
yaml_input = open_file_read(file).read()
|
||||
file_dir = file.parent
|
||||
|
||||
yaml_input = prepend_input + yaml_input
|
||||
|
||||
@ -113,31 +113,18 @@ def clean_whitespace(inp):
|
||||
|
||||
|
||||
def open_file_read(filename):
|
||||
"""Open utf-8 encoded text file for reading - remember closing it when finished"""
|
||||
# TODO: Intelligently determine encoding
|
||||
return open(filename, "r", encoding="UTF-8")
|
||||
|
||||
|
||||
def open_file_write(filename):
|
||||
"""Open utf-8 encoded text file for writing - remember closing it when finished"""
|
||||
return open(filename, "w", encoding="UTF-8")
|
||||
|
||||
|
||||
def open_file_append(filename):
|
||||
"""Open utf-8 encoded text file for appending - remember closing it when finished"""
|
||||
return open(filename, "a", encoding="UTF-8")
|
||||
|
||||
|
||||
def file_read_text(filename: str) -> str:
|
||||
"""Read utf-8 encoded text file, close it, and return the text"""
|
||||
return Path(filename).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def file_write_text(filename: str, text: str) -> int:
|
||||
"""Write utf-8 encoded text file, close it, and return the number of characters written"""
|
||||
return Path(filename).write_text(text, encoding="utf-8")
|
||||
|
||||
|
||||
def is_arrow(inp):
|
||||
"""
|
||||
Matches strings of one or multiple `-` or `=` (but not mixed)
|
||||
@ -157,7 +144,7 @@ def aspect_ratio(image_src):
|
||||
try:
|
||||
from PIL import Image
|
||||
|
||||
with Image.open(image_src) as image:
|
||||
image = Image.open(image_src)
|
||||
if image.width > 0 and image.height > 0:
|
||||
return image.width / image.height
|
||||
print(f"aspect_ratio(): Invalid image size {image.width} x {image.height}")
|
||||
|
||||
@ -2,16 +2,15 @@
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Callable, Dict, List, Union
|
||||
from typing import Dict, List, Union
|
||||
|
||||
from wireviz import APP_NAME, APP_URL, __version__, wv_colors
|
||||
from wireviz.DataClasses import Metadata, Options
|
||||
from wireviz.svgembed import data_URI_base64
|
||||
from wireviz.wv_gv_html import html_line_breaks
|
||||
from wireviz.wv_helper import (
|
||||
file_read_text,
|
||||
file_write_text,
|
||||
flatten2d,
|
||||
open_file_read,
|
||||
open_file_write,
|
||||
smart_file_resolve,
|
||||
)
|
||||
|
||||
@ -22,6 +21,7 @@ def generate_html_output(
|
||||
metadata: Metadata,
|
||||
options: Options,
|
||||
):
|
||||
|
||||
# load HTML template
|
||||
templatename = metadata.get("template", {}).get("name")
|
||||
if templatename:
|
||||
@ -34,14 +34,14 @@ def generate_html_output(
|
||||
# fall back to built-in simple template if no template was provided
|
||||
templatefile = Path(__file__).parent / "templates/simple.html"
|
||||
|
||||
html = file_read_text(templatefile) # TODO?: Warn if unexpected meta charset?
|
||||
html = open_file_read(templatefile).read()
|
||||
|
||||
# embed SVG diagram (only if used)
|
||||
def svgdata() -> str:
|
||||
return re.sub( # TODO?: Verify xml encoding="utf-8" in SVG?
|
||||
# embed SVG diagram
|
||||
with open_file_read(f"{filename}.tmp.svg") as file:
|
||||
svgdata = re.sub(
|
||||
"^<[?]xml [^?>]*[?]>[^<]*<!DOCTYPE [^>]*>",
|
||||
"<!-- XML and DOCTYPE declarations from SVG file removed -->",
|
||||
file_read_text(f"{filename}.tmp.svg"),
|
||||
file.read(),
|
||||
1,
|
||||
)
|
||||
|
||||
@ -80,27 +80,13 @@ def generate_html_output(
|
||||
"<!-- %generator% -->": f"{APP_NAME} {__version__} - {APP_URL}",
|
||||
"<!-- %fontname% -->": options.fontname,
|
||||
"<!-- %bgcolor% -->": wv_colors.translate_color(options.bgcolor, "hex"),
|
||||
"<!-- %filename% -->": str(filename),
|
||||
"<!-- %filename_stem% -->": Path(filename).stem,
|
||||
"<!-- %diagram% -->": svgdata,
|
||||
"<!-- %bom% -->": bom_html,
|
||||
"<!-- %bom_reversed% -->": bom_html_reversed,
|
||||
"<!-- %sheet_current% -->": "1", # TODO: handle multi-page documents
|
||||
"<!-- %sheet_total% -->": "1", # TODO: handle multi-page documents
|
||||
"<!-- %template_sheetsize% -->": metadata.get("template", {}).get(
|
||||
"sheetsize", ""
|
||||
),
|
||||
}
|
||||
|
||||
def replacement_if_used(key: str, func: Callable[[], str]) -> None:
|
||||
"""Append replacement only if used in html."""
|
||||
if key in html:
|
||||
replacements[key] = func()
|
||||
|
||||
replacement_if_used("<!-- %diagram% -->", svgdata)
|
||||
replacement_if_used(
|
||||
"<!-- %diagram_png_b64% -->", lambda: data_URI_base64(f"{filename}.png")
|
||||
)
|
||||
|
||||
# prepare metadata replacements
|
||||
if metadata:
|
||||
for item, contents in metadata.items():
|
||||
@ -111,11 +97,14 @@ def generate_html_output(
|
||||
if isinstance(entry, Dict):
|
||||
replacements[f"<!-- %{item}_{index+1}% -->"] = str(category)
|
||||
for entry_key, entry_value in entry.items():
|
||||
replacements[
|
||||
f"<!-- %{item}_{index+1}_{entry_key}% -->"
|
||||
] = html_line_breaks(str(entry_value))
|
||||
elif isinstance(entry, (str, int, float)):
|
||||
pass # TODO?: replacements[f"<!-- %{item}_{category}% -->"] = html_line_breaks(str(entry))
|
||||
replacements[f"<!-- %{item}_{index+1}_{entry_key}% -->"] = (
|
||||
html_line_breaks(str(entry_value))
|
||||
)
|
||||
|
||||
replacements['"sheetsize_default"'] = '"{}"'.format(
|
||||
metadata.get("template", {}).get("sheetsize", "")
|
||||
)
|
||||
# include quotes so no replacement happens within <style> definition
|
||||
|
||||
# perform replacements
|
||||
# regex replacement adapted from:
|
||||
@ -127,4 +116,4 @@ def generate_html_output(
|
||||
pattern = re.compile("|".join(replacements_escaped))
|
||||
html = pattern.sub(lambda match: replacements[match.group(0)], html)
|
||||
|
||||
file_write_text(f"{filename}.html", html)
|
||||
open_file_write(f"{filename}.html").write(html)
|
||||
|
||||
4
tutorial/tutorial01.gv
generated
4
tutorial/tutorial01.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
tutorial/tutorial01.html
generated
2
tutorial/tutorial01.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>tutorial01</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
tutorial/tutorial02.gv
generated
4
tutorial/tutorial02.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
tutorial/tutorial02.html
generated
2
tutorial/tutorial02.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>tutorial02</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
tutorial/tutorial03.gv
generated
4
tutorial/tutorial03.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
tutorial/tutorial03.html
generated
2
tutorial/tutorial03.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>tutorial03</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
tutorial/tutorial04.gv
generated
4
tutorial/tutorial04.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
tutorial/tutorial04.html
generated
2
tutorial/tutorial04.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>tutorial04</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
tutorial/tutorial05.gv
generated
4
tutorial/tutorial05.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
tutorial/tutorial05.html
generated
2
tutorial/tutorial05.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>tutorial05</title>
|
||||
<style>
|
||||
|
||||
|
||||
4
tutorial/tutorial06.gv
generated
4
tutorial/tutorial06.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
tutorial/tutorial06.html
generated
2
tutorial/tutorial06.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>tutorial06</title>
|
||||
<style>
|
||||
|
||||
|
||||
8
tutorial/tutorial07.bom.tsv
generated
8
tutorial/tutorial07.bom.tsv
generated
@ -1,6 +1,6 @@
|
||||
Id Description Qty Unit Designators
|
||||
1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6
|
||||
2 Wire, 0.25 mm², PK 1 m W1, W2, W3, W4, W5
|
||||
3 Wire, 0.25 mm², TQ 1 m W1, W2, W3, W4, W5
|
||||
4 Wire, 0.25 mm², VT 1 m W1, W2, W3, W4, W5
|
||||
5 Wire, 0.25 mm², YE 1 m W1, W2, W3, W4, W5
|
||||
2 Wire, 0.25 mm², PK 1.0 m W1, W2, W3, W4, W5
|
||||
3 Wire, 0.25 mm², TQ 1.0 m W1, W2, W3, W4, W5
|
||||
4 Wire, 0.25 mm², VT 1.0 m W1, W2, W3, W4, W5
|
||||
5 Wire, 0.25 mm², YE 1.0 m W1, W2, W3, W4, W5
|
||||
|
||||
|
4
tutorial/tutorial07.gv
generated
4
tutorial/tutorial07.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
10
tutorial/tutorial07.html
generated
10
tutorial/tutorial07.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>tutorial07</title>
|
||||
<style>
|
||||
|
||||
@ -716,28 +716,28 @@
|
||||
<tr>
|
||||
<td class="bom_col_id">2</td>
|
||||
<td class="bom_col_description">Wire, 0.25 mm², PK</td>
|
||||
<td class="bom_col_qty">1</td>
|
||||
<td class="bom_col_qty">1.0</td>
|
||||
<td class="bom_col_unit">m</td>
|
||||
<td class="bom_col_designators">W1, W2, W3, W4, W5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="bom_col_id">3</td>
|
||||
<td class="bom_col_description">Wire, 0.25 mm², TQ</td>
|
||||
<td class="bom_col_qty">1</td>
|
||||
<td class="bom_col_qty">1.0</td>
|
||||
<td class="bom_col_unit">m</td>
|
||||
<td class="bom_col_designators">W1, W2, W3, W4, W5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="bom_col_id">4</td>
|
||||
<td class="bom_col_description">Wire, 0.25 mm², VT</td>
|
||||
<td class="bom_col_qty">1</td>
|
||||
<td class="bom_col_qty">1.0</td>
|
||||
<td class="bom_col_unit">m</td>
|
||||
<td class="bom_col_designators">W1, W2, W3, W4, W5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="bom_col_id">5</td>
|
||||
<td class="bom_col_description">Wire, 0.25 mm², YE</td>
|
||||
<td class="bom_col_qty">1</td>
|
||||
<td class="bom_col_qty">1.0</td>
|
||||
<td class="bom_col_unit">m</td>
|
||||
<td class="bom_col_designators">W1, W2, W3, W4, W5</td>
|
||||
</tr>
|
||||
|
||||
4
tutorial/tutorial08.gv
generated
4
tutorial/tutorial08.gv
generated
@ -1,6 +1,6 @@
|
||||
graph {
|
||||
// Graph generated by WireViz 0.4.1
|
||||
// https://github.com/wireviz/WireViz
|
||||
// Graph generated by WireViz 0.4
|
||||
// https://github.com/formatc1702/WireViz
|
||||
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
|
||||
node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
|
||||
edge [fontname=arial style=bold]
|
||||
|
||||
2
tutorial/tutorial08.html
generated
2
tutorial/tutorial08.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="generator" content="WireViz 0.4.1 - https://github.com/wireviz/WireViz">
|
||||
<meta name="generator" content="WireViz 0.4 - https://github.com/formatc1702/WireViz">
|
||||
<title>tutorial08</title>
|
||||
<style>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user