vpype 1.9.0
A commented version of these release notes is available in my annotated release notes post.
Note: This is the last version of vpype to support Python 3.7.
New features and improvements
-
Added support for global and per-layer properties (#359)
This feature introduces metadata to the pipeline in the form of properties which may either be attached to specific layers (layer property) or all of them (global property). Properties are identified by a name and may be of arbitrary type (e.g. integer, floating point, color, etc.). A number of system properties with a specific name (prefixed with
vp_
) and type are introduced to support some of the new features. -
Layer color, pen width, and name are now customizable (#359, #376, #389)
- The
read
commands now sets layer color, pen width, and name based on the input SVG if possible. - The new
color
,penwdith
, andname
commands can be used to modify layer color, pen width, and name. - The new
pens
command can apply a predefined or custom scheme on multiple layers at once. Two common schemes are built-in:rgb
andcmyk
. Custom schemes can be defined in the configuration file. - The
show
andwrite
commands now take into account these layer properties.
- The
-
The
read
command now records the source SVG paths in thevp_source
andvp_sources
system properties (see the documentation) (#397, #406, #408) -
Added property substitution to CLI user input (#395)
The input provided to most commands' arguments and options may now contain substitution patterns which will be replaced by the corresponding property value. Property substitution patterns are marked with curly braces (e.g.
{property_name}
) and support the same formatting capabilities as the Python'sformat()
function. -
Added expression substitution to CLI user input (#397)
The input provided to most command's arguments and options may now contain expression patterns which are evaluated before the command is executed. Expression patterns are marked with the percent symbol
%
(e.g.%3+4%
) and support a large subset of the Python language. A lot of examples were added in the cookbook. -
Added the
--attr
option to theread
command to (optionally) sort geometries by attributes (e.g. stroke color, stroke width, etc.) instead of by SVG layer (#378, #389) -
The
read
andwrite
commands now preserve a sub-set of SVG attributes (experimental) (#359, #389)The
read
command identifies SVG attributes (e.g.stroke-dasharray
) which are common in all geometries within each layer. These attributes are saved as layer properties with their name prefixed withsvg_
(e.g.svg_stroke-dasharray
). Thewrite
command can optionally restore these attributes in the output SVG using the--restore-attribs
option. -
Introduced new commands for low-level inspection and modification of properties (#359)
propget
: gets the value of a given global or layer propertyproplist
: lists all global and/or layer properties and their valuepropset
: sets the value of a given global or layer propertypropdel
: deletes a given global or layer propertypropclear
: removes all global and/or layer properties
-
Updated layer operation commands to handle properties (#359)
- When a single source layer is specified and
--prob
is not used, thelcopy
andlmove
commands now copy the source layer's properties to the destination layer (possibly overwriting existing properties). - When
--prob
is not used, thelswap
command now swaps the layer properties as well. - These behaviors can be disabled with the
--no-prop
option.
- When a single source layer is specified and
-
Improved block processors (#395, #397)
- Simplified and improved the infrastructure underlying block processors for better extensibility.
- The
begin
marker is now optional and implied whenever a block processor command is encountered. Note: theend
marker must always be used to mark the end of a block. - Commands inside the block now have access to the current layer structure and its metadata.
-
Improved the
grid
block processor (#397)- The page size is now updated according to the grid size.
- The command now sets expression variables for use in the nested pipeline.
- Cells are now first iterated along rows instead of columns.
-
The
repeat
block processor now sets expression variables for use in the nested pipeline (#397) -
Added
forfile
block processor to iterate over a list of file (#397) -
Added
forlayer
block processor to iterate over the existing layers (#397) -
Added the
eval
command as placeholder for executing expressions (#397) -
The
read
command now will ignore a missing file if--no-fail
parameter is used (#397) -
Changed the initial default target layer to 1 (#395)
Previously, the first generator command of the pipeline would default to create a new layer if the
--layer
option was not provided. This could lead to unexpected behaviour in several situation. The target layer is now layer 1. For subsequent generators, the existing behaviour of using the previous generator target layer as default remains. -
Added
pagerotate
command, to rotate the page layout (including geometries) by 90 degrees (#404) -
Added
--keep
option to theldelete
command (to delete all layers but those specified) (#383) -
Providing a non-existent layer ID to any
--layer
parameter now generates a note (visible with--verbose
) (#359, #382)
Bug fixes
- Fixed an issue with the
random
command when using non-square area (#395)
API changes
-
Moved all CLI-related APIs from
vpype
tovpype_cli
(#388)A number of CLI-related APIs remained in the
vpype
package for historical reasons. They are now located in thevpype_cli
package for consistency and to allow for future extensions.- Moved the following decorators, classes, and functions from the
vpype
package to thevpype_cli
package. Importing fromvpype
will now generate a deprecation warning:@block_processor
@generator
@global_processor
@layer_processor
@pass_state
AngleType
LayerType
LengthType
PageSizeType
multiple_to_layer_ids()
single_to_layer_id()
- Moved and renamed
vpype.VpypeState
tovpype_cli.State
. Using the old name will generate a deprecation warning. - Removed the following long-time deprecated aliases:
vpype.Length
(alias tovpype_cli.LengthType
)vpype.VectorData
(alias tovpype.Document
)vpype.convert()
(alias tovpype.convert_length()
)vpype.convert_page_format()
(alias tovpype.convert_page_size()
)vpype.PAGE_FORMATS
(alias tovpype.PAGE_SIZES
)
- Moved the following decorators, classes, and functions from the
-
Added support for property substitution in Click type subclasses (#395)
- Existing type classes (
AngleType
,LengthType
,PageSizeType
) now support property substitution. - Added
TextType
andIntegerType
to be used instead ofstr
, resp.int
, when property substitution support is desired.
- Existing type classes (
-
Updated the block processor API (breaking change) (#395)
Block processor commands (decorated with
@block_processor
) are no longer sub-classes ofBlockProcessor
(which has been removed). The are instead regular functions (like commands of other types) which take aState
instance and a list of processors as first arguments. -
Added methods to
vpype_cli.State
to support expression and property substitution, deferred arguments/options evaluation and block processor implementations (#395, #397) -
vpype.Document
andvpype.LineCollection
have multiple, non-breaking additions to support metadata (in particular through thevpype._MetadataMixin
mix-in class) (#359, #397) -
Renamed
vpype.Document.empty_copy()
tovpype.Document.clone()
for coherence withvpype.LineCollection
(the old name remains for backward compatibility) (#359, #380) -
Added
vpype.read_svg_by_attribute()
to read SVG while sorting geometries by arbitrary attributes (#378) -
Added an argument to
vpype_cli.execute()
to pass global option such as--verbose
(#378)
Other changes
- Renamed the bundled config file to
vpype_config.toml
(#359) - Pinned poetry-core to 1.0.8 to enable editable installs (#410)
- Changed dependencies to dataclasses (instead of attrs) and tomli (instead of toml) (#362)
- Removed dependency to click-plugin (#388)
- Improved documentation, in particular the Fundamentals and Cookbook sections (#359, #363, #397)