cimrdf.py
Generate Python data structures from CIM RDF profiles, parse and serialize CIM-compliant information objects, according to IEC 61970-501 standard.
Installing
$ pip install cimrdf.py
or
$ git clone https://github.com/bressanmarcos/cimrdf.py.git
$ cd cimrdf.py
$ python setup.py install
Using
- Create your CIM RDF artifact with your preferred utils
- Convert it into Python data structures with:
cimrdfpy input-rdfs.xml output.py
Creating CIM RDF instances
3a. Use the generated classes from output.py to create your instances
from output import *
ei = EquivalentInjection()
ei.mRID = 'EquivalentNW243'
t = Terminal()
t.sequenceNumber = 1
# This next command reciprocally associates the `t` Terminal to `ei` EquivalentInjection,
t.ConductingEquipment = ei
# but only if this association is well-defined in the RDFS document (inverseRoleName property).
t1 = Terminal(sequenceNumber=1)
t2 = Terminal()
t2.sequenceNumber = 2
s = Switch(mRID='SW12', normalOpen=True)
# All attributes with multiplicity greater than 1 are represented as lists
s.add_Terminals(t1)
# A special function `add_{attribute_name}` is generated to insert a single item into the list
s.add_Terminals(t2)
cn = ConnectivityNode()
cn.mRID = 'Node23'
# List-type attributes may also be declared in the following way:
cn.Terminals = [t1, t]
4a. Create a new document instance with all objects
new_doc = DocumentCIMRDF()
new_doc.add_recursively(ei)
# >> All other linked objects will be automatically inserted into the document
The available methods for the DocumentCIMRDF class are:
- new_doc.dump(): Pretty-Print the document to stdout. Debug purposes only.
- new_doc.pack(): Generate the document's ElementTree (xml.etree.ElementTree) instance.
- new_doc.tostring(): Get the XML stringified version of the document.
- new_doc.tofile(): Save the XML stringified version of the document to a file.
- new_doc.add_elements( ... ): (Advanced users only) Insert one or a list of elements into the document.
- new_doc.add_recursively( ... ): (Recommended) Insert one or a list of elements into the document including its linked elements.
Parsing CIM RDF instances
3b. Use proper functions to parse a file or a string.
new_doc = DocumentCIMRDF()
new_doc.fromstring(rdfstring)
print(new_doc.resources)
# >> [list of instances]
The available functions are:
- new_doc.fromstring(rdfstring): Get list of instances from CIM RDF string.
- new_doc.fromfile(filename): Get list of instances from CIM RDF file.
After being inserted or parsed from a string/file, the elements are stored and accessible from the new_doc.resources attribute.
Metadata
Release files for cimrdf.py 2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cimrdf.py-2.1.tar.gz | 7.3 kB | Without provenance | Details for cimrdf.py-2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cimrdf.py-2.1-py3-none-any.whl | Python 3 | none | any | Details for cimrdf.py-2.1-py3-none-any.whl |
Total release size: 15.8 kB
Release files / cimrdf.py-2.1.tar.gz
| Download URL | cimrdf.py-2.1.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
959524c11099021cd7717d59a9c4fad824b009bec9d47fdaf3f510048465824a
|
|
BLAKE2b-256 checksum How to use checksums |
4843a3952675ad89460a180ddcac1a9df63e874417824390b7dcc484b890b94e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9
|
Release files / cimrdf.py-2.1-py3-none-any.whl
| Download URL | cimrdf.py-2.1-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb14cc038832522fbaaf1f30f00fd310f2accb66c9fe2ad2a5c0ad5fb9ea16a2
|
|
BLAKE2b-256 checksum How to use checksums |
d908c807662f778f39070c2a51c054db0fdbc0ea4beee2f51f2779a6afac5587
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9
|
Security for cimrdf.py 2.1
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.