Support parsing of xml file which export color petri net from CPNTools
Project description
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'
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cpntools4py-1.2.2.tar.gz.
File metadata
- Download URL: cpntools4py-1.2.2.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b81bd2ae296735dcf2d4cae873b01b87ac2657bd8f65bacfd438dacde0011405
|
|
| MD5 |
fbd1923bbe6af6d7ea6557f30500c9b9
|
|
| BLAKE2b-256 |
d880309143962546bec21ec8b961ef191a8a117f64437933c362e69c05bfa7ab
|
File details
Details for the file cpntools4py-1.2.2-py3-none-any.whl.
File metadata
- Download URL: cpntools4py-1.2.2-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ac7531b96a26df76bced8339fc31a9b1c3687c7247a2cb829a6ff2c412b68c5
|
|
| MD5 |
67238aa233d99913f79f88597e7f0447
|
|
| BLAKE2b-256 |
6282a76f8ba65d5cc1148c4ad7edb73fd7583db34071e929bfa44cf90945d573
|