317 Commits

Author SHA1 Message Date
Daniel Rojas
406bdd36f2 Use regex-based replacement 2021-10-16 21:52:05 +02:00
Daniel Rojas
02963101d0 Implement fontname and bgcolor(WIP) replacement 2021-10-16 21:52:05 +02:00
Daniel Rojas
5bed6de7ab Consolidate code for replacing HTML placeholders 2021-10-16 21:52:05 +02:00
Daniel Rojas
36195e1cbb Apply fontname and bgcolor to output HTML
Co-authored-by: kvid <kvid@users.noreply.github.com>
2021-10-16 21:52:05 +02:00
Daniel Rojas
960f20e6ef Add type hint
Co-authored-by: kvid <kvid@users.noreply.github.com>
2021-10-16 21:52:05 +02:00
Daniel Rojas
eae2694b5d Implement template-based HTML output 2021-10-16 21:52:05 +02:00
Daniel Rojas
6b1e274d57 Refactor functions for harness building
- Use pin names instead of pin indices, until the last moment when generating the ports for the GraphViz nodes
- `Harness.add_mate_pin()` now uses pin names
- Remove unused `if is_arrow()` check from `Harness.connect()`
- Consolidate calling of `Connector.activate_pin()` to prevent subtle bugs
  - Call it from `connect()` and `add_mate_pin()`
  - No longer call it from `create_graph()`
- Misc. other tuning
2021-10-16 21:46:31 +02:00
Daniel Rojas
f0b63de3c7 Simplify code 2021-10-14 18:03:30 +02:00
Daniel Rojas
02a800abef Fix bug of arrows using the wrong port IDs 2021-10-14 18:03:18 +02:00
Daniel Rojas
2d701ee652 Resolve component level mate not revealing connection count 2021-10-13 21:39:11 +02:00
Daniel Rojas
2a62dae9ee Resolve edge case of empty HTML tables 2021-10-13 21:39:11 +02:00
Daniel Rojas
8ea8248721 Squash feature/mate+autogenerate branch 2021-10-13 21:38:23 +02:00
Daniel Rojas
4f4d63f029 Bump version to 0.4-dev 2021-10-11 22:08:49 +02:00
Daniel Rojas
2629e1c0da Bump version to 0.3 2021-10-11 20:55:53 +02:00
Daniel Rojas
3cc36e1573 Harmonize shebangs and encoding info
- Use `#!/usr/bin/env python3` on executable modules
- Remove shebangs on all other `.py` files
- Add UTF-8 encoding info where mising
2021-10-11 20:05:52 +02:00
KV
7125f28760 Move color type aliases into wv_colors.py to avoid circular imports 2021-09-28 19:14:28 +02:00
KV
c34946183e Support specifying hex colors for any color attributes 2021-09-28 19:14:28 +02:00
KV
b3fdd48a83 Support specifying hex colors where no color name is needed
This was requested by designer2k2 in #219 for bgcolor usage.
It has also been discussed in #135.

The input validation is more detailed to help the user identifying
and locating invalid values. The wire color padding is now done on
the output to cover different input alternatives.
2021-09-28 19:14:28 +02:00
KV
166ab2fdf1 Support bgcolor of additional components
Maybe not needed that much, but mainly for consistency, to support
bgcolor in all dataclasses that represent boxes in the diagram.
2021-09-28 19:14:28 +02:00
KV
324508a8ee Support image.bgcolor to enable adapting to image colors 2021-09-28 19:14:28 +02:00
KV
45d7d03fe0 Support both bgcolor and bgcolor_title attributes
Solves #210 completely by supporting bgcolor of both the node title
and the whole node independently using separate attributes.
2021-09-28 19:14:28 +02:00
KV
dbccb77b08 Add bgcolor attribute to connectors and cables
This solves the #210 suggestion to render the title row of
the graph nodes with this bgcolor.
2021-09-28 19:14:28 +02:00
Daniel Rojas
a3eefe6659
Implement suppliers and supplier part numbers (#241)
Co-authored-by: kvid <kvid@users.noreply.github.com>
2021-09-14 19:29:59 +02:00
kvid
db05514469
Add optional tweaking of the .gv output (#215)
Co-authored-by: Daniel Rojas <github@danielrojas.net>
2021-09-14 19:20:51 +02:00
kvid
92354e6852
Add basic options and metadata (#214) 2021-08-25 19:46:37 +02:00
Daniel Rojas
e212fc9058
Use unique index for connector pin ports (#229)
Closes #160.

Co-authored-by: kvid <kvid@users.noreply.github.com>
2021-08-23 19:26:23 +02:00
kvid
31d55ff775
Simplify BOM code (#197)
* Skip assignment and return expression directly

* Simplify get_bom_index() parameters

- Use the actual BOM as first parameter instead of the whole harness.
- Use a whole AdditionalComponent as second parameter instead of each
  attribute separately.

* Use the same lambda in get_bom_index() as for deduplicating BOM

Move the lambda declaration out of the function scope for common
access from two different functions.

* Convert dataclass object to dict to use the same lambda

* Redefine the common lambda to an ordinary function

* Simplify BOM header row logic

* Simplify collecting designators for a joined BOM entry

Assign input designators once to a temporary variable for easy reusage.

* Simplify deduplication and sorting of collected designators

* Remove parentheses around return expressions

https://stackoverflow.com/questions/4978567/should-a-return-statement-have-parentheses

* Move out code from inner loop into helper functions

* Move BOM sorting above grouping to use groupby()

- Use one common entry loop to consume iterator only once.
- Use same key function for sort() and groupby(),
  except replace None with empty string when sorting.

* Make the BOM grouping function return string tuple for sorting

* Use a generator expressions and raise exception if failing

Seems to be the most popular search alternative:
 https://stackoverflow.com/questions/8653516/python-list-of-dictionaries-search

Raising StopIteration if not found is better than returning None
to detect such an internal error more easily.

* Replace accumulation loop with sum expressions

Make a list from the group iterator for reusage in sum expressions
and to pick first group entry. The expected group sizes are very small,
so performance loss by creating a temporary list should be neglectable.

Alternativly, itertools.tee(group, 3) could be called to triplicate
the iterator, but it was not chosen for readability reasons.

* Add function type hints and doc strings

* Add BOMEntry type alias

This type alias describes the possible types of keys and values in
the dict representing a BOM entry.

* Rename extra variable to part for consistency

* Build output string in one big expression

Build output string in component_table_entry() as the similar strings
in generate_bom(). Repeating a couple of minor if-expressions is small
cost to obtain a more compact and readable main expression.

* Move default qty value=1 to BOM deduplication

* Eliminate local variable

* Rename the 'item' key to 'description' in all BOMEntry dicts

This way, both BOM and harness.additional_bom_items uses the same
set of keys in their dict entries. This was originally suggested
in a #115 review, but had too many issues to be implemented then.

* Move repeated code into new optional_fields() function

* Group common function arguments into a dict

* Revert "Use a generator expressions and raise exception if failing"

This reverts commit 96d393dfb757afc61ffb319c34035d8d2ce7c33d.
However, raising an exception if failing the BOM index search is still
wanted, so a custom exception is raised instead of returning None.

* Use new BOMKey type alias for get_bom_index() target argument

Replace the get_bom_index() part argument with the target key argument
to prepare for quering any BOM entry that matches the target key.

* Cache the BOM entry key in the entry itself

* Rename bom_types_group() to bom_entry_key()

* Define tuples of BOM columns as common constants

* Clarify a comment

* Change BOM heading from `Item` to `Description`

Co-authored-by: kvid <kvid@users.noreply.github.com>

Co-authored-by: Daniel Rojas <github@danielrojas.net>
2021-08-22 18:34:37 +02:00
KV
7546991b04 Show connector pins even when all are unconnected
Bug: Hiding connector pins when none are connected is not reasonable.
When combined with loops or neither pinlabels nor pincolors, then
exceptions are raised as well.

Fix: Forcing pins at the left side in such cases solves #217.
2021-03-20 11:11:11 +01:00
gopiballava
c0a885a800 Correctly check for default of None
If `show_wirenumbers` is omitted from a cable section, its value will be `None`. In that case, we want to choose a default based on whether this is a bundle or not.

If the user did specify `show_wirenumbers`, then its value will be `True` or `False`, and we want to respect that whether it's a bundle or not.
2021-03-20 11:09:13 +01:00
kvid
da56841290
Assign the default cable length unit when not present (#206)
Bug: Failing to assign the default cable length unit when not present.
It was introduced in #198.

Fix: Test the correct cable attribute. This fix solves issue #205.
2020-12-29 13:31:55 +01:00
Daniel Rojas
606ddbf977
Detect and assign unit within cable length attribute (#198)
Co-authored-by: kvid <kvid@users.noreply.github.com>
2020-12-13 12:39:29 +01:00
William Sutton
dec64abaf5 Add support for wire length units
Based on #161, #162, #171.

Co-authored-by: stevegt <stevegt@t7a.org>
Co-authored-by: kvid <kvid@users.noreply.github.com>
2020-11-16 17:14:46 +01:00
Daniel Rojas
96bd121403 Create separate modules for BOM and HTML functions 2020-11-15 08:42:57 +01:00
Daniel Rojas
eebf932c8d Show pin labels of adjacent connectors in cable node (#70) 2020-11-14 23:21:08 +01:00
Daniel Rojas
03e6077512 Allow referencing wires by color/label (#169,#193) 2020-11-14 23:21:08 +01:00
Daniel Rojas
feff47f47b
Add option to add colors to connector pins (#141) 2020-11-14 09:43:01 +01:00
KV
64bd34a7c6 Add type aliases that reflect their semantics
Using Any or str in type annotations might increase the need for extra
comments to explain the real valid values. However, such needs can be
drastically reduced with the help of semanticly named type aliases.

Each type alias have their legal values described in comments.
Actual validation might be implemented in the future.
2020-11-01 15:26:11 +01:00
KV
3f091bb419 Update the types of dataclass attributes according to usage
Fixes #156
2020-11-01 15:26:11 +01:00
Miklos Marton
e2e8bbfb91 Remove input text hyperlinks except in the HTML BOM
GraphViz does not support the a HTML tag when generating the tables for the
cables/connectors, so this change will remove these tags for the graph generation.
However for the HTML BOM output table these links will be generated.
2020-10-22 23:08:13 +02:00
Tyler Ward
e85ee5d285
Allow addittional BOM items within components (#115) 2020-10-22 17:53:33 +02:00
Daniel Rojas
4e4dac8597 Bump version to 0.3-dev 2020-10-17 11:53:11 +02:00
Daniel Rojas
3e570d648f Bump version to 0.2 2020-10-17 11:41:27 +02:00
KV
fb17eae7a6 Avoid errors from HTML validator
The https://validator.w3.org/ reported Errors:
The align attribute on the th/td element is obsolete. Use CSS instead.

By replacing align="X" attributes with text-align:X; CSS equivalent,
the validator now completes without any errors or warnings.

This solves the remaining issues from #97.
2020-10-16 22:02:15 +02:00
KV
7dcd1a7eeb Define application name and URL only once
The application name and URL was defined several places in the code,
and the name was not written exactly the same everywhere.

By using the same constants everywhere, consistency is obtained.
2020-10-16 22:02:15 +02:00
KV
b00040cdd9 Add version number to output files with meta info
Tag the .gv and .html output files with generator and version number.
2020-10-16 22:02:15 +02:00
KV
1809f73d58 Simplify colorbar using the same technique as html_image()
Moving common code into html_colorbar() helper function.
2020-10-14 22:37:20 +02:00
kvid
4782da47c9
Add optional image to connectors and cables (#153)
This image, with an optional caption below, is displayed in the lower 
section of the connector/cable node in the diagram - just above the 
notes if present.

This solves the basic part of issue #27, and is a continuation of 
PR #137 that was closed due to changes in the base branch.
2020-10-14 16:08:16 +02:00
KV
7df8a4b7cf Add command line options to show version number
Add -V command line option (and --version as an alias) to
both wireviz.py and build_examples.py that show version number.

Move the version number from setup.py into __init__.py to access
the same version number specification from all files needing it.

This solves part 4 of issue #167.
2020-10-11 13:37:34 +02:00
KV
c4957f1475 Comment out unimplemented command line option
It seems, that the current implementation ignores --generate-bom,
and that parser.add_argument() code line is therefore commented
out until it gets implemented to avoid any confusion.

This solves part 1 of issue #167.
2020-10-11 13:37:34 +02:00
KV
83a467a4aa Add diff as an alias to the compare command
When used to "git diff", it is easy to write "build_examples.py diff"
instead of "build_examples.py compare" by a mistake. Therefore,
"diff" is now an alias to "compare" so both commands will work.

This solves part 3 of issue #167.
2020-10-11 13:37:34 +02:00