Name | vsdx JSON |
Version |
0.5.19
JSON |
| download |
home_page | https://github.com/dave-howard/vsdx |
Summary | vsdx - A python library for processing .vsdx files |
upload_time | 2023-12-31 11:26:20 |
maintainer | |
docs_url | None |
author | Dave Howard |
requires_python | >=3.7 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
## vsdx - A python library for processing Visio .vsdx files
![PyPI](https://img.shields.io/pypi/v/vsdx)
![PyPI - Downloads](https://img.shields.io/pypi/dm/vsdx)
[![pytest](https://github.com/dave-howard/vsdx/actions/workflows/test.yaml/badge.svg)](https://github.com/dave-howard/vsdx/actions/workflows/test.yaml)
[![Documentation Status](https://readthedocs.org/projects/vsdx/badge/?version=latest)](https://vsdx.readthedocs.io/en/latest/?badge=latest)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/vsdx)
[![vsdx](https://snyk.io/advisor/python/vsdx/badge.svg)](https://snyk.io/advisor/python/vsdx)
__.vsdx files can be processed in two ways, directly via python code as in
example 1 below, or indirectly using a jinja template as in example 2__
For quick start documentation please see
[https://vsdx.readthedocs.io/en/latest/quickstart.html](https://vsdx.readthedocs.io/en/latest/quickstart.html)
__Example 1__ code to find a shape with specific text, remove it, and
then save the updated .vsdx file:
```python
from vsdx import VisioFile
filename = 'my_file.vsdx'
# open a visio file
with VisioFile(filename) as vis:
# find shape by its text on first page
shape = vis.pages[0].find_shape_by_text('Shape to remove')
# remove the shape if found
if shape:
shape.remove()
# save a new copy
vis.save_vsdx('shape_removed.vsdx')
```
__Example 2__ creating a new vsdx file from a template and context data
using jinja.
Note that as vsdx does not lend itself well to ordered statements like
`{% if something %}my content{% endif %}` or `{% for x in list_value
%}x={{ x }}{% endfor %}` this package provides mechanisms to help -
refer to tests for more details.
```python
from vsdx import VisioFile
filename = 'my_template_file.vsdx' # file containing jinja code
context = {'value1': 10, 'list_value': [1,2,3]} # data for the template
with VisioFile('my_template_file.vsdx') as vis:
vis.jinja_render_vsdx(context=context)
vis.save_vsdx('my_new_file.vsdx')
```
Please refer to tests/test.py for more usage
examples in the form of pytest tests.
----
### Change Log
- v0.5.19: Fix Page.is_master_page prop and add tests
- v0.5.18: Add support for reading (not creating/saving) .vsdm files (macro-enabled)
- v0.5.17: Fix bug with adding multiple connectors to a vsdx with no existing master files/rels
- v0.5.16: Add support & commit hook tests for Python 3.11 and 3.12
- v0.5.15: Change DataProperty.value from field to property (get/set)
- v0.5.14: Add Page.find_shape_by_attr()
- v0.5.13: Update DataProperty class to get value of a property from V attrib or text
- v0.5.12: Add `Shape.fill_color` and `Shape.text_color` properties with get and set tests
- v0.5.11: Add `Shape.find_shapes_by_regex()` & `Page.find_shapes_by_regex()` - add check in `save_vsdx()` that file is open with more meaningful `VisioFileNotOpen` error
- v0.5.10: Add Shape.angle property
- v0.5.9: Add tests for master shape text property
- v0.5.8: Add `Page.master_base_id` property
- v0.5.7: Add support for nested shapes in `Page.all_shapes` and `Shape.all_shapes`. Add `Page.is_master_page` and `Shape.is_master_shape`.
- v0.5.6: Fix error in `Shape.text` with missing master shape. Improve `VisioFile.remove_page_by_index()` and add `VisioFile.remove_page_by_name()`.
- v0.5.5: Added Shape.universal_name and used in Shape.set_start_and_finish(). Set Page.page_id on open file.
- v0.5.4: Added better (but still incomplete) support for adding connectors between shapes
- v0.5.3: Fixed missing deprecation dependency in setup.py
- v0.5.2: deprecated Page.set_name() method and page.page_name property, in favour of Page.name. Unskipped test: test_shape_center(). Added find_shape.rst doc page
- v0.5.1: added Page/Shape.find_shape_by_property_label_value()/find_shapes_by_property_label_value()
- v0.5.0: deprecated Page.shapes property Page/Shape.sub_shapes() methods in favour of Page/Shape.child_shapes property. Add Shape.all_shapes property, convert Page.all_shapes() method to property
- v0.4.20: Shape.set_cell_value()/set_cell_formula() create new cell if missing, add Media().rectangle and circle props, add Shape.bounds, relative_bounds, and end_arrow props
- v0.4.19: correctly position new connector shapes between 'from' and 'to' shapes
- v0.4.18: add page.page_name, width and height properties
- v0.4.17: register xml namespaces to improve compatibility of xml output
- v0.4.16: Add Geometry class to read Shape geometry
- v0.4.15: Add requirement for Jinja2 to package
- v0.4.14: Include media/*.vsdx files in package
- v0.4.13: Fix for master shape property inheritance / value overrides
- v0.4.12: Add support for absolute paths
- v0.4.11: Add support for master shape data properties, with related tests
- v0.4.10: Add methods (`Shape.find_shape_by_property_label()` and `Shape.find_shapes_by_property_label`) to find shape or shapes by data property name.
- v0.4.9: Add support for creating new connection between two objects. Fix ShapeProperty.value, and add label, sort_key, value_type and prompt
- v0.4.8: Support nested loops/showifs and combo of loop and if in same shape.
- v0.4.7: Python 3.10.0rc1 added to test suite. Add `Shape.data_properties` property, and new class `ShapeProperty` to represent Visio Shape Data
- v0.4.6: Add support for nested jinja loops in one shape
- v0.4.5: Fix bug where some shapes have no parent, and inserting shape into empty page
- v0.4.4: Added support for master page shape inheritance, ability to get `Shape.master_shape`, ability to
update master shapes and persist changes to master shapes in `save_vsdx()`
- v0.4.3: Added support for including/excluding pages via Jinja with `{% showif <statement> %}` in page name
- v0.4.2: Added `VisioFile.add_page_at()` method taking `index` to allow insertion
at a specific point; Added `VisionFile.copy_page()` method to copy an existing page
and insert at a specific index or relative to copied page (using `PagePosition` enum).
- v0.4.1: Added support for self referencing calculations in Jinja statements,
such as `{% set self.x = self x + n * 3.2 %}`
- v0.4.0: Added `VisioFile.jinja_set_selfs` to allow setting shape x and
y properties in Jinja template. Setting values, calculations, or if
statements are supported e.g. `{% set self.x = 1.5 %}` or `{% set
self.y = n * 3 %}` or `{% set self.x = 1.0 if n else 2.0 %}`
- v0.3.5: Added `VisioFile.add_page()` method and tests
- v0.3.4: Added `VisioFile.remove_page_by_index()` method to remove a
page, with associated test
- v0.3.3: Added code of conduct and contributing guides
- v0.3.2: updated README and updated tests for improved compatibility
- v0.3.1: add jinja rendering support for if statements, via
`VisioFile.jinja_render_vsdx()` - similar to for loops but using a `{%
showif statement %}` in text of group shape controls whether that
group shape is included in vsdx file rendered. Note that the showif
statement is replaced with a standard if statement around the group
shape prior to rendering. Refer to test.py::test_jinja_if() for an
example
- v0.3.0: update jinja rendering to support for loops, where for
statement is at start of group shape text, endfor is automatically
inserted before processing. Refer to test.py::test_basic_jinja_loop()
for code and test_jinja_loop.vsdx for content.
- v0.2.10: add `VisioFile.jinja_render_vsdx()` - applying jinja
processing to Shape.text only
- v0.2.9: check that Page has shapes tag when in shape_copy(), add test
to copy shape to new page
- v0.2.8: find max shape ID in Page before creating Shape in
`Shape.copy()`. Find and load master pages when file is opened, store
in VisioFile.master_page_objects and .master_pages
- v0.2.7: add `Shape.copy()` method
- v0.2.6: added `Page.get_connectors_between()` to get zero or many
connectors between two shapes, by shape id or text
- 0.2.5: Add new Shape properties connected_shapes (list of Shape
objects) and connects (list of Connect objects) properties to allow
related shapes to be identified (i.e. shapes and connectors) and
provide information on the relationship, in new Connect object. Also
new properties of shape begin_x/y, end_x/y, plus height/width
setters
- 0.2.4: Added find_replace(old, new) method to Shape and Page classes
to recursively replace old with new
- 0.2.3: Updated tests to output files to an /out folder. Added test
vsdx file with compound shape. Updated Shape text getter/setter
- 0.2.2: Added x & y location setters to Shape, and move(x_delta,
y_delta) method - both with related tests
Raw data
{
"_id": null,
"home_page": "https://github.com/dave-howard/vsdx",
"name": "vsdx",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Dave Howard",
"author_email": "dave@codypy.com",
"download_url": "https://files.pythonhosted.org/packages/17/f2/24171efb3efb763cabf291085c135fea4bd1937fb1618b6a75afb3f66abc/vsdx-0.5.19.tar.gz",
"platform": null,
"description": "## vsdx - A python library for processing Visio .vsdx files\n\n![PyPI](https://img.shields.io/pypi/v/vsdx)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/vsdx)\n\n[![pytest](https://github.com/dave-howard/vsdx/actions/workflows/test.yaml/badge.svg)](https://github.com/dave-howard/vsdx/actions/workflows/test.yaml)\n[![Documentation Status](https://readthedocs.org/projects/vsdx/badge/?version=latest)](https://vsdx.readthedocs.io/en/latest/?badge=latest)\n\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/vsdx)\n[![vsdx](https://snyk.io/advisor/python/vsdx/badge.svg)](https://snyk.io/advisor/python/vsdx)\n\n__.vsdx files can be processed in two ways, directly via python code as in\nexample 1 below, or indirectly using a jinja template as in example 2__\n\nFor quick start documentation please see\n[https://vsdx.readthedocs.io/en/latest/quickstart.html](https://vsdx.readthedocs.io/en/latest/quickstart.html)\n\n__Example 1__ code to find a shape with specific text, remove it, and\nthen save the updated .vsdx file:\n\n```python\nfrom vsdx import VisioFile\n\nfilename = 'my_file.vsdx'\n# open a visio file\nwith VisioFile(filename) as vis:\n # find shape by its text on first page\n shape = vis.pages[0].find_shape_by_text('Shape to remove')\n # remove the shape if found\n if shape:\n shape.remove()\n # save a new copy\n vis.save_vsdx('shape_removed.vsdx')\n```\n\n__Example 2__ creating a new vsdx file from a template and context data\nusing jinja. \nNote that as vsdx does not lend itself well to ordered statements like\n`{% if something %}my content{% endif %}` or `{% for x in list_value\n%}x={{ x }}{% endfor %}` this package provides mechanisms to help -\nrefer to tests for more details.\n\n```python\nfrom vsdx import VisioFile\n\nfilename = 'my_template_file.vsdx' # file containing jinja code\ncontext = {'value1': 10, 'list_value': [1,2,3]} # data for the template\nwith VisioFile('my_template_file.vsdx') as vis: \n vis.jinja_render_vsdx(context=context)\n vis.save_vsdx('my_new_file.vsdx')\n```\n\nPlease refer to tests/test.py for more usage\nexamples in the form of pytest tests.\n\n----\n\n### Change Log\n- v0.5.19: Fix Page.is_master_page prop and add tests\n- v0.5.18: Add support for reading (not creating/saving) .vsdm files (macro-enabled)\n- v0.5.17: Fix bug with adding multiple connectors to a vsdx with no existing master files/rels\n- v0.5.16: Add support & commit hook tests for Python 3.11 and 3.12\n- v0.5.15: Change DataProperty.value from field to property (get/set)\n- v0.5.14: Add Page.find_shape_by_attr()\n- v0.5.13: Update DataProperty class to get value of a property from V attrib or text\n- v0.5.12: Add `Shape.fill_color` and `Shape.text_color` properties with get and set tests\n- v0.5.11: Add `Shape.find_shapes_by_regex()` & `Page.find_shapes_by_regex()` - add check in `save_vsdx()` that file is open with more meaningful `VisioFileNotOpen` error\n- v0.5.10: Add Shape.angle property\n- v0.5.9: Add tests for master shape text property\n- v0.5.8: Add `Page.master_base_id` property\n- v0.5.7: Add support for nested shapes in `Page.all_shapes` and `Shape.all_shapes`. Add `Page.is_master_page` and `Shape.is_master_shape`. \n- v0.5.6: Fix error in `Shape.text` with missing master shape. Improve `VisioFile.remove_page_by_index()` and add `VisioFile.remove_page_by_name()`.\n- v0.5.5: Added Shape.universal_name and used in Shape.set_start_and_finish(). Set Page.page_id on open file.\n- v0.5.4: Added better (but still incomplete) support for adding connectors between shapes\n- v0.5.3: Fixed missing deprecation dependency in setup.py\n- v0.5.2: deprecated Page.set_name() method and page.page_name property, in favour of Page.name. Unskipped test: test_shape_center(). Added find_shape.rst doc page\n- v0.5.1: added Page/Shape.find_shape_by_property_label_value()/find_shapes_by_property_label_value()\n- v0.5.0: deprecated Page.shapes property Page/Shape.sub_shapes() methods in favour of Page/Shape.child_shapes property. Add Shape.all_shapes property, convert Page.all_shapes() method to property\n- v0.4.20: Shape.set_cell_value()/set_cell_formula() create new cell if missing, add Media().rectangle and circle props, add Shape.bounds, relative_bounds, and end_arrow props\n- v0.4.19: correctly position new connector shapes between 'from' and 'to' shapes \n- v0.4.18: add page.page_name, width and height properties\n- v0.4.17: register xml namespaces to improve compatibility of xml output\n- v0.4.16: Add Geometry class to read Shape geometry\n- v0.4.15: Add requirement for Jinja2 to package\n- v0.4.14: Include media/*.vsdx files in package\n- v0.4.13: Fix for master shape property inheritance / value overrides\n- v0.4.12: Add support for absolute paths\n- v0.4.11: Add support for master shape data properties, with related tests\n- v0.4.10: Add methods (`Shape.find_shape_by_property_label()` and `Shape.find_shapes_by_property_label`) to find shape or shapes by data property name.\n- v0.4.9: Add support for creating new connection between two objects. Fix ShapeProperty.value, and add label, sort_key, value_type and prompt \n- v0.4.8: Support nested loops/showifs and combo of loop and if in same shape.\n- v0.4.7: Python 3.10.0rc1 added to test suite. Add `Shape.data_properties` property, and new class `ShapeProperty` to represent Visio Shape Data\n- v0.4.6: Add support for nested jinja loops in one shape\n- v0.4.5: Fix bug where some shapes have no parent, and inserting shape into empty page\n- v0.4.4: Added support for master page shape inheritance, ability to get `Shape.master_shape`, ability to \n update master shapes and persist changes to master shapes in `save_vsdx()`\n- v0.4.3: Added support for including/excluding pages via Jinja with `{% showif <statement> %}` in page name\n- v0.4.2: Added `VisioFile.add_page_at()` method taking `index` to allow insertion\n at a specific point; Added `VisionFile.copy_page()` method to copy an existing page \n and insert at a specific index or relative to copied page (using `PagePosition` enum). \n- v0.4.1: Added support for self referencing calculations in Jinja statements, \n such as `{% set self.x = self x + n * 3.2 %}`\n- v0.4.0: Added `VisioFile.jinja_set_selfs` to allow setting shape x and\n y properties in Jinja template. Setting values, calculations, or if\n statements are supported e.g. `{% set self.x = 1.5 %}` or `{% set\n self.y = n * 3 %}` or `{% set self.x = 1.0 if n else 2.0 %}`\n- v0.3.5: Added `VisioFile.add_page()` method and tests\n- v0.3.4: Added `VisioFile.remove_page_by_index()` method to remove a\n page, with associated test\n- v0.3.3: Added code of conduct and contributing guides\n- v0.3.2: updated README and updated tests for improved compatibility\n- v0.3.1: add jinja rendering support for if statements, via\n `VisioFile.jinja_render_vsdx()` - similar to for loops but using a `{%\n showif statement %}` in text of group shape controls whether that\n group shape is included in vsdx file rendered. Note that the showif\n statement is replaced with a standard if statement around the group\n shape prior to rendering. Refer to test.py::test_jinja_if() for an\n example\n- v0.3.0: update jinja rendering to support for loops, where for\n statement is at start of group shape text, endfor is automatically\n inserted before processing. Refer to test.py::test_basic_jinja_loop()\n for code and test_jinja_loop.vsdx for content.\n- v0.2.10: add `VisioFile.jinja_render_vsdx()` - applying jinja\n processing to Shape.text only\n- v0.2.9: check that Page has shapes tag when in shape_copy(), add test\n to copy shape to new page\n- v0.2.8: find max shape ID in Page before creating Shape in\n `Shape.copy()`. Find and load master pages when file is opened, store\n in VisioFile.master_page_objects and .master_pages\n- v0.2.7: add `Shape.copy()` method\n- v0.2.6: added `Page.get_connectors_between()` to get zero or many\n connectors between two shapes, by shape id or text\n- 0.2.5: Add new Shape properties connected_shapes (list of Shape\n objects) and connects (list of Connect objects) properties to allow\n related shapes to be identified (i.e. shapes and connectors) and\n provide information on the relationship, in new Connect object. Also\n new properties of shape begin_x/y, end_x/y, plus height/width\n setters\n- 0.2.4: Added find_replace(old, new) method to Shape and Page classes\n to recursively replace old with new\n- 0.2.3: Updated tests to output files to an /out folder. Added test\n vsdx file with compound shape. Updated Shape text getter/setter\n- 0.2.2: Added x & y location setters to Shape, and move(x_delta,\n y_delta) method - both with related tests\n\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "vsdx - A python library for processing .vsdx files",
"version": "0.5.19",
"project_urls": {
"Documentation": "https://vsdx.readthedocs.io/en/latest/",
"Homepage": "https://github.com/dave-howard/vsdx"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c76e937bab07bcec373494ddc62205a26fe2420f9ac53936bc2d84c929f1e7e2",
"md5": "3396814badaf79444203e9557f1c19d8",
"sha256": "bf30f7807a5d63eb1ece0be5616c22688b0938c8bf96c0804c0026e2d2659603"
},
"downloads": -1,
"filename": "vsdx-0.5.19-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3396814badaf79444203e9557f1c19d8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 52087,
"upload_time": "2023-12-31T11:26:18",
"upload_time_iso_8601": "2023-12-31T11:26:18.372493Z",
"url": "https://files.pythonhosted.org/packages/c7/6e/937bab07bcec373494ddc62205a26fe2420f9ac53936bc2d84c929f1e7e2/vsdx-0.5.19-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "17f224171efb3efb763cabf291085c135fea4bd1937fb1618b6a75afb3f66abc",
"md5": "48ad31ea54696e02d580a0659f83ce71",
"sha256": "4445eecc1ee34cbe722351333f9e3a67ad29ba85b9c8e3f7c435f276e1f9e84e"
},
"downloads": -1,
"filename": "vsdx-0.5.19.tar.gz",
"has_sig": false,
"md5_digest": "48ad31ea54696e02d580a0659f83ce71",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 55198,
"upload_time": "2023-12-31T11:26:20",
"upload_time_iso_8601": "2023-12-31T11:26:20.530478Z",
"url": "https://files.pythonhosted.org/packages/17/f2/24171efb3efb763cabf291085c135fea4bd1937fb1618b6a75afb3f66abc/vsdx-0.5.19.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-31 11:26:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dave-howard",
"github_project": "vsdx",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "vsdx"
}