Skip to main content

CPNTools4Py

CPNTools4Py is a small python 3 scripts. These scripts support parsing of xml file which export color petri net from CPNTools, define a data structure for Petri nets and labelled partial orders. It is completely open source and be used in academia.

First Example

A very simple example, to what you appetite:

import cpntools4py
xml_doc = cpntools4py.read_xml('<path_to_xml_file>')
cpn = cpntools4py.CPN(xml_doc)

print(cpn.places) # Get places

Reference

Module cpntools4py

This is CPNTools4Py main module, it holds the various Petrei net elements, arcs, places, transitions.

Method cpntools4py.read_xml

def read_xml(file_path):

Read Xml file editing by CPNTools.

xml_doc = read_xml('/path/to/PetriNet.xml')

Call API

  • str file_path: Input the XML file of Petri nets editing by CPNTools.
  • return root Element: Return an object that holds the root element of the node information of CPNTools.

Method cpntools4py.to_snakes

def to_snakes(cpn)

Convert to SNAKES from CPNTools

xml_doc = cpntools4py.read_xml('<path_to_xml_file>')
cpn = cpntools4py.CPN(xml_doc)
net = cpntools4py.to_snakes(cpn)

Call API

  • object CPN: Input the CPN object.
  • return object net: return the SNAKES net object.

Module cpntools4py.petri_net

This is CPNTools4Py data structure module, it holds the various Petrei net elements, arcs, places, transitions.

Class Place

A place of a Petri net. Place class has 4 variables, each of which returns id, text, type and tokens. Each variable holds the Place name, color attirbute, and initial marking set by CPNTools. Since id is an identification number, it is automatically assinged at the time of generation by CPNTools.

xml_doc = cpntools4py.read_xml('<path_to_xml_file>')
cpn = cpntools4py.CPN(xml_doc)

for place in cpn.places:
	print(place.id)
	# 'id0123456789'

Class Transitions

A Transition of a Petri net. Transition class has 3 variables, each of which returns id, text and time. Each variable holds the Transition name and time inscription. id is and identification number.

xml_doc = cpntools4py.read_xml('<path_to_xml_file>')
cpn = cpntools4py.CPN(xml_doc)

for transition in cpn.transitions:
	print(transition.text)
	# 'Trans1'

Class Arc

A Arc of a Petri net. Arc class has 4 variables, each of which returns id, orientation, placeend and transend. The Arc class holds the connection information between places and transitions. orientation holds the orientation of the arc, placened and tranend holdes the nodes to be connected.

xml_doc = cpntools4py.read_xml('<path_to_xml_file>')
cpn = cpntools4py.CPN(xml_doc)

for arc in cpn.arcs:
	print(arc.orientation)
	# 'PtoT'

Metadata

Release files for cpntools4py 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cpntools4py 1.2.2
File Size Uploaded Provenance
cpntools4py-1.2.2.tar.gz 5.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cpntools4py 1.2.2
File Interpreter ABI Platform
cpntools4py-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 kB

Release files / cpntools4py-1.2.2.tar.gz

Download URL cpntools4py-1.2.2.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b81bd2ae296735dcf2d4cae873b01b87ac2657bd8f65bacfd438dacde0011405
BLAKE2b-256 checksum
How to use checksums
d880309143962546bec21ec8b961ef191a8a117f64437933c362e69c05bfa7ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.0

Release files / cpntools4py-1.2.2-py3-none-any.whl

Download URL cpntools4py-1.2.2-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ac7531b96a26df76bced8339fc31a9b1c3687c7247a2cb829a6ff2c412b68c5
BLAKE2b-256 checksum
How to use checksums
6282a76f8ba65d5cc1148c4ad7edb73fd7583db34071e929bfa44cf90945d573
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.0

Security for cpntools4py 1.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page