Registry / data / ocpsvg

ocpsvg

JSON →
library0.6.0pypypiunverified

A Python library for parsing, manipulating, and rendering SVG (Scalable Vector Graphics) files with support for OCP (Open Canvas Protocol) extensions. Version 0.6.0, active development with no fixed release cadence.

pip install ocpsvg
INSTALL
IMPORT
SIG · OCPSVG
O
ocpsvg
datapythonv0.6.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SVG
✓ import ocpsvg
✗ from ocpsvg import SVG

Load an SVG file, select an element via CSS, modify its attribute, and output the updated XML.

from ocpsvg import SVG # Load an SVG file svg = SVG.from_file('example.svg') # Access SVG elements (using CSS selectors) rect = svg.cssselect('rect')[0] print(rect.attrib) # Modify attributes rect.set('fill', 'blue') # Get the XML string print(svg.tostring())
Debug
Known issues
gotchaSVG.from_file() returns an SVG object, not a string. Use .tostring() to get the XML string, not str() or repr().
fix
Use svg.tostring() instead of print(svg) to serialize XML.
affects: all
gotchaCSS selectors via cssselect() return a list of lxml elements, not SVG-specific objects. Direct attribute manipulation on returned elements works fine.
fix
Remember that the returned elements are standard lxml elements; use .set() and .get() for attributes.
affects: all
Upgrade
Version history
0.6.0latest on PyPI · released Jan 8, 2026
Audit
Dependencies
lxmlrequiredXML parsing of SVG files
cssselectrequiredCSS selector support for element selection
Agent activity
14 hits · last 30 days
node
14
Resources
ocpsvg — pip install ocpsvg · libregistry