Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: property substitution and block overhaul #395

Merged
merged 8 commits into from
Feb 3, 2022

Conversation

abey79
Copy link
Owner

@abey79 abey79 commented Feb 3, 2022

Description

The input provided to most commands' arguments and options may now contain substitution patterns which will be replaced by the corresponding property value.

This created the need for deferred evaluation of click-provided arguments and options. The type classes now return subclass of _DeferredEvaluator which are detected by the command decorators (@generator, etc.) and replaced by their evaluated value before they reach the command function.

In turn, implementing the above lead to the overhaul of the block processor sub-system. Block processors are now implemented as functions and the nested command have access to the current layer structure. Also, begin is now optional.

Also:

  • Added property substitution function to vpype_cli.State
  • Added mechanism to perform deferred evaluation of Click argument/option value
  • Added TextType and IntegerType classes to use as Click type instead of str, responding. int to perform property substitution
  • Updated existing types to perform property substitution
  • The default target layer for generators is now 1 (was new)
  • grid now iterates along lines first
  • Document.clone() now has an option to keep the layer structure/metadata (without line data)
  • fixed an issue where metadata dict could be shared across Doc/LC, leading to potential bugs.
  • fixed a bug with random when using non-square area
  • Various docstring fixes and improvements
  • assert_image_similarity now skips the test when the reference image is saved

Fixes #393

Minor bug addressed in #396

Checklist

  • feature/fix implemented
  • code formatting ok (black and isort)
  • mypy returns no error
  • tests added/updated and pytest succeeds
  • documentation added/updated
    • command docstring and option/argument help
    • README.md updated (Feature Overview)
    • CHANGELOG.md updated
    • added new command to reference.rst
    • RTD doc updated and building with no error (make clean && make html in docs/)

The input provided to most commands' arguments and options may now contain substitution patterns which will be replaced by the corresponding property value.

This created the need for deferred evaluation of click-provided arguments and options. The type classes now return subclass of `_DeferredEvaluator` which are detected by the command decorators (`@generator`, etc.) and replaced by their evaluated value before they reach the command function.

In turn, implementing the above lead to the overhaul of the block processor sub-system. Block processors are now implemented as functions and the nested command have access to the current layer structure.

* Added property substitution function to `vpype_cli.State`
* Added mechanism to perform deferred evaluation of Click argument/option value
* Added `TextType` class to use as Click type instead of `str` so property substitution is performed.
* Updated types to perform property substitution
* `grid` now iterates along lines first
* Document.clone() now has an option to keep the layer structure/metadata (without line data)
* fixed an issue where metadata dict could be shared across Doc/LC, leading to potential bugs.
* fixed a bug with `random` when using non-square area
* Various docstring fixes and improvements
* `assert_image_similarity` now skips the test when the reference image is saved
Fixed doc heading level
@codecov
Copy link

codecov bot commented Feb 3, 2022

Codecov Report

Merging #395 (cb8ee21) into master (63a44cc) will increase coverage by 0.65%.
The diff coverage is 98.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #395      +/-   ##
==========================================
+ Coverage   92.89%   93.54%   +0.65%     
==========================================
  Files          55       56       +1     
  Lines        4587     4663      +76     
  Branches      639      648       +9     
==========================================
+ Hits         4261     4362     +101     
+ Misses        217      201      -16     
+ Partials      109      100       -9     
Impacted Files Coverage Δ
tests/conftest.py 75.40% <ø> (+5.71%) ⬆️
tests/test_commands.py 98.95% <ø> (ø)
vpype_cli/write.py 85.71% <83.33%> (+0.80%) ⬆️
vpype_cli/cli.py 76.92% <88.23%> (+3.18%) ⬆️
tests/test_hpgl.py 100.00% <100.00%> (ø)
tests/test_model.py 100.00% <100.00%> (ø)
tests/test_property_substitution.py 100.00% <100.00%> (ø)
vpype/model.py 92.91% <100.00%> (+0.16%) ⬆️
vpype_cli/blocks.py 100.00% <100.00%> (ø)
vpype_cli/decorators.py 95.29% <100.00%> (+1.17%) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63a44cc...cb8ee21. Read the comment docs.

- Added default target layer change to CHANGELOG.md

Fixes #393
- Fixed dead code in conf.py

Thanks SonarCloud!
- fixed missing TextType in propset, propget, propdel and pens
- fixed argument type to AngleType for skew
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@abey79 abey79 merged commit 6c347bd into master Feb 3, 2022
@abey79 abey79 deleted the feature-text-format-v2 branch February 3, 2022 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: make begin optional
1 participant