vpype_cli

This module implements vpype’s CLI interface and the execute() function.

Functions

execute

Execute a vpype pipeline.

Functions

execute(pipeline, document=None)

Execute a vpype pipeline.

This function serves as a Python API to vpype’s pipeline. It can be used from a regular Python script (as opposed to the vpype CLI which must be used from a console or via os.system().

If a vpype.Document instance is provided, it will be preloaded in the pipeline before the first command executes. The pipeline’s content after the last command is returned as a vpype.Document instance.

Examples

Read a SVG file, optimize it and return the result as a vpype.Document instance:

>>> doc = execute("read input.svg linemerge linesimplify linesort")

Optimize and save a vpype.Document instance:

>>> doc = vp.Document()
>>> # populate `doc` with some graphics
>>> execute("linemerge linesimplify linesort write output.svg", doc)
Parameters
  • pipeline (str) -- vpype pipeline as would be used with vpype CLI

  • document (Optional[Document]) -- if provided, is perloaded in the pipeline before the first command executes

Return type

Document

Returns

pipeline’s content after the last command executes