Compare commits

..

13 Commits

Author SHA1 Message Date
KV
78434969cd Add optional tweak per node with name placeholder
Implements feature suggested in #349
2025-02-16 22:30:09 +01:00
KV
7cf9244af1 Update setup.py with all tested python versions (#442) 2025-01-27 19:26:58 +01:00
KV
6c87c27cfc Use ubuntu-latest for the supported Python versions (#442)
Use ubuntu-22.04 only for Python 3.7-3.8
by including them separately into the matrix.
2025-01-27 19:26:58 +01:00
Martin Rieder
336bea8b0d Update deprecated GitHub Actions and add Python versions (#408)
Running 6 different Python versions (3.7 to 3.12) in parallel now.
NOTE: This is in conflict with #309, but can be resolved easily in a later PR.

GitHub Actions require an update:
- actions/upload-artifact@v3 is scheduled for deprecation on November
30, 2024.
- Similarly, v1/v2 are scheduled for deprecation on June 30, 2024. 
- Updating this comes with a breaking change in upload-artifact@v4:

Uploading to the same named Artifact multiple times.

Due to how Artifacts are created in this new version, it is no longer
possible to upload to the same named Artifact multiple times. You must
either split the uploads into multiple Artifacts with different names,
or only upload once. Otherwise you will encounter an error.

The artifact .zip files therefore have the python version added to
their name.
2025-01-12 19:38:50 +01:00
Daniel Rojas
590504130c Add documentation on template separator character 2024-06-07 17:06:36 +02:00
Daniel Rojas
a3281b07a2 Add v0.4 release date 2024-05-19 14:48:03 +02:00
KV
b85bd0cd0a Add check for outdated connector attributes 2024-05-19 14:48:03 +02:00
Daniel Rojas
81ed3fa12b Remove references for unsupported output formats
Remove the references in the CLI help, but keep the placeholders elsewhere in the code as a TODO
2024-05-19 14:48:03 +02:00
Daniel Rojas
8e3014911a Apply suggestions from code review
Co-authored-by: kvid <kvid@users.noreply.github.com>
2024-05-19 14:48:03 +02:00
Daniel Rojas
684f6f0064 Apply black 2024-05-19 14:48:03 +02:00
Daniel Rojas
0c73e57267 Rebuild examples 2024-05-19 14:48:03 +02:00
Andreas Motl
49c7685bb2 Improve gracefulness when invoking wireviz.parse() without file_out
This happened to be a regression for WireViz-Web [1], which aims to do
as much in memory as possible.

[1] https://github.com/daq-tools/wireviz-web.

kvid rebased and mixed original commit with similar change by Daniel Rojas

Co-authored-by: kvid <kvid@users.noreply.github.com>
2024-05-19 14:46:46 +02:00
Daniel Rojas
d680361556 Bump version to 0.5-dev 2024-04-16 14:08:33 +02:00
66 changed files with 295 additions and 355 deletions

View File

@ -1,31 +1,6 @@
# Change Log # Change Log
## [0.4.1] (2024-07-13) ## [0.4](https://github.com/formatc1702/WireViz/tree/v0.4) (2024-05-12)
### 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)
### Backward-incompatible changes ### Backward-incompatible changes
- New syntax for autogenerated components ([#184](https://github.com/wireviz/WireViz/issues/184), [#186](https://github.com/wireviz/WireViz/pull/186)) - 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 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. - 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 ### New features
- Allow mates between connectors ([#134](https://github.com/wireviz/WireViz/issues/134), [#186](https://github.com/wireviz/WireViz/pull/186)) - 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)) - 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 ### 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 ### 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 ### 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 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/wireviz/WireViz/issues/50), [#115](https://github.com/wireviz/WireViz/pull/115)) - 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/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 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/wireviz/WireViz/issues/53), [#141](https://github.com/wireviz/WireViz/pull/141)) - 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/wireviz/WireViz/pull/164)) - Remove HTML links from the input attributes ([#164](https://github.com/formatc1702/WireViz/pull/164))
- Add harness metadata section ([#158](https://github.com/wireviz/WireViz/issues/158), [#214](https://github.com/wireviz/WireViz/pull/214)) - 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/wireviz/WireViz/issues/240), [#241](https://github.com/wireviz/WireViz/pull/241/)) - 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/wireviz/WireViz/issues/158), [#214](https://github.com/wireviz/WireViz/pull/214)) - 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/wireviz/WireViz/issues/210), [#219](https://github.com/wireviz/WireViz/pull/219)) - 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/wireviz/WireViz/pull/215)) (experimental) - Add optional tweaking of the .gv output ([#215](https://github.com/formatc1702/WireViz/pull/215)) (experimental)
### Misc. fixes ### 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)) - 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/wireviz/WireViz/issues/156), [#163](https://github.com/wireviz/WireViz/pull/163)) - 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/wireviz/WireViz/issues/151), [#192](https://github.com/wireviz/WireViz/pull/192)) - 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/wireviz/WireViz/pull/197)) - Simplify BOM code ([#197](https://github.com/formatc1702/WireViz/pull/197))
- Bug fixes ([#218](https://github.com/wireviz/WireViz/pull/218), [#221](https://github.com/wireviz/WireViz/pull/221)) - Bug fixes ([#218](https://github.com/formatc1702/WireViz/pull/218), [#221](https://github.com/formatc1702/WireViz/pull/221))
### Known issues ### 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 `-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 - 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/formatc1702/WireViz/tree/v0.2) (2020-10-17)
## [0.2](https://github.com/wireviz/WireViz/tree/v0.2) (2020-10-17)
### Backward incompatible changes ### 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` - `pinnumbers` is now `pins`
- `pinout` is now `pinlabels` - `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 - 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. - 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. See the [syntax description](syntax.md) for details.
### New features ### New features
- Add bidirectional AWG/mm2 conversion ([#40](https://github.com/wireviz/WireViz/issues/40), [#41](https://github.com/wireviz/WireViz/pull/41)) - 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/wireviz/WireViz/pull/11), [#114](https://github.com/wireviz/WireViz/issues/114), [#121](https://github.com/wireviz/WireViz/pull/121)) - 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/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 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/wireviz/WireViz/issues/27), [#153](https://github.com/wireviz/WireViz/pull/153)) - 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/wireviz/WireViz/pull/55)) - 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/wireviz/WireViz/issues/49), [#64](https://github.com/wireviz/WireViz/pull/64)) - 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/wireviz/WireViz/issues/72), [#139](https://github.com/wireviz/WireViz/issues/139), [#140](https://github.com/wireviz/WireViz/pull/140)) - 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/wireviz/WireViz/issues/67), [#75](https://github.com/wireviz/WireViz/pull/75)) - 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/wireviz/WireViz/issues/167), [#173](https://github.com/wireviz/WireViz/pull/173)) - 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/wireviz/WireViz/pull/118)) - Add new features to `build_examples.py` ([#118](https://github.com/formatc1702/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)) - 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/wireviz/WireViz/issues/107), [#111](https://github.com/wireviz/WireViz/pull/111)) - Improve documentation ([#107](https://github.com/formatc1702/WireViz/issues/107), [#111](https://github.com/formatc1702/WireViz/pull/111))
### Misc. fixes ### Misc. fixes
- Improve BOM generation - Improve BOM generation
- Add various input sanity checks - 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)) - 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/wireviz/WireViz/issues/69), [#104](https://github.com/wireviz/WireViz/pull/104)) - 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/wireviz/WireViz/issues/125), [#126](https://github.com/wireviz/WireViz/pull/126)) - 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/wireviz/WireViz/issues/146), [#154](https://github.com/wireviz/WireViz/pull/154)) - 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 - Initial release

View File

@ -1,6 +1,6 @@
# Contribution Guidelines # 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 ## 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. 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. 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. 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. 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 ### Hints

View File

@ -2,7 +2,7 @@
<!-- <!--
The following text is taken from #118 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 --> TODO: write a better explaination -->

View File

@ -85,6 +85,10 @@ tweak: # optional tweaking of .gv output
# loops # loops
loops: <List> # every list item is itself a list of exactly two pins loops: <List> # every list item is itself a list of exactly two pins
# on the connector that are to be shorted # 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 ## Cable attributes
@ -148,6 +152,9 @@ tweak: # optional tweaking of .gv output
show_wirecount: <bool> # defaults to true show_wirecount: <bool> # defaults to true
show_wirenumbers: <bool> # defaults to true for cables; false for bundles 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 ## 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 # If no value is specified for 'title', then the
# output filename without extension is used. # 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 ## 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 # This feature is experimental and might change
# or be removed in future versions. # 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 override: # dict of .gv entries to override
# Each entry is identified by its leading string # Each entry is identified by its leading string
# in lines beginning with a TAB character. # in lines beginning with a TAB character.

4
examples/demo01.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/demo01.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>demo01</title>
<style> <style>

4
examples/demo02.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/demo02.html generated
View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; 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> <title>WireViz Demo 2</title>
<style> <style>
body { body {

4
examples/ex01.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex01.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex01</title>
<style> <style>

4
examples/ex02.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex02.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex02</title>
<style> <style>

4
examples/ex03.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex03.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex03</title>
<style> <style>

4
examples/ex04.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex04.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex04</title>
<style> <style>

4
examples/ex05.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex05.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex05</title>
<style> <style>

8
examples/ex06.bom.tsv generated
View File

@ -1,6 +1,6 @@
Id Description Qty Unit Designators Id Description Qty Unit Designators
1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6 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 2 Wire, 0.25 mm², PK 1.0 m W1, W2, W3, W4, W5
3 Wire, 0.25 mm², TQ 1 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 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 m W1, W2, W3, W4, W5 5 Wire, 0.25 mm², YE 1.0 m W1, W2, W3, W4, W5

1 Id Description Qty Unit Designators
2 1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6
3 2 Wire, 0.25 mm², PK 1 1.0 m W1, W2, W3, W4, W5
4 3 Wire, 0.25 mm², TQ 1 1.0 m W1, W2, W3, W4, W5
5 4 Wire, 0.25 mm², VT 1 1.0 m W1, W2, W3, W4, W5
6 5 Wire, 0.25 mm², YE 1 1.0 m W1, W2, W3, W4, W5

4
examples/ex06.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

10
examples/ex06.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex06</title>
<style> <style>
@ -716,28 +716,28 @@
<tr> <tr>
<td class="bom_col_id">2</td> <td class="bom_col_id">2</td>
<td class="bom_col_description">Wire, 0.25 mm², PK</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_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">3</td> <td class="bom_col_id">3</td>
<td class="bom_col_description">Wire, 0.25 mm², TQ</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_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">4</td> <td class="bom_col_id">4</td>
<td class="bom_col_description">Wire, 0.25 mm², VT</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_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">5</td> <td class="bom_col_id">5</td>
<td class="bom_col_description">Wire, 0.25 mm², YE</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_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>

4
examples/ex07.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex07.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex07</title>
<style> <style>

4
examples/ex08.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex08.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex08</title>
<style> <style>

4
examples/ex09.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex09.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex09</title>
<style> <style>

4
examples/ex10.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex10.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex10</title>
<style> <style>

4
examples/ex11.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex11.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex11</title>
<style> <style>

4
examples/ex12.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex12.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex12</title>
<style> <style>

4
examples/ex13.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex13.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex13</title>
<style> <style>

4
examples/ex14.gv generated
View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

2
examples/ex14.html generated
View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>ex14</title>
<style> <style>

View File

@ -27,7 +27,6 @@ setup(
keywords="cable connector hardware harness wiring wiring-diagram wiring-harness", keywords="cable connector hardware harness wiring wiring-diagram wiring-harness",
url=APP_URL, url=APP_URL,
package_dir={"": "src"}, package_dir={"": "src"},
package_data={CMD_NAME: ["templates/*.html"]},
packages=find_packages("src"), packages=find_packages("src"),
entry_points={ entry_points={
"console_scripts": [ "console_scripts": [
@ -40,6 +39,10 @@ setup(
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8", "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", "Topic :: Utilities",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
], ],

View File

@ -72,6 +72,7 @@ class Options:
@dataclass @dataclass
class Tweak: class Tweak:
placeholder: Optional[PlainText] = None
override: Optional[Dict[Designator, Dict[str, Optional[str]]]] = None override: Optional[Dict[Designator, Dict[str, Optional[str]]]] = None
append: Union[str, List[str], None] = 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 # See also HTML doc at https://graphviz.org/doc/info/shapes.html#html
def __post_init__(self): def __post_init__(self):
if self.fixedsize is None: if self.fixedsize is None:
# Default True if any dimension specified unless self.scale also is specified. # Default True if any dimension specified unless self.scale also is specified.
self.fixedsize = (self.width or self.height) and self.scale is None 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) loops: List[List[Pin]] = field(default_factory=list)
ignore_in_bom: bool = False ignore_in_bom: bool = False
additional_components: List[AdditionalComponent] = field(default_factory=list) additional_components: List[AdditionalComponent] = field(default_factory=list)
tweak: Optional[Tweak] = None
def __post_init__(self) -> None: def __post_init__(self) -> None:
if isinstance(self.image, dict): if isinstance(self.image, dict):
self.image = Image(**self.image) self.image = Image(**self.image)
if self.tweak is not None:
self.tweak = Tweak(**self.tweak)
self.ports_left = False self.ports_left = False
self.ports_right = False self.ports_right = False
@ -272,10 +278,14 @@ class Cable:
show_wirenumbers: Optional[bool] = None show_wirenumbers: Optional[bool] = None
ignore_in_bom: bool = False ignore_in_bom: bool = False
additional_components: List[AdditionalComponent] = field(default_factory=list) additional_components: List[AdditionalComponent] = field(default_factory=list)
tweak: Optional[Tweak] = None
def __post_init__(self) -> None: def __post_init__(self) -> None:
if isinstance(self.image, dict): if isinstance(self.image, dict):
self.image = Image(**self.image) 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 if isinstance(self.gauge, str): # gauge and unit specified
try: try:
@ -383,6 +393,7 @@ class Cable:
to_name: Optional[Designator], to_name: Optional[Designator],
to_pin: NoneOrMorePinIndices, to_pin: NoneOrMorePinIndices,
) -> None: ) -> None:
from_pin = int2tuple(from_pin) from_pin = int2tuple(from_pin)
via_wire = int2tuple(via_wire) via_wire = int2tuple(via_wire)
to_pin = int2tuple(to_pin) to_pin = int2tuple(to_pin)

View File

@ -8,6 +8,7 @@ from pathlib import Path
from typing import Any, List, Union from typing import Any, List, Union
from graphviz import Graph from graphviz import Graph
from wireviz import APP_NAME, APP_URL, __version__, wv_colors from wireviz import APP_NAME, APP_URL, __version__, wv_colors
from wireviz.DataClasses import ( from wireviz.DataClasses import (
Cable, Cable,
@ -19,7 +20,7 @@ from wireviz.DataClasses import (
Side, Side,
Tweak, 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 ( from wireviz.wv_bom import (
HEADER_MPN, HEADER_MPN,
HEADER_PN, HEADER_PN,
@ -28,6 +29,7 @@ from wireviz.wv_bom import (
component_table_entry, component_table_entry,
generate_bom, generate_bom,
get_additional_component_table, get_additional_component_table,
make_list,
pn_info_string, pn_info_string,
) )
from wireviz.wv_colors import get_color_hex, translate_color 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 ( from wireviz.wv_helper import (
awg_equiv, awg_equiv,
file_write_text,
flatten2d, flatten2d,
is_arrow, is_arrow,
mm2_equiv, mm2_equiv,
open_file_read,
open_file_write,
tuplelist2tsv, tuplelist2tsv,
) )
from wireviz.wv_html import generate_html_output from wireviz.wv_html import generate_html_output
@ -57,14 +60,12 @@ OLD_CONNECTOR_ATTR = {
"autogenerate": "is replaced with new syntax in v0.4", "autogenerate": "is replaced with new syntax in v0.4",
} }
def check_old(node: str, old_attr: dict, args: dict) -> None: def check_old(node: str, old_attr: dict, args: dict) -> None:
"""Raise exception for any outdated attributes in args.""" """Raise exception for any outdated attributes in args."""
for attr, descr in old_attr.items(): for attr, descr in old_attr.items():
if attr in args: if attr in args:
raise ValueError(f"'{attr}' in {node}: '{attr}' {descr}") raise ValueError(f"'{attr}' in {node}: '{attr}' {descr}")
@dataclass @dataclass
class Harness: class Harness:
metadata: Metadata metadata: Metadata
@ -78,12 +79,42 @@ class Harness:
self._bom = [] # Internal Cache for generated bom self._bom = [] # Internal Cache for generated bom
self.additional_bom_items = [] 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: def add_connector(self, name: str, *args, **kwargs) -> None:
check_old(f"Connector '{name}'", OLD_CONNECTOR_ATTR, kwargs) check_old(f"Connector '{name}'", OLD_CONNECTOR_ATTR, kwargs)
self.connectors[name] = Connector(name, *args, **kwargs) self.connectors[name] = Connector(name, *args, **kwargs)
self.extend_tweak(self.connectors[name])
def add_cable(self, name: str, *args, **kwargs) -> None: def add_cable(self, name: str, *args, **kwargs) -> None:
self.cables[name] = Cable(name, *args, **kwargs) 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: 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)) 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"), bgcolor=wv_colors.translate_color(self.options.bgcolor, "HEX"),
nodesep="0.33", nodesep="0.33",
fontname=self.options.fontname, fontname=self.options.fontname,
) # TODO: Add graph attribute: charset="utf-8", )
dot.attr( dot.attr(
"node", "node",
shape="none", shape="none",
@ -186,6 +217,7 @@ class Harness:
dot.attr("edge", style="bold", fontname=self.options.fontname) dot.attr("edge", style="bold", fontname=self.options.fontname)
for connector in self.connectors.values(): for connector in self.connectors.values():
# If no wires connected (except maybe loop wires)? # If no wires connected (except maybe loop wires)?
if not (connector.ports_left or connector.ports_right): if not (connector.ports_left or connector.ports_right):
connector.ports_left = True # Use left side pins. connector.ports_left = True # Use left side pins.
@ -252,9 +284,6 @@ class Harness:
pinhtml.append(" </table>") pinhtml.append(" </table>")
if len(pinhtml) == 2: # Table start and end with no rows between?
pinhtml = ["<!-- all pins hidden -->"] # Avoid Graphviz error
html = [ html = [
row.replace("<!-- connector table -->", "\n".join(pinhtml)) row.replace("<!-- connector table -->", "\n".join(pinhtml))
for row in html for row in html
@ -283,7 +312,6 @@ class Harness:
dot.edge( dot.edge(
f"{connector.name}:p{loop[0]}{loop_side}:{loop_dir}", f"{connector.name}:p{loop[0]}{loop_side}:{loop_dir}",
f"{connector.name}:p{loop[1]}{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; # determine if there are double- or triple-colored wires in the harness;
@ -295,6 +323,7 @@ class Harness:
) )
for cable in self.cables.values(): for cable in self.cables.values():
html = [] html = []
awg_fmt = "" awg_fmt = ""
@ -532,38 +561,6 @@ class Harness:
fillcolor=translate_color(bgcolor, "HEX"), 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: def typecheck(name: str, value: Any, expect: type) -> None:
if not isinstance(value, expect): if not isinstance(value, expect):
raise Exception( raise Exception(
@ -629,9 +626,51 @@ class Harness:
typecheck("tweak.append", self.tweak.append, str) typecheck("tweak.append", self.tweak.append, str)
dot.body.append(self.tweak.append) dot.body.append(self.tweak.append)
# Tweak processing above must be the last before returning dot. for mate in self.mates:
# Please don't insert any code that might change the dot contents if mate.shape[0] == "<" and mate.shape[-1] == ">":
# after tweak processing. 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 return dot
@ -656,7 +695,7 @@ class Harness:
return data.read() return data.read()
@property @property
def svg(self): # TODO?: Verify xml encoding="utf-8" in SVG? def svg(self):
graph = self.graph graph = self.graph
return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd()) return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd())
@ -691,7 +730,7 @@ class Harness:
# BOM output # BOM output
bomlist = bom_list(self.bom()) bomlist = bom_list(self.bom())
if "tsv" in fmt: 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: if "csv" in fmt:
# TODO: implement CSV output (preferrably using CSV library) # TODO: implement CSV output (preferrably using CSV library)
print("CSV output is not yet supported") print("CSV output is not yet supported")

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Please don't import anything in this file to avoid issues when it is imported in setup.py # 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 CMD_NAME = "wireviz" # Lower case command and module name
APP_NAME = "WireViz" # Application name in texts meant to be human readable 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"

View File

@ -8,20 +8,6 @@ from typing import Union
mime_subtype_replacements = {"jpg": "jpeg", "tif": "tiff"} 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: def embed_svg_images(svg_in: str, base_path: Union[str, Path] = Path.cwd()) -> str:
images_b64 = {} # cache of base64-encoded images images_b64 = {} # cache of base64-encoded images
@ -59,8 +45,8 @@ def embed_svg_images_file(
) -> None: ) -> None:
filename_in = Path(filename_in).resolve() filename_in = Path(filename_in).resolve()
filename_out = filename_in.with_suffix(".b64.svg") 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) embed_svg_images(filename_in.read_text(), filename_in.parent)
) # TODO: Use encoding="utf-8" in both read_text() and write_text() )
if overwrite: if overwrite:
filename_out.replace(filename_in) filename_out.replace(filename_in)

View File

@ -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.

View File

@ -179,7 +179,7 @@
</head> </head>
<body> <body>
<div id="page"> <div id="page">
<div id="frame" class="<!-- %template_sheetsize% -->"> <div id="frame" class="sheetsize_default">
<div id="diagram"> <div id="diagram">

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import platform
import sys import sys
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Tuple, Union 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.Harness import Harness
from wireviz.wv_helper import ( from wireviz.wv_helper import (
expand, expand,
file_read_text,
get_single_key_and_value, get_single_key_and_value,
is_arrow, is_arrow,
open_file_read,
smart_file_resolve, smart_file_resolve,
) )
from . import APP_NAME
def parse( def parse(
inp: Union[Path, str, Dict], inp: Union[Path, str, Dict],
@ -89,10 +86,6 @@ def parse(
raise Exception("No output formats or return types specified") raise Exception("No output formats or return types specified")
yaml_data, yaml_file = _get_yaml_data_and_path(inp) 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: if output_formats:
# need to write data to file, determine output directory and filename # need to write data to file, determine output directory and filename
output_dir = _get_output_dir(yaml_file, output_dir) 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. # When title is not given, either deduce it from filename, or use default text.
if "title" not in harness.metadata: 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 # add items
# parse YAML input file ==================================================== # parse YAML input file ====================================================
@ -408,21 +403,14 @@ def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path):
try: try:
yaml_path = Path(inp).expanduser().resolve(strict=True) yaml_path = Path(inp).expanduser().resolve(strict=True)
# if no FileNotFoundError exception happens, get file contents # if no FileNotFoundError exception happens, get file contents
yaml_str = file_read_text(yaml_path) yaml_str = open_file_read(yaml_path).read()
except (FileNotFoundError, OSError, ValueError) as e: except (FileNotFoundError, OSError) as e:
# if inp is a long YAML string, Pathlib will normally raise # if inp is a long YAML string, Pathlib will raise OSError: [errno.ENAMETOOLONG]
# FileNotFoundError or OSError(errno = ENAMETOOLONG) when # when trying to expand and resolve it as a path.
# trying to expand and resolve it as a path, but in Windows # Catch this error, but raise any others
# might ValueError or OSError(errno = EINVAL or None) be raised from errno import ENAMETOOLONG
# instead in some cases (depending on the Python version).
# Catch these specific errors, but raise any others.
from errno import EINVAL, ENAMETOOLONG if type(e) is OSError and e.errno != 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()}"
)
raise e raise e
# file does not exist; assume inp is a YAML string # file does not exist; assume inp is a YAML string
yaml_str = inp yaml_str = inp

View File

@ -204,9 +204,7 @@ def generate_bom(harness: "Harness") -> List[BOMEntry]:
bom.append( bom.append(
{ {
**group_entries[0], **group_entries[0],
"qty": int(total_qty) "qty": round(total_qty, 3),
if float(total_qty).is_integer()
else round(total_qty, 3),
"designators": sorted(set(designators)), "designators": sorted(set(designators)),
} }
) )

View File

@ -11,7 +11,7 @@ if __name__ == "__main__":
import wireviz.wireviz as wv import wireviz.wireviz as wv
from wireviz import APP_NAME, __version__ from wireviz import APP_NAME, __version__
from wireviz.wv_helper import file_read_text from wireviz.wv_helper import open_file_read
format_codes = { format_codes = {
# "c": "csv", # "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}") raise Exception(f"File does not exist:\n{prepend_file}")
print("Prepend file:", 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: else:
prepend_input = "" 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}" "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 file_dir = file.parent
yaml_input = prepend_input + yaml_input yaml_input = prepend_input + yaml_input

View File

@ -113,31 +113,18 @@ def clean_whitespace(inp):
def open_file_read(filename): def open_file_read(filename):
"""Open utf-8 encoded text file for reading - remember closing it when finished"""
# TODO: Intelligently determine encoding # TODO: Intelligently determine encoding
return open(filename, "r", encoding="UTF-8") return open(filename, "r", encoding="UTF-8")
def open_file_write(filename): 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") return open(filename, "w", encoding="UTF-8")
def open_file_append(filename): 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") 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): def is_arrow(inp):
""" """
Matches strings of one or multiple `-` or `=` (but not mixed) Matches strings of one or multiple `-` or `=` (but not mixed)
@ -157,10 +144,10 @@ def aspect_ratio(image_src):
try: try:
from PIL import Image from PIL import Image
with Image.open(image_src) as image: image = Image.open(image_src)
if image.width > 0 and image.height > 0: if image.width > 0 and image.height > 0:
return image.width / image.height return image.width / image.height
print(f"aspect_ratio(): Invalid image size {image.width} x {image.height}") print(f"aspect_ratio(): Invalid image size {image.width} x {image.height}")
# ModuleNotFoundError and FileNotFoundError are the most expected, but all are handled equally. # ModuleNotFoundError and FileNotFoundError are the most expected, but all are handled equally.
except Exception as error: except Exception as error:
print(f"aspect_ratio(): {type(error).__name__}: {error}") print(f"aspect_ratio(): {type(error).__name__}: {error}")

View File

@ -2,16 +2,15 @@
import re import re
from pathlib import Path 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 import APP_NAME, APP_URL, __version__, wv_colors
from wireviz.DataClasses import Metadata, Options 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_gv_html import html_line_breaks
from wireviz.wv_helper import ( from wireviz.wv_helper import (
file_read_text,
file_write_text,
flatten2d, flatten2d,
open_file_read,
open_file_write,
smart_file_resolve, smart_file_resolve,
) )
@ -22,6 +21,7 @@ def generate_html_output(
metadata: Metadata, metadata: Metadata,
options: Options, options: Options,
): ):
# load HTML template # load HTML template
templatename = metadata.get("template", {}).get("name") templatename = metadata.get("template", {}).get("name")
if templatename: if templatename:
@ -34,14 +34,14 @@ def generate_html_output(
# fall back to built-in simple template if no template was provided # fall back to built-in simple template if no template was provided
templatefile = Path(__file__).parent / "templates/simple.html" 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) # embed SVG diagram
def svgdata() -> str: with open_file_read(f"{filename}.tmp.svg") as file:
return re.sub( # TODO?: Verify xml encoding="utf-8" in SVG? svgdata = re.sub(
"^<[?]xml [^?>]*[?]>[^<]*<!DOCTYPE [^>]*>", "^<[?]xml [^?>]*[?]>[^<]*<!DOCTYPE [^>]*>",
"<!-- XML and DOCTYPE declarations from SVG file removed -->", "<!-- XML and DOCTYPE declarations from SVG file removed -->",
file_read_text(f"{filename}.tmp.svg"), file.read(),
1, 1,
) )
@ -80,27 +80,13 @@ def generate_html_output(
"<!-- %generator% -->": f"{APP_NAME} {__version__} - {APP_URL}", "<!-- %generator% -->": f"{APP_NAME} {__version__} - {APP_URL}",
"<!-- %fontname% -->": options.fontname, "<!-- %fontname% -->": options.fontname,
"<!-- %bgcolor% -->": wv_colors.translate_color(options.bgcolor, "hex"), "<!-- %bgcolor% -->": wv_colors.translate_color(options.bgcolor, "hex"),
"<!-- %filename% -->": str(filename), "<!-- %diagram% -->": svgdata,
"<!-- %filename_stem% -->": Path(filename).stem,
"<!-- %bom% -->": bom_html, "<!-- %bom% -->": bom_html,
"<!-- %bom_reversed% -->": bom_html_reversed, "<!-- %bom_reversed% -->": bom_html_reversed,
"<!-- %sheet_current% -->": "1", # TODO: handle multi-page documents "<!-- %sheet_current% -->": "1", # TODO: handle multi-page documents
"<!-- %sheet_total% -->": "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 # prepare metadata replacements
if metadata: if metadata:
for item, contents in metadata.items(): for item, contents in metadata.items():
@ -111,11 +97,14 @@ def generate_html_output(
if isinstance(entry, Dict): if isinstance(entry, Dict):
replacements[f"<!-- %{item}_{index+1}% -->"] = str(category) replacements[f"<!-- %{item}_{index+1}% -->"] = str(category)
for entry_key, entry_value in entry.items(): for entry_key, entry_value in entry.items():
replacements[ replacements[f"<!-- %{item}_{index+1}_{entry_key}% -->"] = (
f"<!-- %{item}_{index+1}_{entry_key}% -->" html_line_breaks(str(entry_value))
] = html_line_breaks(str(entry_value)) )
elif isinstance(entry, (str, int, float)):
pass # TODO?: replacements[f"<!-- %{item}_{category}% -->"] = html_line_breaks(str(entry)) replacements['"sheetsize_default"'] = '"{}"'.format(
metadata.get("template", {}).get("sheetsize", "")
)
# include quotes so no replacement happens within <style> definition
# perform replacements # perform replacements
# regex replacement adapted from: # regex replacement adapted from:
@ -127,4 +116,4 @@ def generate_html_output(
pattern = re.compile("|".join(replacements_escaped)) pattern = re.compile("|".join(replacements_escaped))
html = pattern.sub(lambda match: replacements[match.group(0)], html) 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)

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>tutorial01</title>
<style> <style>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>tutorial02</title>
<style> <style>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>tutorial03</title>
<style> <style>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>tutorial04</title>
<style> <style>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>tutorial05</title>
<style> <style>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>tutorial06</title>
<style> <style>

View File

@ -1,6 +1,6 @@
Id Description Qty Unit Designators Id Description Qty Unit Designators
1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6 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 2 Wire, 0.25 mm², PK 1.0 m W1, W2, W3, W4, W5
3 Wire, 0.25 mm², TQ 1 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 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 m W1, W2, W3, W4, W5 5 Wire, 0.25 mm², YE 1.0 m W1, W2, W3, W4, W5

1 Id Description Qty Unit Designators
2 1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6
3 2 Wire, 0.25 mm², PK 1 1.0 m W1, W2, W3, W4, W5
4 3 Wire, 0.25 mm², TQ 1 1.0 m W1, W2, W3, W4, W5
5 4 Wire, 0.25 mm², VT 1 1.0 m W1, W2, W3, W4, W5
6 5 Wire, 0.25 mm², YE 1 1.0 m W1, W2, W3, W4, W5

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>tutorial07</title>
<style> <style>
@ -716,28 +716,28 @@
<tr> <tr>
<td class="bom_col_id">2</td> <td class="bom_col_id">2</td>
<td class="bom_col_description">Wire, 0.25 mm², PK</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_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">3</td> <td class="bom_col_id">3</td>
<td class="bom_col_description">Wire, 0.25 mm², TQ</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_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">4</td> <td class="bom_col_id">4</td>
<td class="bom_col_description">Wire, 0.25 mm², VT</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_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>
<tr> <tr>
<td class="bom_col_id">5</td> <td class="bom_col_id">5</td>
<td class="bom_col_description">Wire, 0.25 mm², YE</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_unit">m</td>
<td class="bom_col_designators">W1, W2, W3, W4, W5</td> <td class="bom_col_designators">W1, W2, W3, W4, W5</td>
</tr> </tr>

View File

@ -1,6 +1,6 @@
graph { graph {
// Graph generated by WireViz 0.4.1 // Graph generated by WireViz 0.4
// https://github.com/wireviz/WireViz // https://github.com/formatc1702/WireViz
graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2] 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] node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
edge [fontname=arial style=bold] edge [fontname=arial style=bold]

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"><head> <html lang="en"><head>
<meta charset="UTF-8"> <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> <title>tutorial08</title>
<style> <style>