Skip to main content

Python implementation of the Common Information Model.

Project description

PyCIM is a Python implementation of the IEC Common Information Model. Current features include:

  • Support for IEC 61970 14v15 and IEC 61968 10v31.

  • Class and attribute documentation integrated as Python docstrings.

  • Transparent bi-directional reference handling using Python properties.

  • CIM RDF/XML parsing and serialisation according to IEC 61970-552.

Installation

PyCIM has no dependencies beyond Python 2.5 or later. It can be easy_installed using setuptools:

$ easy_install PyCIM

Alternatively, download and unpack the tarball and install:

$ tar zxf PyCIM-14.15.tar.gz
$ python setup.py install

On UNIX systems, use sudo for the latter command if you need to install the scripts to a directory that requires root privileges:

$ sudo python setup.py install

The development Git repository can be cloned from GitHub:

$ git clone https://github.com/rwl/PyCIM.git

Using PyCIM

To use PyCIM with the Python interpreter, iPython is recommended. For example, to instantiate a ConnecticityNode:

In [1]: from CIM14.IEC61970.Core import ConnectivityNode

In [2]: node = ConnectivityNode(name='Node 1')

To associate the node with a Terminal:

In [3]: from CIM14.IEC61970.Core import Terminal

In [4]: t = Terminal(name='T1', ConnectivityNode=node)

In [5]: node.Terminals[0].name
Out[5]: 'T1'

To add a Terminal to a ConnectivityNode:

In [6]: t2 = Terminal()

In [7]: node.addTerminals(t2)

In [8]: t2.ConnectivityNode.name
Out[8]: 'Node 1'

To view the docstring for an attribute:

In [9]: t.connected?
Type:     bool
Base Class: <type 'bool'>
String Form:    False
Namespace:  Interactive
Docstring:
    bool(x) -> bool

    Returns True when the argument x is true, False otherwise.
    The builtins True and False are the only two instances of the class bool.
    The class bool is a subclass of the class int, and cannot be subclassed.

To parse a CIM RDF/XML file:

In[1]: import logging

In[2]: logging.basicConfig(level=logging.INFO)

In[3]: from PyCIM import cimread

In[4]: d = cimread('path/to/input_file.xml')
INFO:PyCIM.RDFXMLReader:Created 5660 CIM objects in 1.04s.

The cimread function returns a Python dictionary that maps UUIDs to CIM objects. To serialise the dictionary of objects:

In[5]: from PyCIM import cimwrite

In[6]: cimwrite(d, 'path/to/output_file.xml')
INFO:PyCIM.RDFXMLWriter:5660 CIM objects serialised in 1.14s.

For further information refer to the API documentation.

License

PyCIM is licensed under the GNU Lesser General Public License version 2.1 to allow commercial use while ensuring it remains free and open source.

Credits

PyCIM is developed by Richard Lincoln (r.w.lincoln@gmail.com).

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

PyCIM-14.15.1.tar.gz (568.1 kB view hashes)

Uploaded Source

Built Distributions

PyCIM-14.15.1.win32.exe (887.3 kB view hashes)

Uploaded Source

PyCIM-14.15.1.win32-py2.6.msi (557.1 kB view hashes)

Uploaded Source

PyCIM-14.15.1-py2.6.egg (1.3 MB view hashes)

Uploaded Source

PyCIM-14.15.1-py2.5.egg (1.3 MB view hashes)

Uploaded Source

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