74 Commits

Author SHA1 Message Date
KV
73f56b2efc Apply black *.py ../../setup.py
black==23.3.0
2024-07-12 19:05:12 +02:00
KV
19cdff1774 Avoid ResourceWarning: unclosed file (#395)
A number of such warnings showed up when running e.g.
PYTHONWARNINGS=always python build_examples.py
PYTHONWARNINGS=always wireviz ../../examples/demo0?.yml
See https://github.com/wireviz/WireViz/pull/309#issuecomment-2170988381

Fix: All open() calls should be in a "with open() as x" statement
to ensure closing the file when exiting the block in any way.
Otherwise, use the new file_read_text() or file_write_text() functions
to read or write the whole utf-8 text file and closing it.
2024-07-07 16:16:56 +02:00
KV
ee1bd7801e Provide more information when raising exception 2024-07-05 18:16:34 +02:00
Martin Rieder
f2a1aa8856 Update comment in src/wireviz/wireviz.py (#392)
Clarify all exceptions catched, including changes in #392

Co-authored-by: kvid <kvid@users.noreply.github.com>
2024-07-05 18:16:34 +02:00
Martin Rieder
0e8ab7a668 Catch also ValueError (#392)
In Windows might ValueError be raised instead of the already
catched exceptions in some cases (depending on the Python version)

Fixes point 2 of https://github.com/wireviz/WireViz/pull/318#pullrequestreview-1457016602
2024-07-05 18:16:34 +02:00
Martin Rieder
42d10dfab4 Catch OSError also with errno=None (#392)
In Windows might OSError(errno = None) be raised instead of the already
catched exceptions in some cases (depending on the Python version)

Fixes #391
2024-07-05 18:16:34 +02:00
kvid
858b2664db Update src/wireviz/wireviz.py (#383)
Raising TypeError is better than assert. (Black reformatted)

Co-authored-by: Andreas Motl <andreas.motl@panodata.org>
2024-07-05 18:23:32 +02:00
KV
5cedba9def Explain unexpeced top-level type (#383)
Might help in reported issues like #342
2024-07-05 18:16:34 +02:00
KV
7ae3fb33fd Use output_name as default title (#361)
The CLI handling code was redesigned for v0.4 and it seems the code
to assign a default title from v0.3.1 has been messed up. This bug
has not been triggered by build_examples.py due to it seems to call
the parse() function differently.

The output_name should be used as default title when present.

This will fix the #360 bug report.
2024-07-05 18:16:34 +02:00
KV
77061a0656 Handle OSError(errno=EINVAL) that might be raised in Windows (#346)
In Windows might OSError(errno=EINVAL) be raised instead of the already
catched exceptions in some cases (depending on the Python version).

Suggested fix posted by JarrettR in
https://github.com/wireviz/WireViz/issues/344#issuecomment-2113476151

Co-authored-by: JarrettR <jrainier@gmail.com>
2024-07-05 18:16:34 +02:00
Daniel Rojas
55c6ab51f1 Apply black 2024-05-05 15:50:59 +02:00
Daniel Rojas
487498e128 Merge branch 'release/v0.4-rc' into release/v0.4-rc2
`rc2` branch is based directly on `master`. By merging into `rc2`, any merge conflicts can be resolved while leaving `master` intact until final merge is approved.

# Conflicts:
#	docs/CHANGELOG.md
#	src/wireviz/Harness.py
#	src/wireviz/__init__.py
#	src/wireviz/wireviz.py
2024-05-05 15:30:40 +02:00
Daniel Rojas
8ba9131a11 Add warning about unconnected components 2024-04-16 10:15:33 +02:00
RedshiftVelocities
6f9007f45d
Use portable OS error codes so program doesn't crash (#318)
Hard-coding OS error numbers that differ between different platforms
caused the program to crash at platforms using a different error number.

Using the Standard errno system symbols will avoid this problem.

Co-authored-by: kvid <kvid@users.noreply.github.com>
2023-09-01 22:24:34 +02:00
Andreas Motl
80b7a5407b 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.
2021-10-25 20:05:05 +02:00
Daniel Rojas
e31ed72655 Auto-assign missing harness title if reading from file 2021-10-16 22:27:00 +02:00
Daniel Rojas
45bcc1dd45 Make template separator character user-configurable 2021-10-16 22:27:00 +02:00
Daniel Rojas
08b5124adb Add support for multiple prepended files 2021-10-16 22:26:59 +02:00
Daniel Rojas
5aaea651b1 Automatically include input file directory in list to resolve image paths 2021-10-16 22:26:59 +02:00
Daniel Rojas
3aa1a2e651 Write docstring for parse() function 2021-10-16 22:26:59 +02:00
Daniel Rojas
8215113165 Add leading underscore to local helper functions 2021-10-16 22:26:59 +02:00
Daniel Rojas
e3530702f2 Allow specifying output directory and file name separately 2021-10-16 22:26:59 +02:00
Daniel Rojas
d7d7854bce Consolidate wireviz.parse() to handle Path, str and Dict as input 2021-10-16 22:26:59 +02:00
Daniel Rojas
c89cf735ae Apply some manual fixes, reapply black 2021-10-16 22:09:59 +02:00
Daniel Rojas
f92985a61c Apply black 2021-10-16 22:09:59 +02:00
Daniel Rojas
344615483a Apply isort 2021-10-16 22:09:59 +02:00
Daniel Rojas
fb2aae5515 Split file output logic and object return logic
Use `output_formats` parameter to specify which *files* to output to disk,
Use `return_types` parameter to specify which objects to return to a calling Python script
2021-10-16 22:08:01 +02:00
Daniel Rojas
0cb0a4e054 Add main() to wireviz.py as fallback 2021-10-16 22:08:01 +02:00
Daniel Rojas
3c6b902867 Remove obsolete comments 2021-10-16 22:08:01 +02:00
Daniel Rojas
3a181f6f95 Fix smart file resolver for images 2021-10-16 22:08:01 +02:00
Daniel Rojas
b1fa2b9de9 Do not output .gv files by default 2021-10-16 22:08:01 +02:00
Daniel Rojas
6a08988ca9 Implement image path resolver 2021-10-16 22:08:01 +02:00
Daniel Rojas
a5b0fbe305 Split the YAML loading and parsing functions 2021-10-16 22:08:00 +02:00
Daniel Rojas
b53ce36046 Fix entry point 2021-10-16 22:08:00 +02:00
Daniel Rojas
d3e99abaa8 Only output requested file types (closes #60) 2021-10-16 22:08:00 +02:00
Daniel Rojas
19481b291b Remove unneeded code from wireviz.py
Re-add `parse_file()` for building examples

bla
2021-10-16 22:08:00 +02:00
Daniel Rojas
35e89d4fdf Simplify main() 2021-10-16 21:54:56 +02:00
Daniel Rojas
a85ad89719 Add explanatory comment 2021-10-16 21:54:56 +02:00
Daniel Rojas
00be4747ad Replace os.path with pathlib.Path where used 2021-10-16 21:54:56 +02:00
Daniel Rojas
f0b63de3c7 Simplify code 2021-10-14 18:03:30 +02:00
Daniel Rojas
2d701ee652 Resolve component level mate not revealing connection count 2021-10-13 21:39:11 +02:00
Daniel Rojas
8ea8248721 Squash feature/mate+autogenerate branch 2021-10-13 21:38:23 +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
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
Daniel Rojas
831b423c03 Eliminate ferrule category, unify connectors (#78) 2020-07-20 08:21:54 +02:00
Andrew Katz
fecf27165f Fix unicode issue for windows (force an encoding) 2020-07-19 19:03:07 +02:00
Jason
12d3002af8
Add type hinting (#92) 2020-07-15 19:30:23 +02:00