A utility package for PLCopenXML parsing/generation based on xsdata (https://xsdata.readthedocs.io/)
Project description
Python PLCopenXML
A Python class model for PLCopen XML.
The class model has been generated with xsdata. Xsdata can also be used to parse/serialize PLCopen XML files to/from the class model.
To be able to parse PLCopen XML files generated by Codesys, the class model also contains some manually created classes for Codesys-specific stuff.
Usage
from plcopen import *
# parsing an existing PLCopen XML file
with open(path_to_plcopen_xml_file, 'rb') as plcopen_xml_file:
content = plcopen_xml_file.read()
parser = XmlParser(context=XmlContext())
return parser.from_bytes(content, Project)
# working on the parsed project
first_pou = plcopen_project.types.pous[0]
# serializing the project
with open(path_to_plcopen_xml_file, 'w') as plcopen_xml_file:
serializer = XmlSerializer(context=context)
serializer.config.pretty_print = True
content = serializer.render(project)
serializer.write(content)
Note: More information about parsing and serializing can be found in the xsdata docs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
plcopen-1.0.1.tar.gz
(29.5 kB
view details)
File details
Details for the file plcopen-1.0.1.tar.gz
.
File metadata
- Download URL: plcopen-1.0.1.tar.gz
- Upload date:
- Size: 29.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 509f217ae7caa90c256279afc46a85f2f1ef991d6c7b2fee39ca6fc18a5a2e59 |
|
MD5 | 8c5a749cd40be9d26f5bec08429f94e9 |
|
BLAKE2b-256 | fda023fae97c6e42a792565bebbe6388a7acfc04e130257bf5390eacbeb5d45a |