Skip to main content

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


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.0.tar.gz (29.3 kB view details)

Uploaded Source

File details

Details for the file plcopen-1.0.0.tar.gz.

File metadata

  • Download URL: plcopen-1.0.0.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for plcopen-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fc245c2a050a4e44866a462c250f473a43072c2e0b01a1801d2ef00c164c3bea
MD5 8e5b82a7c3347b8829e9e34345ed13af
BLAKE2b-256 d5e79fc860853ad40b1d57c42e59901aaf2e5c488fd322d53f39483387c49927

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page