Mcpy doesn't support compiled Python. So I decided to try Macropy, this is a
test.
Is much harder to get it working:
- The script must be a 2 liner, you can't activate it in any other way.
- The hook breaks the _import function in kiplot.py figuring out how to solve
it was a real challenge. It failed miserably passing the class instead of
the ast._ClassDef to the macro.
When I finally got it working I found the code supports compiled Python, but
runs almost 3 times slower.
I keep this in a branch in case I want to revisit it, but doesn't look useful.
Now the options are just an attribute of the outputs.
It means we have a set of classes for the options.
All the output content is parsed by the classes, including the Layers.
Now the layers support a simple string (with interesting shortcuts), a list of
strings or the original list of dicts.
They can be added from ~/.config/kiplot/plugins/
Also sorted the preflights in the YAML example and allower -v for
--help-list-outputs, needed to know from where are the plugins loaded.
This make the code cleaner and better documented.
Now the usage is more clear, and also a little bit more strict.
I'm using a modified docopt because I preffer using args.option instead of
args['--option'], I also fixed a few flake8 issues in docopt.py.
Pro:
- Much easier to add new outputs and pre-flights
- All options are optional
- Much better configuration syntax check
- Access to data is simpler
Cons:
- Much more source code files
- I focused on one application, not multiple instances running on the same
process.
Implemented in a different way.
For all internal commands now we use Python bindings to fill the zones as
suggested by @arikrupnik in johnbeard/kiplot#11
For 'print_pcb' now we ask KiCad to do it before printing (needs v1.4.1)
- When a BoM operation fails now we show the output of the child process.
(Only enabled when using debug verbosity)
- The error levels 1 and 2 were overlapped with internal Python codes.
- Now we delay the PCB load until we really need it. Which could be never.
_configure_plot_ctrl is called only for "layer" outputs, there is no
point trying to configure other formats.
Also some of the "configuration" were ridiculous calls with an assert
that only tested Python's sanity. Probably optimized out by python
compiler.