Contact

Email (PGP key), Homepage

Address: IBISC, 1st floor, room 16,
University of Évry
Tour Évry 2
523 place des terrasses de l'Agora
91000 Évry, France

Tel: (+33)160873718
Fax: (+33)160873789


Search

Rss Posts

Rss Comments

Login

 

Using SNAKES plugins

Monday, January 18, 2010

One of the important features of SNAKES is its capability to extend the basic model with plugins. In this post, we see how to load plugins.
Loading a plugin essentially requires a call to snakes.plugins.load. For instance, let's load plugin gv that allows to draw Petri nets (using GraphViz):

import snakes.plugins
snakes.plugins.load("gv", "snakes.nets", "mynets")
This call to load can be understood as: load plugin gv, on the top of module snakes.nets, and build a module mynets as a result. Indeed, loading a plugin results in creating a new module that is immediately imported. (This allows one to use simultaneously several modules extended in different ways.) So, after, this two lines, the following is possible:
net = mynets.PetriNet("Drawable net")
from mynets import *
In order to load more than one plugin, the first argument to load can be replaced by a list of modules to be loaded. For instance:
import snakes.plugins
snakes.plugins.load(["gv", "ops"], "snakes.nets", "mynets")

Post a comment