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: expression substitution #397

Merged
merged 25 commits into from
Feb 21, 2022
Merged

Feature: expression substitution #397

merged 25 commits into from
Feb 21, 2022

Conversation

abey79
Copy link
Owner

@abey79 abey79 commented Feb 7, 2022

Description

This PR introduces expression substitution on most user input. Expressions are marked with % characters and are a subset of the Python language. They are interpreted using the asteval package (see doc). See doc for the built-in symbols.

New commands:

  • forfile
  • forlayer
  • eval

Misc other changes:

  • The read command now will not fail if the provided file doesn't exist and the --no-fail parameter is used
  • grid now sets page size
  • read now sets/update the vp_source/vp_sources system props
  • added --no-fail to read
  • added explicit support for vp_sources update in vp.Document
  • Fixed pycharm type error with CliRunner.execute()
  • Added reference SVG tests
  • Major doc update
  • Minor update to docstrings
  • pined shapely to 1.8.0 due to installer breaking with the current 1.8.1 (missing geos lib)
  • Updated deps

Fixes #392
Fixes #381

Checklist

  • test all README examples
  • 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/)

@codecov
Copy link

codecov bot commented Feb 7, 2022

Codecov Report

Merging #397 (4054b9b) into master (22356c8) will increase coverage by 0.18%.
The diff coverage is 93.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #397      +/-   ##
==========================================
+ Coverage   93.54%   93.72%   +0.18%     
==========================================
  Files          56       59       +3     
  Lines        4666     5135     +469     
  Branches      648      717      +69     
==========================================
+ Hits         4365     4813     +448     
- Misses        201      207       +6     
- Partials      100      115      +15     
Impacted Files Coverage Δ
vpype_cli/write.py 85.71% <66.66%> (ø)
vpype/model.py 91.72% <80.00%> (-1.19%) ⬇️
vpype_cli/types.py 88.80% <82.35%> (+3.08%) ⬆️
vpype_cli/substitution.py 91.33% <91.33%> (ø)
vpype_cli/state.py 95.31% <91.42%> (-4.69%) ⬇️
vpype/io.py 84.09% <95.00%> (+1.81%) ⬆️
vpype_cli/blocks.py 97.29% <96.77%> (-2.71%) ⬇️
tests/test_substitution.py 98.31% <98.31%> (ø)
tests/conftest.py 83.14% <100.00%> (+7.73%) ⬆️
tests/test_commands.py 98.99% <100.00%> (+0.04%) ⬆️
... and 11 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 22356c8...4054b9b. Read the comment docs.

@abey79 abey79 changed the title Feature expressions Feature: expression substitution Feb 7, 2022
@abey79 abey79 force-pushed the feature-expressions branch 3 times, most recently from 9a594c1 to d8b104d Compare February 14, 2022 15:48
Expression between `%` markers are now evaluated by asteval.

- Fixed pycharm type error with CliRunner.execute()
- Minor update to docstrings
- Updated deps
- added `forfile` command
- added `forlayer` command
- added FileType and PathType (with prop/exp substitution)
- added variables to `grid` and `repeat`
- vp.Document: added option to copy metadata with `replace()`
- `State`: renamed CM to temp_document()
- `State`: added CM to set variables
- fixed tests
- improved coverage
- quotes for path (windows fix?)
- added substitution to LayerType
- added `--no-fail` to read
- added glob and convert_{length, angle, page_size} to expr symbols
- disabled numpy from expr
- grid now sets page size
- fixed logging to print fully substituted arguments
- added args logging to @block_processor
- added example for interactive grid
- doc: renamed metadata section to properties
@abey79 abey79 force-pushed the feature-expressions branch from ffa53c2 to 270bb4c Compare February 15, 2022 12:12
@sonarqubecloud
Copy link

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 f69c7f0 into master Feb 21, 2022
@abey79 abey79 deleted the feature-expressions branch February 21, 2022 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant