openalea.core package#

Submodules#

openalea.core.actor module#

This module provides an actor interface

class openalea.core.actor.IActor[source]#

Bases: object

Interface to emulate a function

The class IActor implements an interface to emulate a function. It has functions to inputs() and outputs().

Examples:

>>> import openalea.core
>>> a = openalea.core.actor.IActor()
eval()[source]#

Computes output values when input is set

inputs()[source]#

Iterates on all input descriptions

Returns:

iter of (input key, input interface)

output(key)[source]#

Get value computed of the output

Parameters:

key – a specified key

Returns:

the corresponding value

outputs()[source]#

Iterates on all output descriptions

Returns:

iter of (output key, output interface)

set_input(key, value)[source]#

Set input specified by a key to the given value

Parameters:
  • key – the input key

  • value – the value key corresponding to the key

openalea.core.alea module#

a script to run alea dataflow and scripts

openalea.core.alea.function(factory)[source]#

Return a function which is evaluated like a python function.

factory is a NodeFactory.

openalea.core.alea.get_intput_callback(option, opt_str, value, parser)[source]#

todo

openalea.core.alea.get_node(component, inputs, pm=None)[source]#

retrieve a node from its component name and inputs

Parameters:
  • component – todo

  • inputs – todo

  • pm – package manager

openalea.core.alea.load_package_manager(*args)[source]#

Return the package manager

Parameters:
  • pkg_id – package id

  • node_id – node id

Returns:

package manager

openalea.core.alea.main()[source]#

Parse options

openalea.core.alea.parse_component(name)[source]#

Return (pkg_id, node_id) from name

openalea.core.alea.query(component, pm=None)[source]#

show help of component

openalea.core.alea.run(component, inputs, pm=None, vtx_id=-1)[source]#

Run component with inputs. can exit by exception.

If node_id is given, eval the dataflow from that node and return the result.

openalea.core.alea.run_and_display(component, inputs, gui=False, pm=None)[source]#

run component with inputs

Parameters:
  • component – todo

  • inputs – todo

  • gui (boolean (default is False)) – todo

  • pm (package manager) – package manager

openalea.core.alea.start_qt(factory, node)[source]#

Start Qt, and open widget of factory, node

Parameters:
  • factory – todo

  • node – todo

openalea.core.authors module#

Warning

This file is not complete. Only appears authors added manually by community or author themselves. So, other authors, not in this list, may have contribute to this code. Please have look to README, AUTHORS, ABOUT files, source code files and other official documents to have a reliable information about authors.

Warning

If your are a contributor and do not appear in this list or information are wrong, please fix it or send a message to ask to fix it.

If you have contributed in openalea one day and want to be cited, please fill your information here

fname = {‘name’: u”First name Family name”, additional fields}

fname: first letter of your first name + first fullname If you have multiple first name: use one letter for each name. Example: Jean-Philippe -> jp If you have multiple family names: use at least first family name and then as you want for additional names Ex: Dufour-Kowalski -> dufourko, dufour, dufourkowalski, …

Additional fields:
  • email

  • employer

  • department

  • team

  • note

openalea.core.category module#

This module defines category keywords to be used within wralea files

class openalea.core.category.PackageManagerCategory[source]#

Bases: object

The PackageManagerCategory provides a Dictionary of keywords and categories.

This dictionary is used by the PackageManager class so as to extract the category fields that are found in the __wralea__.py files. Those fields are gathered into a list that is shown within Visualea.

Here below is the list of keywords to be used within the __wralea__ files – inside the category field. Each of these keywords (left column) corresponds to a label (right column) that will appear in the visualea interface. For instance, if “image” is found in the __wralea__ file, then the corresponding node will appear in “Image Processing/standard category”.

If you provide a keyword that is not in this list, this keyword will not be taken into account. However, a keyword may be appended with a “.” followed by any keywords that will be considered as a subcategory. For instance, a category called scene.myScene will appear in the standard main category “Scene Design” and in a sub-category myScene.

For now there are quite a few keywords that correspond to the same category. The goal in the mid-term in to merge them so that there is only 1 keyword per category.

keywords(__wralea__)

Category names in VisuAlea

image

Image Processing.standard

svg

Image Processing.svg

datatype

Python Functionalities.Datatype

functional

Python Functionalities.functional

math

Python Functionalities.math

python

Python Functionalities.standard

data

Raw Data (txt,geom,png,etc)

tutorial

Tutorial

workflow

Workflow

flow control

Workflow

system

System Interaction

io

Data I/O

file

Data I/O

test

Test

misc

Miscellaneous

spatial

Scene Design.spatial

scene

Scene Design

light

Scene Design.light

sky

Scene Design.sky

PGL Object Generator

Scene Design.PGL

demo

Demo

composite

Composite

descriptive

Data Processing.statistics

stat

Data Processing.statistics

statistics

Data Processing.statistics

regression

Data Processing.regression

fitting

Data Processing.fitting

distribution

Data Processing.distribution

test

Data Processing.statistical tests

string

Data processing.Data Manipulation…

codec

Data processing.Data Manipulation…

fractal analysis

Scene Design.Fractal Analysis

plot

Visualisation

graphics

Visualisation

graphic

Visualisation

visualization

Visualisation

visualisation

Visualisation

web

Web Services

unclassified

to Classify

openalea.core.cli module#

This module defines the command line interface. It is composed by a set of functions useable directly in the interpreter

openalea.core.cli.get_datapool_code(data_key)[source]#

Return the python code to access to ‘data_key’ in the datapool

openalea.core.cli.get_node_code(node_id)[source]#

Return the python code to access to ‘node_id’

openalea.core.cli.get_welcome_msg()[source]#

Return a welcome message

openalea.core.cli.init_interpreter(interpreter, session, _locals=None)[source]#

Initialise the interpreter to interact with the openalea system (import, variables…)

openalea.core.codegen module#

codegen#

Extension to ast that allow ast -> python code generation.

copyright:

Copyright 2008 by Armin Ronacher.

license:

BSD.

class openalea.core.codegen.SourceGenerator(indent_with, add_line_information=False)[source]#

Bases: NodeVisitor

This visitor is able to transform a well formed syntax tree into python sourcecode. For more details have a look at the docstring of the node_to_source function.

body(statements)[source]#
body_or_else(node)[source]#
decorators(node)[source]#
newline(node=None, extra=0)[source]#
signature(node)[source]#
visit_Assert(node)[source]#
visit_Assign(node)[source]#
visit_Attribute(node)[source]#
visit_AugAssign(node)[source]#
visit_BinOp(node)[source]#
visit_BoolOp(node)[source]#
visit_Break(node)[source]#
visit_Bytes(node)[source]#
visit_Call(node)[source]#
visit_ClassDef(node)[source]#
visit_Compare(node)[source]#
visit_Continue(node)[source]#
visit_Delete(node)[source]#
visit_Dict(node)[source]#
visit_DictComp(node)[source]#
visit_Ellipsis(node)[source]#
visit_Expr(node)[source]#
visit_ExtSlice(node)[source]#
visit_For(node)[source]#
visit_FunctionDef(node)[source]#
visit_GeneratorExp(node)#
visit_Global(node)[source]#
visit_If(node)[source]#
visit_IfExp(node)[source]#
visit_Import(node)[source]#
visit_ImportFrom(node)[source]#
visit_Lambda(node)[source]#
visit_List(node)#
visit_ListComp(node)#
visit_Name(node)[source]#
visit_Nonlocal(node)[source]#
visit_Num(node)[source]#
visit_Pass(node)[source]#
visit_Print(node)[source]#
visit_Raise(node)[source]#
visit_Repr(node)[source]#
visit_Return(node)[source]#
visit_Set(node)#
visit_SetComp(node)#
visit_Slice(node)[source]#
visit_Starred(node)[source]#
visit_Str(node)[source]#
visit_Subscript(node)[source]#
visit_TryExcept(node)[source]#
visit_TryFinally(node)[source]#
visit_Tuple(node)[source]#
visit_UnaryOp(node)[source]#
visit_While(node)[source]#
visit_With(node)[source]#
visit_Yield(node)[source]#
visit_alias(node)[source]#
visit_arguments(node)[source]#
visit_comprehension(node)[source]#
visit_excepthandler(node)[source]#
write(x)[source]#
openalea.core.codegen.to_source(node, indent_with='    ', add_line_information=False)[source]#

This function can convert a node tree back into python sourcecode. This is useful for debugging purposes, especially if you’re dealing with custom asts not generated by python itself.

It could be that the sourcecode is evaluable when the AST itself is not compilable / evaluable. The reason for this is that the AST contains some more data than regular sourcecode does, which is dropped during conversion.

Each level of indentation is replaced with indent_with. Per default this parameter is equal to four spaces as suggested by PEP 8, but it might be adjusted to match the application’s styleguide.

If add_line_information is set to True comments for the line numbers of the nodes are added to the output. This can be used to spot wrong line number information of statement nodes.

openalea.core.color_palette module#

openalea.core.color_palette.HTMLColorToRGB(colorstring)[source]#

convert #RRGGBB to an (R, G, B) tuple. Taken from here: http://code.activestate.com/recipes/266466-html-colors-tofrom-rgb-tuples/ Many thanks go to the authors!

openalea.core.compositenode module#

A CompositeNode is a Node that contains other nodes connected in a directed graph. A CompositeNodeFactory instance is a factory that build CompositeNode instances. Different instances of the same factory can coexist and can be modified in a dataflow.

class openalea.core.compositenode.CompositeNode(inputs=(), outputs=())[source]#

Bases: Node, DataFlow

The CompositeNode is a container that interconnect different node instances between them in directed graph.

add_node(node, vid=None, modify=True)[source]#

Add a node in the Graph with a particular id if id is None, autogenrate one

Parameters:
  • node – the node instance

  • vid – element id

Returns:

the id

close()[source]#
compute_external_io(vertex_selection, new_vid)[source]#

Return the list of input and output edges to connect the composite node.

compute_io(v_list=None)[source]#

Return (inputs, outputs, connections)

representing the free port of node v_list is a vertex id list

connect(src_id, port_src, dst_id, port_dst)[source]#

Connect 2 elements

Parameters:
  • src_id – source node id

  • port_src – source output port number

  • dst_id – destination node id

  • port_dst – destination input port number

copy_to(other)[source]#
disconnect(src_id, port_src, dst_id, port_dst)[source]#

Deconnect 2 elements

Parameters:
  • src_id – source node id

  • port_src – source output port number

  • dst_id – destination node id

  • port_dst – destination input port number

eval(*args, **kwds)[source]#

Evaluate the graph

Return True if the node need a reevaluation (like generator)

eval_as_expression(vtx_id=None, step=False)[source]#

Evaluate a vtx_id

if node_id is None, then all the nodes without sons are evaluated

get_eval_algo()[source]#

Return the evaluation algo instance

get_input(index_key)[source]#

Return the composite node input

get_output(index_key)[source]#

Retrieve values from output node input ports

invalidate()[source]#

Invalidate nodes

mimetype = 'openalea/compositenode'#
node(vid)[source]#

Convenience function

notify_vertex_addition(vertex, vid=None)[source]#
notify_vertex_removal(vertex)[source]#
remove_edge(eid)[source]#

remove a specified edge from the graph

Parameters:

eid (eid) – id of the edge to remove

remove_node(vtx_id)[source]#

remove a node from the graph :param vtx_id: element id

replace_node(vid, newnode)[source]#

Replace the node vid by newnode

reset()[source]#

Reset nodes

set_continuous_eval(vid, state=True)[source]#

set vid as a continuous evaluated node

set_input(index_key, val=None, *args)[source]#

Copy val into input node output ports

set_io(inputs, outputs)[source]#

Define inputs and outputs

Inputs and outputs are list of dict(name=’’, interface=’’, value=’’)

set_output(index_key, val)[source]#

Set a value to an output

simulate_destruction_notifications()[source]#

emits messages as if we were adding elements to the composite node

to_factory(sgfactory, listid=None, auto_io=False)[source]#

Update CompositeNodeFactory to fit with the graph

listid is a list of element to export. If None, select all id. if auto_io is true : inputs and outputs are connected to the free ports

to_script()[source]#

Translate the dataflow into a python script.

update_eval_listeners(vid)[source]#

Update continuous evaluation listener for node vid

class openalea.core.compositenode.CompositeNodeFactory(*args, **kargs)[source]#

Bases: AbstractFactory

clear()[source]#

todo

copy(**args)[source]#

Copy factory.

Parameters:
  • path – new search path

  • replace_pkg – old and new package names.

When replace package is set, change the package id for all the elt factories.

create_fake_node(vid)[source]#

Return an empty node with the correct number of inputs and output

get_documentation()[source]#
get_writer()[source]#

Return the writer class

instantiate(call_stack=None)[source]#

Create a CompositeNode instance and allocate all elements This function overide default implementation of NodeFactory

Parameters:

call_stack – the list of NodeFactory id already in recursion stack (in order to avoid infinite loop)

instantiate_node(vid, call_stack=None)[source]#

Partial instantiation

instantiate only elt_id in CompositeNode

Parameters:

call_stack – a list of parent id (to avoid infinite recursion)

instantiate_widget(node=None, parent=None, edit=False, autonomous=False)[source]#

Return the corresponding widget initialised with node

If node is None, the node is allocated else a composite widget composed with the node sub widget is returned.

is_composite_node()[source]#
load_ad_hoc_data(node, elt_data, elt_ad_hoc=None)[source]#
mimetype = 'openalea/compositenodefactory'#

The CompositeNodeFactory is able to create CompositeNode instances Each node has an unique id : the element id (elt_id)

paste(cnode, data_modifiers=[], call_stack=None, meta=False)[source]#

Paste to an existing CompositeNode instance

Parameters:
  • cnode – composite node instance

  • data_modifiers – list of 2-uple (key, function) to apply to internal data (for instance to move the node)

  • call_stack – the list of NodeFactory id already in recursion stack (in order to avoid infinite loop)

Returns:

the list of created id

class openalea.core.compositenode.CompositeNodeInput(inputs)[source]#

Bases: Node

Dummy node to represent the composite node inputs

eval()[source]#

Evaluate the node by calling __call__ Return True if the node needs a reevaluation and a timed delay if the node needs a reevaluation at a later time.

get_input(input_pid)[source]#

Return the input value

set_input(input_pid, val=None, *args)[source]#

Define input value

to_script()[source]#

Script translation of this node.

class openalea.core.compositenode.CompositeNodeOutput(outputs)[source]#

Bases: Node

Dummy node to represent the composite node outputs

eval()[source]#

Evaluate the node by calling __call__ Return True if the node needs a reevaluation and a timed delay if the node needs a reevaluation at a later time.

get_output(output_pid)[source]#

Return Output value

set_output(output_pid, val)[source]#

Define output

to_script()[source]#

Script translation of this node.

class openalea.core.compositenode.ContinuousEvalListener(dataflow, vid)[source]#

Bases: AbstractListener

When notified this listener reexecute a dataflow on a particular vid)

notify(sender, event)[source]#

Notification

exception openalea.core.compositenode.IncompatibleNodeError[source]#

Bases: Exception

todo

class openalea.core.compositenode.JSONCNFactoryWriter(factory)[source]#

Bases: PyCNFactoryWriter

class openalea.core.compositenode.PyCNFactoryWriter(factory)[source]#

Bases: object

CompositeNodeFactory python Writer

pprint_repr(obj, indent=3)[source]#

Pretty print repr

sgfactory_template = '\n\n$NAME = CompositeNodeFactory(name=$PNAME,\n                             description=$DESCRIPTION,\n                             category=$CATEGORY,\n                             doc=$DOC,\n                             inputs=$INPUTS,\n                             outputs=$OUTPUTS,\n                             elt_factory=$ELT_FACTORY,\n                             elt_connections=$ELT_CONNECTIONS,\n                             elt_data=$ELT_DATA,\n                             elt_value=$ELT_VALUE,\n                             elt_ad_hoc=$ELT_AD_HOC,\n                             lazy=$LAZY,\n                             eval_algo=$EVALALGO,\n                             )\n\n'#

openalea.core.ctypes_ext module#

This file contains fixes for shared library location under different oses

openalea.core.ctypes_ext.find_library(name)[source]#

Similar to ctypes.util.find_library except that on posixes that are not darwin, besides using ldconfig, gcc and objdump, it also browses the LD_LIBRARY_PATH.

openalea.core.customexception module#

exception openalea.core.customexception.CustomException(*args, **kargs)[source]#

Bases: Exception

CustomException is an extension of builtin Exception. Goal is to provide an unique structure for all kind of exceptions to allow high-level exception handling.

For this reason, CustomException always provides :
  • a title (getTitle)

  • a message (getMessage)

  • a detailed description (getDesc)

Typicall use is :

def print_error(error):

“number of error arguments has no importance” print_in_red(error.getTitle()) print_in_blue(error.getMessage())

try :

action

except CustomExceptionNumberOne,error :

print_error(error)

except CustomExceptionNumberTwo,error :

print_error(error)

except CustomExceptionNumberThree,error :

fix the problem

# CustomExceptionNumberFour isn’t intercepted here but for example in GUI classes else :

print ‘done’

If CustomException takes one argument, you can reach it using “%(value)s”. If it takes more than one, you must reimplement _kargs method.

Example :

class ErrNotMatchingPuzzlePiece(CustomException):
  title = u'Error: puzzle pieces do not match'
  message = u'%(compass_1)s part of piece %(piece_1)%s do not match %(compass_2)s part of piece %(piece_2)%s'
  desc = "This error is raised because ..."

  def _kargs(self):
    return dict(
      compass_1=unicode(self._args[0].num),
      piece_1=self._args[1],
      compass_2=unicode(self._args[2].num),
      piece_2=self._args[3],
      )

#two raise this exception:
raise ErrNotMatchingPuzzlePiece(p1, u'North', p2, u'South')
# with p1 and p2 two "Piece" objects containing a "num" attribute.
desc = 'No details available'#
getDesc()[source]#
getMessage()[source]#
getTitle()[source]#
kargs()[source]#
message = 'An unknown error occurs'#
rkargs()[source]#
title = 'Unknown Error'#
exception openalea.core.customexception.UserException(*args, **kargs)[source]#

Bases: CustomException

openalea.core.customexception.cast_error(error, klass, title=True, message=True, desc=True, **kargs)[source]#
openalea.core.customexception.display_error_color(e)[source]#

openalea.core.data module#

Data management classes

class openalea.core.data.Data(**kwargs)[source]#

Bases: object

property code#
property content#
default_file_name = 'filename.ext'#
default_name = 'Data'#
exists()[source]#
extension = 'ext'#
property filename#
get_documentation()[source]#
icon = 'Crystal_Clear_app_kcmdf.png'#
is_same_data(other)[source]#
mimetype = None#
move(new_path)[source]#
property name#
pattern = '*.ext'#
read()[source]#
rename(new)[source]#
save()[source]#
class openalea.core.data.DataFactory(name, description='', editors=None, includes=None, **kargs)[source]#

Bases: AbstractFactory

Data representation as factory

clean_files()[source]#

Remove files depending of factory

get_pkg_data()[source]#

Return the associated PackageData object

get_writer()[source]#

Return the writer class

instantiate(call_stack=[])[source]#

Return a node instance

Parameters:

call_stack – the list of NodeFactory id already in call stack (in order to avoid infinite recursion)

instantiate_widget(node=None, parent=None, edit=False, autonomous=False)[source]#

Return the corresponding widget initialized with node

is_data()[source]#
is_valid()[source]#

Return True if the factory has associated data. Else raise an exception

class openalea.core.data.DataNode(packagedata, editors=None, includes=[])[source]#

Bases: Node

Node representing a Data

changed(path)[source]#

Call listeners

monitor_file(filename)[source]#

Enable file monitoring

to_script()[source]#

Script translation of this node.

class openalea.core.data.PackageData(pkg_name, filename, package=None)[source]#

Bases: object

String representing a package data

class openalea.core.data.PyDataFactoryWriter(factory)[source]#

Bases: object

DataFactory python Writer

datafactory_template = '\n$NAME = DataFactory(name=$PNAME,\n                    description=$DESCRIPTION,\n                    editors=$EDITORS,\n                    includes=$INCLUDES,\n                    )\n'#
class openalea.core.data.PythonFile(**kwargs)[source]#

Bases: Data

default_file_name = 'script.py'#
default_name = 'Python'#
extension = 'py'#
get_documentation()[source]#
icon = ':/images/resources/Python-logo.png'#
mimetype = 'text/x-python'#
pattern = '*.py'#

openalea.core.dataflow module#

This module provide an implementation of a dataflow

class openalea.core.dataflow.DataFlow[source]#

Bases: PropertyGraph

Directed graph with connections between in_ports of vertices and out_port of vertices ports are typed

actor(vid)[source]#

return actor associated to a given vertex

add_actor(actor, vid=None)[source]#

create a vertex and the corresponding ports and associate it with the given actor return: vid

add_in_port(vid, local_pid, pid=None)[source]#

add a new in port to vertex pid using local_pid use pid as global port id if specified or create a new one if None raise an error if pid is already used

Returns:

pid used

Return type:

pid

add_out_port(vid, local_pid, pid=None)[source]#

add a new out port to vertex pid using local_pid use pid as global port id if specified or create a new one if None raise an error if pid is already used

Returns:

pid used

Return type:

pid

add_vertex(vid=None)[source]#

add a vertex to the graph, if vid is not provided create a new vid

Parameters:

vid (vid) – the id of the vertex to add, default=None

Returns:

the id of the created vertex

Return type:

vid

clear()[source]#

remove all vertices and edges don’t change references to objects

connect(source_pid, target_pid, eid=None)[source]#

connect the out port source_pid with the in_port target_pid use eid if not None or create a new one raise an error if eid is already used

Returns:

eid used

Return type:

eid

connected_edges(pid)[source]#

iterate on all edges connected to this port :rtype: iter of eid

connected_ports(pid)[source]#

iterate on all ports connected to this port :rtype: iter of pid

get_all_parent_nodes(vid)[source]#

Return an iterator of vextex id corresponding to all the parent node of vid

in_port(vid, local_pid)[source]#

global port id of a given port :rtype: pid

in_ports(vid=None)[source]#

iter on all in ports of a given vertex iter on all in ports of the dataflow if vid is None

Return type:

iter of pid

is_in_port(pid)[source]#

test whether port refered by pid is an in port of its vertex :rtype: bool

is_out_port(pid)[source]#

test whether port refered by pid is an out port of its vertex :rtype: bool

local_id(pid)[source]#

local port identifier of a given port specified by its global pid

nb_connections(pid)[source]#

Compute number of edges connected to a given port.

Parameters:

pid (-) – id of port

Returns:

  • int

out_port(vid, local_pid)[source]#

global port id of a given port :rtype: pid

out_ports(vid=None)[source]#

iter on all out ports of a given vertex iter on all out ports of the dataflow if vid is None

Parameters:

vid – todo

Return type:

iter of pid

port(pid)[source]#

port object specified by its global pid

ports(vid=None)[source]#

iter on all ports of a given vertex iter on all ports of the dataflow if vid is None

Return type:

iter of pid

remove_port(pid)[source]#

remove the specified port and all connections to this port

remove_vertex(vid)[source]#

remove a specified vertex of the graph remove all the edges attached to it

Parameters:

vid (vid) – the id of the vertex to remove

set_actor(vid, actor)[source]#

associate an actor to a given vertex

source_port(eid)[source]#

out port of the source vertex of the edge

Parameters:

eid – todo

Return type:

pid

target_port(eid)[source]#

in port of the target vertex of the edge

Parameters:

eid – todo

Return type:

pid

vertex(pid)[source]#

return the id of the vertex which own the port :rtype: vid

class openalea.core.dataflow.Port(vid, local_pid, is_out_port)[source]#

Bases: object

simple structure to maintain some port property a port is an entry point to a vertex

exception openalea.core.dataflow.PortError[source]#

Bases: Exception

class openalea.core.dataflow.SubDataflow(dataflow, algo, node_id, port_index)[source]#

Bases: object

Represents a part of a dataflow for a partial evaluation A SubDataflow is a callable and absracts a part of a dataflow as a funtion

openalea.core.dataflow_evaluation module#

This module provide algorithms to evaluate a dataflow

class openalea.core.dataflow_evaluation.AbstractEvaluation(dataflow)[source]#

Bases: object

Abstract evaluation algorithm

clear()[source]#

Clear algorithm, ready to reevaluate.

eval(env, state, vid=None)[source]#

Evaluate associated dataflow.

Produce a valid state from a ready_to_evaluate one.

Parameters:
  • env (-) – environment in which to perform the evaluation

  • state (-) – must be a ready_not_evaluate state

  • vid (-) – id of vertex to start the evaluation if None starts from the leaves of the dataflow

class openalea.core.dataflow_evaluation.BruteEvaluation(dataflow)[source]#

Bases: AbstractEvaluation

For each evaluation reevaluate each node of the dataflow.

clear()[source]#

Clear algorithm, ready to reevaluate.

eval(env, state, vid=None)[source]#

Evaluate associated dataflow.

Produce a valid state from a ready_to_evaluate one.

Parameters:
  • env (-) – environment in which to perform the evaluation

  • state (-) – must be a ready_not_evaluate state

  • vid (-) – id of vertex to start the evaluation if None starts from the leaves of the dataflow

eval_from_node(env, state, vid)[source]#

Evaluate dataflow from a given node.

function provided for convenience to simplify derivation from this algo

eval_node(env, state, vid)[source]#

Evaluate a single node

Store result in state. Doesn’t test if state is valid or if the node actually need to be evaluated

openalea.core.dataflow_state module#

This module provide an implementation of a way to store data exchanged between nodes of a dataflow.

class openalea.core.dataflow_state.DataflowState(dataflow)[source]#

Bases: object

Store outputs of node and provide a way to access them

clear()[source]#

Clear state

cmp_port_priority(pid1, pid2)[source]#

Compare port priority.

Compare first x position of actors then use pids

get_data(pid)[source]#

Retrieve data associated with a port.

If pid is an output port, retrieve single item of data if pid is an input port, retrieve data on all output ports connected to this port and return a list of it or a single item if only one port connected

Parameters:

pid (-) – id of port either in or out

is_ready_for_evaluation()[source]#

Test wether the state contains enough information to evaluate the associated dataflow.

Simply check that each lonely input port has some data attached to it.

is_valid()[source]#

Test wether all data have been computed

reinit()[source]#

Remove all data stored except for the one associated to lonely input ports.

set_data(pid, data)[source]#

Store data on a port.

This function does not test that the port is an output port

Parameters:
  • pid (-) – id of port

  • data (-)

openalea.core.dataflow_state.cmp(x, y)[source]#

Replacement for built-in function cmp that was removed in Python 3

Compare the two objects x and y and return an integer according to the outcome. The return value is negative if x < y, zero if x == y and strictly positive if x > y.

openalea.core.datapool module#

DataPool is a global dictionnary to share data between node instance

class openalea.core.datapool.DataPool(*args, **kw)[source]#

Bases: Observed, dict

Dictionnary of session data

add_data(key, instance)[source]#

Add an instance referenced by key to the data pool

remove_data(key)[source]#

Remove the instance identified by key

openalea.core.datapool.notify_decorator(f)[source]#

openalea.core.export_app module#

Export application functions

openalea.core.export_app.export_app(name, filename, cn_factory)[source]#

Export application

Parameters:
  • name – name of the application

  • filename – python file to write$

  • cn_factory – composite node factory

openalea.core.external module#

This module defines all the import used in wralea declarations

openalea.core.external.add_docstring(obj)[source]#

Decorator that replace a function’s docstring by another from obj

This function should be used to decorate your wralea functions when docstring is equivalent to an already existing function or class.

Parameters:

obj – a function or class that contains a docstring

Example:

from math import abs

@add_docstring(abs)
def int_abs_function(x):
    if type(x) == int:
        return abs(x)
    else:
        raise TypeError("expect int as parameter")

openalea.core.factory module#

Abstract Factory classes and methods.

A Factory build Functor (Nodes or Pluggings) from its description. Factories instantiates Functors.

class openalea.core.factory.AbstractFactory[source]#

Bases: object

Abstract Factory is Factory base class.

Properties:
  • name

  • metainfo

  • module

  • distribution (aka egg name)

instantiate(call_stack=[])[source]#

Return a node instance

Parameters:

call_stack – the list of NodeFactory id already in call stack (in order to avoir infinite recursion)

is_valid()[source]#

Return True if the factory is valid else raise an exception

mimetype = 'openalea/factory'#

openalea.core.factory_decorator module#

Decorators to attach signature information to functions

openalea.core.factory_decorator.factory(f)[source]#

Flag the given function f as an openalea factory.

class openalea.core.factory_decorator.inputs(*args)[source]#

Bases: object

Add inputs information to a function

Example

>>> from openalea.core.factory_decorator import inputs
>>> @inputs('a:int=1,b:list=[]')
... def fct(*args):
...     pass
class openalea.core.factory_decorator.outputs(*args)[source]#

Bases: inputs

Add outputs information to a function

Example

>>> from openalea.core.factory_decorator import outputs
>>> @outputs('first:int,remainder:list')
... def fct(*args):
...     return int(args[0]), args[1:]

openalea.core.factory_parser module#

Automatical extraction of openalea factories for python modules and packages

TODO: bad name. The module is not parsed but imported.

openalea.core.factory_parser.add_factory(pkg, fct, base_dir=None)[source]#

Add a (Node) Factory for function fct into package pkg

If function does not contain suitable meta_info, try to take it from pkg_info

openalea.core.factory_parser.import_module(module_name, search_path=[])[source]#

load module_name

Inputs:
  • module_name

    string with the name of the module as it is given to import (i.e. containing package dependancies separated by ‘.’)

  • search_path

    Additional search directories, given as a list of string, to look for module_name (and its parent package) if it is in not in sys.path.

openalea.core.factory_parser.parse_module(module, module_dir=None)[source]#

Create an openalea package from a python module

Inputs::
module:
  • either a python module

  • or the full name of the module to parse (e.g. ‘pkg.sub_pkg.module’)

module_dir:

Base directory of module if it is not in the python path.

openalea.core.funcsigs module#

Function signature objects for callables

Back port of Python 3.3’s function signature tools from the inspect module, modified to be compatible with Python 2.7 and 3.2+.

class openalea.core.funcsigs.BoundArguments(signature, arguments)[source]#

Bases: object

Result of Signature.bind call. Holds the mapping of arguments to the function’s parameters.

Has the following public attributes:

  • argumentsOrderedDict

    An ordered mutable mapping of parameters’ names to arguments’ values. Does not contain arguments’ default values.

  • signatureSignature

    The Signature object that created this instance.

  • argstuple

    Tuple of positional arguments values.

  • kwargsdict

    Dict of keyword arguments values.

property args#
property kwargs#
property signature#
class openalea.core.funcsigs.Parameter(name, kind, default=<class 'openalea.core.funcsigs._empty'>, annotation=<class 'openalea.core.funcsigs._empty'>, _partial_kwarg=False)[source]#

Bases: object

Represents a parameter in a function signature.

Has the following public attributes:

  • namestr

    The name of the parameter as a string.

  • defaultobject

    The default value for the parameter if specified. If the parameter has no default value, this attribute is not set.

  • annotation

    The annotation for the parameter if specified. If the parameter has no annotation, this attribute is not set.

  • kindstr

    Describes how argument values are bound to the parameter. Possible values: Parameter.POSITIONAL_ONLY, Parameter.POSITIONAL_OR_KEYWORD, Parameter.VAR_POSITIONAL, Parameter.KEYWORD_ONLY, Parameter.VAR_KEYWORD.

KEYWORD_ONLY = <_ParameterKind: 'KEYWORD_ONLY'>#
POSITIONAL_ONLY = <_ParameterKind: 'POSITIONAL_ONLY'>#
POSITIONAL_OR_KEYWORD = <_ParameterKind: 'POSITIONAL_OR_KEYWORD'>#
VAR_KEYWORD = <_ParameterKind: 'VAR_KEYWORD'>#
VAR_POSITIONAL = <_ParameterKind: 'VAR_POSITIONAL'>#
property annotation#
property default#
empty#

alias of _empty

property kind#
property name#
replace(name=<class 'openalea.core.funcsigs._void'>, kind=<class 'openalea.core.funcsigs._void'>, annotation=<class 'openalea.core.funcsigs._void'>, default=<class 'openalea.core.funcsigs._void'>, _partial_kwarg=<class 'openalea.core.funcsigs._void'>)[source]#

Creates a customized copy of the Parameter.

class openalea.core.funcsigs.Signature(parameters=None, return_annotation=<class 'openalea.core.funcsigs._empty'>, __validate_parameters__=True)[source]#

Bases: object

A Signature object represents the overall signature of a function. It stores a Parameter object for each parameter accepted by the function, as well as information specific to the function itself.

A Signature object has the following public attributes and methods:

  • parametersOrderedDict

    An ordered mapping of parameters’ names to the corresponding Parameter objects (keyword-only arguments are in the same order as listed in code.co_varnames).

  • return_annotationobject

    The annotation for the return type of the function if specified. If the function has no annotation for its return type, this attribute is not set.

  • bind(*args, **kwargs) -> BoundArguments

    Creates a mapping from positional and keyword arguments to parameters.

  • bind_partial(*args, **kwargs) -> BoundArguments

    Creates a partial mapping from positional and keyword arguments to parameters (simulating ‘functools.partial’ behavior.)

bind(*args, **kwargs)[source]#

Get a BoundArguments object, that maps the passed args and kwargs to the function’s signature. Raises TypeError if the passed arguments can not be bound.

bind_partial(*args, **kwargs)[source]#

Get a BoundArguments object, that partially maps the passed args and kwargs to the function’s signature. Raises TypeError if the passed arguments can not be bound.

empty#

alias of _empty

classmethod from_function(func)[source]#

Constructs Signature for the given python function

property parameters#
replace(parameters=<class 'openalea.core.funcsigs._void'>, return_annotation=<class 'openalea.core.funcsigs._void'>)[source]#

Creates a customized copy of the Signature. Pass ‘parameters’ and/or ‘return_annotation’ arguments to override them in the new copy.

property return_annotation#
openalea.core.funcsigs.signature(obj)[source]#

Get a signature object for the passed callable.

openalea.core.interface module#

This module defines Interface classes (I/O types)

class openalea.core.interface.IBool(**kargs)[source]#

Bases: IInterface

Bool interface

classmethod default()[source]#
class openalea.core.interface.ICodeStr(**kargs)[source]#

Bases: IStr

Source code interface

class openalea.core.interface.IData(**kargs)[source]#

Bases: IStr

Package data interface

class openalea.core.interface.IDateTime(**kargs)[source]#

Bases: IInterface

DateTime

class openalea.core.interface.IDict(**kargs)[source]#

Bases: IInterface

Dictionary interface

classmethod default()[source]#

todo

class openalea.core.interface.IDirStr(**kargs)[source]#

Bases: IStr

Directory Path interface

class openalea.core.interface.IEnumStr(enum=[], **kargs)[source]#

Bases: IStr

String enumeration

class openalea.core.interface.IFileStr(filter='All (*)', save=False, **kargs)[source]#

Bases: IStr

File Path interface

class openalea.core.interface.IFloat(min=-16777216.0, max=16777216.0, step=1.0, **kargs)[source]#

Bases: IInterface

Float interface

classmethod default()[source]#
class openalea.core.interface.IFunction(**kargs)[source]#

Bases: IInterface

Function interface

class openalea.core.interface.IInt(min=-16777216, max=16777216, step=1, **kargs)[source]#

Bases: IInterface

Int interface

classmethod default()[source]#
example()[source]#
class openalea.core.interface.IInterface(**kargs)[source]#

Bases: object

Abstract base class for all interfaces

classmethod default()[source]#
class openalea.core.interface.IInterfaceMetaClass(name, bases, dict)[source]#

Bases: type

IInterface Metaclass Allow to register corresponding python type

all = [IInterface, IStr, ISlice, IFileStr, IDirStr, ITextStr, ICodeStr, IFloat, IInt, IBool, IEnumStr, IRGBColor, IDateTime, ITuple3, ITuple, IFunction, ISequence, IDict, IData]#
class openalea.core.interface.IInterfaceWidget(node, parent, parameter_str, interface)[source]#

Bases: AbstractListener

Base class for widget associated to an interface

classmethod get_label(node, parameter_str)[source]#
get_state()[source]#
get_value()[source]#
get_widget_value()[source]#
internal_data()[source]#

return a dict: minimal

notify(sender, event)[source]#

Notification sent by node

set_value(newval)[source]#
set_widget_value(newval)[source]#
unvalidate()[source]#
update_state()[source]#

Enable or disable widget depending of connection status

class openalea.core.interface.IRGBColor(**kargs)[source]#

Bases: IInterface

RGB Color

class openalea.core.interface.ISequence(**kargs)[source]#

Bases: IInterface

Sequence interface (list, tuple, …)

classmethod default()[source]#
class openalea.core.interface.ISlice(**kargs)[source]#

Bases: IInterface

String interface

class openalea.core.interface.IStr(**kargs)[source]#

Bases: IInterface

String interface

classmethod default()[source]#
class openalea.core.interface.ITextStr(**kargs)[source]#

Bases: IStr

Long String interface

class openalea.core.interface.ITuple(**kargs)[source]#

Bases: IInterface

Tuple

class openalea.core.interface.ITuple3(**kargs)[source]#

Bases: IInterface

Tuple3

classmethod default()[source]#
class openalea.core.interface.IWidgetMetaClass(name, bases, dic, **kargs)[source]#

Bases: type

InterfaceWidget Metaclass

class openalea.core.interface.InterfaceWidgetMap(*args, **kw)[source]#

Bases: dict

Singleton class to map Interface with InterfaceWidget InterfaceWidgetMap inherits from dict class

declare_interface(interface, widget=None)[source]#

Declare an interface and its optional widget @param interface : IInterface class object @param widget : IInterfaceWidget class object

class openalea.core.interface.TypeInterfaceMap(*args, **kw)[source]#

Bases: dict

Singleton class to map Interface with standard python type InterfaceWidgetMap inherits from dict class

declare_interface(type, interface)[source]#

Declare an interface and its optional widget

Parameters:
  • interface – IInterface class object

  • type – Python type

class openalea.core.interface.TypeNameInterfaceMap(*args, **kw)[source]#

Bases: dict

Singleton class to map Interface Name with interface type InterfaceWidgetMap inherits from dict class

declare_interface(name, interface)[source]#

Declare an interface and its optional widget

Parameters:
  • interface – IInterface class object

  • type – Python type

openalea.core.logger module#

Central logging module from openalea.

Simple Tutorial#

Just to see how easy it is to log something:

from openalea.core import logger
a = 1234
logger.debug("This is an evil value %d"%a)

This examples uses the defaults of the openalea.core.logger module: There is one base logger name “openalea” that logs to a default stream handler (prints out the logs to stderr).

There are more default loggers available:

logger.default_init(level=logger.DEBUG, handlers=["file"])

This line will make logs go to rotating files in ~/.openalea/.

If you’re running PyQt4:

logger.default_init(level=logger.DEBUG, handlers=["qt"])

Will make your logs go to a QStandardItemModel that you can get this way:

itemModel = logger.get_handler("qt")

You can directly use it in a QListView.

Per-package loggers#

The previous example used the central OpenAlea logger. However, we recommend you use a specific logger for your package, eg. Openalea.MTG:

from openalea.core import logger
mylogger = logger.get_logger("Openalea.MTG")
[...]
mylogger.debug("Execution reached this place...")

This will print nothing as mylogger is attached to no handler. You can attach it to Openalea’s handlers if they are any available:

logger.connect_loggers_to_handlers(mylogger, logger.get_handler_names())
mylogger.debug("Execution reached this other place...")

This will make every handler registered to OpenAlea receive the log.

Or you can connect it to your own handlers (In this case you can completely bypass Openalea.)

import logging
mylogger.addHandler(logging.FileHandler("path_to_file", mode="w"))

Indeed, mylogger is a logger.PatchedPyLogger slightly derived from standard logging.Logger.

You can disconnect loggers and handlers::

logger.disconnect_loggers_from_handlers(mylogger, logger.get_handler_names())

This will disconnect all handlers know by openalea from mylogger.

Logging levels#

Logging typically happens at different levels, from the less important to the worst case. You have access to 5 default logging levels: DEBUG, INFO, WARNING, ERROR and CRITICAL.

Through the openalea.core.logger module:

logger.debug(str)
logger.info(str)
logger.warning(str)
logger.error(str)
logger.critical(str)

Or a custom logger:

mylogger = logger.get_logger("Openalea.MTG")
mylogger.debug(str)
mylogger.info(str)
mylogger.warning(str)
mylogger.error(str)
mylogger.critical(str)

You can also send logs of arbitrary levels using the log(level (int), msg (str)) module function (or mylogger.log(int, str)).

Logger objects can be set to ignore logs that happen at levels lower than a chosen one. The same goes for handlers.

In openalea.core.logger, you can set all loggers and handlers to have the same level:

logger.set_global_logger_level(logger.INFO) #DEBUG logs will not be sent to handlers
logger.set_global_handler_level(logger.ERROR) #DEBUG and ERROR logs will be ignored by handlers.

Of course you can do this more selectively:

lg = logger.get_logger("Openalea.MTG")
# lg will not send logs below the CRITICAL level:
lg.setLevel(logger.CRITICAL)

hd = logger.get_handler("qt")
# hd will not process logs below INFO level.
hd.setLevel(logger.INFO)
class openalea.core.logger.LoggerOffice(*args, **kw)[source]#

Bases: object

This class behaves as the central registry of loggers and handlers for Openalea. This way, the application can query information about them.

add_handler(name, handler)[source]#
add_logger(name)[source]#
connect_loggers_to_handlers(loggers, handlers, noDisconnect=False)[source]#
disconnect_loggers_from_handlers(loggers, handlers)[source]#
get_date_format()[source]#
get_default_logger()[source]#
get_format()[source]#
get_handler(name)[source]#
get_handler_names()[source]#
get_logger(name)[source]#
get_logger_names()[source]#
iter_handlers()[source]#
iter_loggers()[source]#
make_default_logger(handlers=None)[source]#
set_default_logger(logger)[source]#
set_defaults(level=40, handlers=None)[source]#
set_global_handler_level(level)[source]#
set_global_logger_level(level)[source]#
openalea.core.logger.connect_loggers_to_handlers(loggers, handlers)[source]#

Connects loggers to handlers. Each argument can be a single item or a list of them. Each item can be the name of the logger/handler or an instance of that.

openalea.core.logger.critical(msg)[source]#

Send a critical level msg to openalea’s default logger. Handlers may or may not be connected yet.

openalea.core.logger.debug(msg)[source]#

Send a debug level msg to openalea’s default logger. Handlers may or may not be connected yet.

openalea.core.logger.defaultHandlerNames = ['file', 'stream']#

List of default handler names:

openalea.core.logger.default_init(level=40, handlers=['file', 'stream'])[source]#

Configure the LoggerOffice with a default openalea logger and handlers named in handlers. The latter is a list of strings from “qt”, “file”, “stream”.

  • “qt” is only available if PyQt4 or PyQt5 is installed. Logs will go to a QStandardItemModel.

  • “file” creates a rotating file handler. Logs are stored in “~/.openalea/log.log.X” files X get incremented every day. Beyond 20 days olds files get deleted.

  • “stream” logs to stderr.

openalea.core.logger.disconnect_loggers_from_handlers(loggers, handlers)[source]#

Disconnect loggers from handlers. Each argument can be a single item or a list of them. Each item can be the name of the logger/handler or an instance of that.

openalea.core.logger.error(msg)[source]#

Send a error level msg to openalea’s default logger. Handlers may or may not be connected yet.

openalea.core.logger.get_handler(name)[source]#

Returns the handler called name. It will always return the same handler for the same name.

openalea.core.logger.get_handler_names()[source]#

Returns a list of handler names known by OpenAlea’s LoggerOffice

openalea.core.logger.get_logger(name)[source]#

Returns the logger called name. It will always return the same logger for the same name.

openalea.core.logger.get_logger_names()[source]#

Returns a list of logger names known by OpenAlea’s LoggerOffice

openalea.core.logger.info(msg)[source]#

Send a info level msg to openalea’s default logger. Handlers may or may not be connected yet.

openalea.core.logger.log(level, msg)[source]#

Send an arbitrary level msg to openalea’s default logger. Handlers may or may not be connected yet.

openalea.core.logger.set_global_handler_level(level)[source]#

Set level of all known handlers to level.

openalea.core.logger.set_global_logger_level(level)[source]#

Set level of all known loggers to level.

openalea.core.logger.warning(msg)[source]#

Send a warning level msg to openalea’s default logger. Handlers may or may not be connected yet.

openalea.core.manager module#

class openalea.core.manager.GenericManager(items=None, item_proxy=None, autoload=['entry_points'])[source]#

Bases: Observed, AbstractListener

add(item, group, item_proxy=None, **kwds)[source]#
add_items(items, group)[source]#
clear()[source]#
discover(group=None)[source]#
generate_item_id(item)[source]#
generate_item_name(item)[source]#
instantiate(item)[source]#
item(self, group, identifier)[source]#

-> Plugin or raises UnknownPluginError

items(group=None, tags=None, criteria=None, **kwds)[source]#
load_items(group=None)[source]#
patch_item(item)[source]#
set_proxy(group, item_proxy)[source]#

Embed all item for given group in item_proxy.

exception openalea.core.manager.UnknownItemError[source]#

Bases: Exception

openalea.core.metaclass module#

todo

openalea.core.metaclass.get_noconflict_metaclass(bases, left_metas, right_metas)[source]#

Not intended to be used outside of this module, unless you know what you are doing.

openalea.core.metaclass.make_metaclass(left_metas=(), right_metas=())[source]#

Generate a metaclass for multi-inherited class

openalea.core.metaclass.remove_redundant(metaclasses)[source]#

todo

openalea.core.metaclass.skip_redundant(iterable, skipset=None)[source]#

Redundant items are repeated items or items in the original skipset.

openalea.core.metadatadict module#

class openalea.core.metadatadict.HasAdHoc[source]#

Bases: object

classmethod extend_ad_hoc_slots(name, _type, default, *args)[source]#

Describes which data and what type are expected to be found in the ad_hoc dictionnary. Used by views.__ad_hoc_slots__ = {} Created at runtime __ad_hoc_from_old_map__ = {}.

get_ad_hoc_dict()[source]#
class openalea.core.metadatadict.MetaDataDict(**kwargs)[source]#

Bases: Observed

Attach meta data of a graphical representation of a graph component. This metadata can be used to customize the appearance of the node.

add_metadata(key, valType, notify=True)[source]#

Creates a new entry in the meta data registry. The data to set will be of the given ‘valType’ type.

do_type_checking(val)[source]#
get_metadata(key)[source]#

Gets the value of a meta data.

get_metadata_type(key)[source]#

Gets the value of a meta data.

keys()[source]#
remove_metadata(key, valType=None, notify=True)[source]#

Removes an entry in the meta data registry.

set_metadata(key, value, notify=True)[source]#

Sets the value of a meta data.

set_slots(slots, useSlotDefaults=True)[source]#
simulate_full_data_change(observer=None, source=None)[source]#
update(other)[source]#

openalea.core.model module#

A Model is an object that can be run. It is generally used to define algorithms or process.

A model has inputs, outputs and an internal state. Inputs and outputs are used to allow communication between environnement and models and between models. Internal state is used by the model itself but cannot be reached from outside. This internal step is generally used when user want to execute model step by step, each step depending on previous one.

To define model instructions, you need to define at least “step” instructions. To do that, you can use:

To use a Model, you also need to define set_code method that is able to extract inputs, outpus and step, init, … from given source code.

Animate notification are not yet implemented.

To reset internal state, use init() method. To run one step, use step() method.

Two convenience methods, see run() and “call” can be used to reset internal state and run a given number of step (one by default)

By default, functions are generated for “init”, “run” and “animate”

class openalea.core.model.IModel(**kwds)[source]#

Bases: object

animate(*args, **kwargs)[source]#

Like run but send notification at each step.

dtype = None#
init(*args, **kwargs)[source]#

Reset internal state, fill namespace and run “init code” if defined.

mimetype = None#
run(*args, **kwargs)[source]#

Init model and run “nstep” step(s).

set_code(code)[source]#

extract and set inputs, outputs and functions from code. For example, if “code” is:

'''
input = a, b:int=5
output = c
'''
def step():
    c = a+b

you can extract input, output and step function. So, m = Model(“m1”) m.set_code(code)

is equivalent to

m = Model(“m1”) m.set_func_code(“step”, “c=a+b”) m.inputs_info = [InputObj(‘a’), InputObj(‘b:int=5’)] m.outputs_info = [OutputObj(‘c’)]

set_func_code(fname, code)[source]#
Parameters:
  • fname – function name: “step”, “init”, “animate”, …

  • code – python source code

set_step_code(code)[source]#

convenience method equivalent to set_func_code(“step”, code)

step(*args, **kwargs)[source]#

run “step code” if defined.

stop(*args, **kwargs)[source]#

Stop execution.

class openalea.core.model.Model(name=None, **kwds)[source]#

Bases: object

animate(*args, **kwds)[source]#
property code#
eval_value(value)[source]#
execute(code)[source]#
get_documentation()[source]#
Returns:

a string with the documentation of the model

icon = ''#
init(*args, **kwds)[source]#
inputs_from_ns(inputs, ns, *args, **kwargs)[source]#
output_from_ns(namespace)[source]#

Get outputs from namespace and set them inside self.outputs

Parameters:

namespace – dict where the model will search the outputs

repr_code()[source]#
run(*args, **kwds)[source]#
run_code(code, namespace)[source]#
set_code(code)[source]#
set_func_code(fname, code)[source]#
set_step_code(code)[source]#
step(*args, **kwds)[source]#
property step_code#
class openalea.core.model.PythonModel(**kwargs)[source]#

Bases: Model

default_name = 'Python'#
dtype = 'Python'#
get_documentation()[source]#
Returns:

a string with the documentation of the model

mimetype = 'text/x-python'#
repr_code()[source]#
set_code(code)[source]#

openalea.core.model_inout module#

Definition of Input and Output objects.

Code to parse the functions.

class openalea.core.model_inout.InputObj(string='')[source]#

Bases: object

Inputs object with:
  • an attribute name: name of the input obj (str) (mandatory)

  • an attribute interface: interface/type of the input obj (str) (optional)

  • an attribute default: default value of the input obj (str) (optional)

>>> from openalea.oalab.model.parse import InputObj
>>> obj = InputObj('a:float=1')
>>> obj.name
'a'
>>> obj.default
'1'
>>> obj.interface
IFloat
>>> obj
InputObj('a:IFloat=1')
Parameters:

string – string object with format “input_name:input_type=input_default_value” or “input_name=input_default_value” or “input_name:input_type” or “input_name”

repr_code()[source]#
class openalea.core.model_inout.OutputObj(string='')[source]#

Bases: InputObj

openalea.core.model_inout.ast_parse(string)[source]#
openalea.core.model_inout.extract_functions(codestring, filename='tmp')[source]#

parse the code codestring and detect what are the functions defined inside :return: dict name -> code

openalea.core.model_inout.get_docstring(string)[source]#

Get a docstring from a string

openalea.core.model_inout.parse_doc(docstring)[source]#

Parse a docstring.

Returns:

model, inputs, outputs

openalea.core.model_inout.parse_doc_in_code(string)[source]#

Take a lpy string_file, parse it and return only the docstring of the file.

Parameters:

string – string representation of lpy file

Returns:

docstring of the file if exists (must be a multiline docstring!). If not found, return None.

Use:
>>> f = open(lpyfilename, "r")
>>> lpystring = f.read()
>>> f.close()
>>>
>>> docstring = parse_lpy(lpystring)
>>>
>>> from openalea.oalab.model.parse import parse_doc
>>> if docstring is not None:
...     model, inputs, outputs = parse_doc(docstring)
...     print "model : ", model
...     print "inputs : ", inputs
...     print "outputs : ", outputs
openalea.core.model_inout.parse_docstring(string)[source]#

parse a string (not a docstring), get the docstring and return information on the model.

Use:

model, inputs, outputs = parse_docstring(multiline_string_to_parse)

Parameters:

string – docstring to parse (string)

Returns:

model, inputs, outputs

openalea.core.model_inout.parse_function(docstring)[source]#
Parse a docstring with format:

my_model(a:int=4, b)->r:int

Unused.

Returns:

model, inputs, outputs

openalea.core.model_inout.parse_input_and_output(docstring)[source]#
Parse a docstring with format:

inputs = input_name:input_type=input_default_value, … outputs = output_name:output_type, …

Use:
>>> from openalea.oalab.model.parse import parse_input_and_output
>>> comment = '''
... input = a:int=4, b
... output = r:float'''
>>> inputs, outputs = parse_input_and_output(comment)
>>> inputs
['a:int=4', 'b']
>>> outputs
['r:float']
Returns:

inputs, outputs

openalea.core.model_inout.set_interface(input_obj)[source]#

openalea.core.node module#

Node and NodeFactory classes.

A Node is generalized functor which is embeded in a dataflow. A Factory build Node from its description. Factories instantiate Nodes on demand for the dataflow.

class openalea.core.node.AbstractFactory(name, description='', category='', inputs=(), outputs=(), lazy=True, delay=0, view=None, alias=None, authors=None, **kargs)[source]#

Bases: Observed

Abstract Factory is Factory base class

clean_files()[source]#

Remove files depending of factory

copy(**args)[source]#

Copy factory

get_authors()[source]#

returns node authors

if no authors is found within the node, then it takes the authors field found in its package.

get_documentation()[source]#
get_id()[source]#

Returns the node factory Id

get_pkg()[source]#

todo

get_python_name()[source]#

Returns a valid python variable as name. This is used to store the factory into a python list (i.e. __all__).

get_tip(asRst=False)[source]#

Return the node description

if no authors is found within the node, then it takes the authors field found in its package.

get_writer()[source]#

Return the writer class

instantiate(call_stack=[])[source]#

Return a node instance

Parameters:

call_stack – the list of NodeFactory id already in call stack (in order to avoir infinite recursion)

instantiate_widget(node=None, parent=None, edit=False, autonomous=False)[source]#

Return the corresponding widget initialised with node

is_composite_node()[source]#
is_data()[source]#
is_node()[source]#
is_valid()[source]#

Return True if the factory is valid else raise an exception

mimetype = 'openalea/nodefactory'#
property package#

todo

set_pkg(port)[source]#

An openalea package contains factories. The factory has a link to this package (weakref). The package id is the name of the package when the package is the Python object.

class openalea.core.node.AbstractNode[source]#

Bases: Observed, HasAdHoc

An AbstractNode is the atomic entity in a dataflow.

internal_data contains properties specified by users. They can be extended and the number is not fixed. We use a dict to distinguish these public properties to the others which are used for protected management.

close()[source]#
get_factory()[source]#

Return the factory of the node (if any)

get_id()[source]#
get_raise_exception()[source]#
invalidate()[source]#

Invalidate Node

mimetype = 'openalea/node'#
property raise_exception#
reload()[source]#

Reset Node

reset()[source]#

Reset Node

set_compositenode(upper)[source]#
set_data(key, value, notify=True)[source]#

Set internal node data

set_factory(factory)[source]#

Set the factory of the node (if any)

set_id(id)[source]#
set_raise_exception(val)[source]#
class openalea.core.node.AbstractPort(vertex)[source]#

Bases: dict, Observed, HasAdHoc

The class describing the ports. AbstractPort is a dict for historical reason.

copy_to(other)[source]#
get_default()[source]#

todo

get_desc()[source]#

Gets default description

get_id()[source]#
get_interface()[source]#

Gets the interface

get_tip(current_value=None)[source]#

Return the tool tip

set_id(id)[source]#
openalea.core.node.Alias(factory, name)[source]#

Create a alias for factory

class openalea.core.node.Annotation[source]#

Bases: AbstractNode

to_script()[source]#

Script translation of this node.

openalea.core.node.Factory#

alias of NodeFactory

class openalea.core.node.FuncNode(inputs, outputs, func)[source]#

Bases: Node

Node with external function or function

get_process_obj()[source]#

Return the process obj

property process_obj#

Return the process obj

class openalea.core.node.InputPort(node)[source]#

Bases: AbstractPort

The class describing the input ports

get_label()[source]#

Gets default label

is_hidden()[source]#

True if the port should not be displayed.

exception openalea.core.node.InstantiationError[source]#

Bases: Exception

todo

class openalea.core.node.Node(inputs=(), outputs=())[source]#

Bases: AbstractNode

It is a callable object with typed inputs and outputs. Inputs and Outpus are indexed by their position or by a name (str)

add_input(**kargs)[source]#

Create an input port

add_output(**kargs)[source]#

Create an output port

property block#

todo

property caption#

Return the node caption

clear_inputs()[source]#
clear_outputs()[source]#
copy_to(other)[source]#
property delay#

todo

eval()[source]#

Evaluate the node by calling __call__ Return True if the node needs a reevaluation and a timed delay if the node needs a reevaluation at a later time.

get_block()[source]#

todo

get_caption()[source]#

Return the node caption

get_delay()[source]#

todo

get_input(index_key)[source]#

Return the input value for the specified index/key

get_input_port(name=None)[source]#

Gets port by name.

Long description of the function functionality.

Parameters:

name (string) – the name of the port

Returns:

Input port characterized by name

Return type:

InputPort

get_input_state(index_key)[source]#
get_lazy()[source]#

todo

get_nb_input()[source]#

Return the nb of input ports

get_nb_output()[source]#

Return the nb of output ports

get_output(index_key)[source]#

Return the output for the specified index/key

get_process_obj()[source]#

Return the process obj

get_tip()[source]#
get_user_application()[source]#

todo

invalidate()[source]#

Invalidate node

static is_deprecated_event(event)[source]#
is_port_hidden(index_key)[source]#

Return the hidden state of a port

property lazy#

todo

notify_listeners(event)[source]#

Send a notification to all listeners

Parameters:

event – an object to pass to the notify function

output(key)[source]#
property process_obj#

Return the process obj

reload()[source]#

Reset ports

reset()[source]#

Reset ports

set_block(data)[source]#

todo

set_caption(newcaption)[source]#

Define the node caption

set_delay(delay)[source]#

todo

set_factory(factory)[source]#

Set the factory of the node (if any) and uptdate caption

set_input(key, val=None, notify=True)[source]#

Define the input value for the specified index/key

set_input_state(index_key, state)[source]#

Set the state of the input index/key (state is a string)

set_io(inputs, outputs)[source]#

Define the number of inputs and outputs

Parameters:
  • inputs – list of dict(name=’X’, interface=IFloat, value=0)

  • outputs – list of dict(name=’X’, interface=IFloat)

set_lazy(data)[source]#

todo

set_output(key, val)[source]#

Define the input value for the specified index/key

set_port_hidden(index_key, state)[source]#

Set the hidden state of a port.

Parameters:
  • index_key – the input port index.

  • state – a boolean value.

set_user_application(data)[source]#

todo

to_script()[source]#

Script translation of this node.

unvalidate_input(index_key, notify=True)[source]#

Unvalidate node and notify listeners.

This method is called when the input value has changed.

property user_application#

todo

class openalea.core.node.NodeFactory(name, description='', category='', inputs=None, outputs=None, nodemodule='', nodeclass=None, widgetmodule=None, widgetclass=None, search_path=None, authors=None, **kargs)[source]#

Bases: AbstractFactory

A Node factory is able to create nodes on demand, and their associated widgets.

apply_new_src(newsrc)[source]#

Execute new src and store the source into the factory.

copy(**args)[source]#

Copy factory :param path: new search path

get_classobj()[source]#
get_documentation()[source]#
get_node_file()[source]#

Return the path of the python module.

get_node_module()[source]#

Return the python module object (if available) Raise an Import Error if no module is associated

get_node_src(cache=True)[source]#

Return a string containing the node src Return None if src is not available If cache is False, return the source on the disk

get_python_name()[source]#

Return a python valid name

get_writer()[source]#

Return the writer class

instantiate(call_stack=[])[source]#

Returns a node instance. :param call_stack: the list of NodeFactory id already in call stack (in order to avoir infinite recursion)

instantiate_widget(node=None, parent=None, edit=False, autonomous=False)[source]#

Return the corresponding widget initialised with node

is_node()[source]#
save_new_src(newsrc)[source]#

Execute the new source and replace the text into the old file containing the source.

class openalea.core.node.OutputPort(node)[source]#

Bases: AbstractPort

The class describing the output ports

class openalea.core.node.PyNodeFactoryWriter(factory)[source]#

Bases: object

NodeFactory python Writer

nodefactory_template = '\n\n$NAME = Factory(name=$PNAME,\n                authors=$AUTHORS,\n                description=$DESCRIPTION,\n                category=$CATEGORY,\n                nodemodule=$NODEMODULE,\n                nodeclass=$NODECLASS,\n                inputs=$LISTIN,\n                outputs=$LISTOUT,\n                widgetmodule=$WIDGETMODULE,\n                widgetclass=$WIDGETCLASS,\n               )\n\n'#
exception openalea.core.node.RecursionError[source]#

Bases: Exception

todo

openalea.core.node.cmp(x, y)[source]#

Replacement for built-in function cmp that was removed in Python 3

Compare the two objects x and y and return an integer according to the outcome. The return value is negative if x < y, zero if x == y and strictly positive if x > y.

openalea.core.node.gen_port_list(size)[source]#

Generate a list of port description

openalea.core.node.initialise_standard_metadata()[source]#

Declares the standard keys used by the Node structures. Called at the end of this file

openalea.core.observer module#

This module defines all the classes for the Observer design Pattern

class openalea.core.observer.AbstractListener[source]#

Bases: object

Listener base class

call_notify(sender, event=None)[source]#

Basic implementation call directly notify function Sub class can override this method to implement different call strategy (like signal slot)

change_observed(old, new)[source]#
deaf(setDeaf=True)[source]#
initialise(observed)[source]#

Register self as a listener to observed

is_notification_locked()[source]#
notify(sender, event=None)[source]#

This function is called by observed objects

Parameters:
  • sender – the observed object which send notification

  • event – the data associated to the notification

notify_lock = None#
queue_call_notifications(call, *args, **kwargs)[source]#

Runs a call and queues notifications coming from that call to this listener. Once the call is finished, queued notifications are processed FIFO.

class openalea.core.observer.Observed[source]#

Bases: object

Observed Object

exclusive_command(who, command, *args, **kargs)[source]#

Executes a call “command” and if it triggers any signal from this observed object along the way, “who” will be the only one to be notified

notify_listeners(event=None)[source]#

Send a notification to all listeners

Parameters:

event – an object to pass to the notify function

post_notification()[source]#
register_listener(listener)[source]#

Add listener to list of listeners. If the observed is currently notifying, the registration is delayed until it finishes.

transfer_listeners(newObs)[source]#

Takes all this observed’s listeners, unregisters them from itself and registers them to the newObs, calling listener.change_observed if implemented

unregister_listener(listener)[source]#

Remove listener from the list of listeners

openalea.core.observer.lock_notify(method)[source]#

openalea.core.package module#

This module defines Package classes.

A Package is a deplyment unit and contains a factories (Node generator) and meta informations (authors, license, doc…)

class openalea.core.package.AbstractPackageReader(filename)[source]#

Bases: object

Abstract class to add a package in the package manager.

register_packages(pkgmanager)[source]#

Create and add a package in the package manager.

class openalea.core.package.DynamicPackage(name, metainfo)[source]#

Bases: PackageDict

Package for dynamical parsing of python file

exception openalea.core.package.FactoryExistsError[source]#

Bases: Exception

class openalea.core.package.Package(name, metainfo, path=None)[source]#

Bases: PackageDict

A Package is a dictionnary of node factory. Each node factory is able to generate node and their widgets.

Meta informations are associated with a package.

add_factory(factory)[source]#

Add to the package a factory ( node or subgraph )

get_factory(id)[source]#

Return the factory associated with id

get_id()[source]#

Return the package id

get_metainfo(key)[source]#

Return a meta information. See the standard key in the __init__ function documentation.

Parameters:

key – todo

get_names()[source]#

Return all the factory names in a list

get_pkg_files()[source]#

Return the list of python filename of the package. The filename are relative to self.path

get_tip()[source]#

Return the package description

get_wralea_path()[source]#

Return the full path of the wralea.py (if set)

is_directory()[source]#

New style package. A package is embeded in a unique directory. This directory can not contain more than one package. Thus, you can move, copy or delete a package by acting on the directory without ambiguity.

Return True if the package is embeded in a directory.

is_editable()[source]#

A convention (for the GUI) to ensure that the user can modify the package.

mimetype = 'openalea/package'#
reload()[source]#

Reload all python file of the package

remove_files()[source]#

Remove pkg files

update_factory(old_name, factory)[source]#

Update factory (change its name)

class openalea.core.package.PyPackageReader(filename)[source]#

Bases: AbstractPackageReader

Build packages from wralea file Use ‘register_package’ function

build_package(wraleamodule, pkgmanager)[source]#

Build package and update pkgmanager

filename_to_module(filename)[source]#

Transform the filename ending with .py to the module name

get_pkg_name()[source]#

Return the OpenAlea (uniq) full package name

register_packages(pkgmanager)[source]#

Execute Wralea.py

class openalea.core.package.PyPackageReaderVlab(filename)[source]#

Bases: AbstractPackageReader

Build a package from a vlab specification file.

register_packages(pkgmanager)[source]#

Create and add a package in the package manager.

class openalea.core.package.PyPackageReaderWralea(filename)[source]#

Bases: PyPackageReader

Build a package from a __wralea__.py Use module variable

build_package(wraleamodule, pkgmanager)[source]#

Build package and update pkgmanager

class openalea.core.package.PyPackageWriter(package)[source]#

Bases: object

Write a wralea python file

get_factories_str()[source]#

Return a dict of (name:repr) of all factory

get_str()[source]#

Return string to write

pkg_template = '\n$PKGNAME\n\n$METAINFO\n\n$ALL\n\n$FACTORY_DECLARATION\n'#
wralea_template = '\n# -*- coding: latin-1 -*-\n# This file has been generated at $TIME\n\nfrom openalea.core import *\n\n$PKG_DECLARATION\n\n'#
write_wralea(full_filename)[source]#

Write the wralea.py in the specified filename

exception openalea.core.package.UnknownNodeError(name)[source]#

Bases: Exception

class openalea.core.package.UserPackage(name, metainfo, path=None)[source]#

Bases: Package

Package user editable and persistent

add_data_file(filename, description='')[source]#

Add a file in a package (copy it in the directory)

add_factory(factory)[source]#

Write change on disk

clone_from_package(pkg)[source]#

Copy the contents of pkg in self

create_user_compositenode(name, category, description, inputs, outputs)[source]#

Add a new user composite node factory to the package and save the package. Returns the cn factory.

create_user_node(name, category, description, inputs, outputs)[source]#

Return a new user node factory This function create a new python module in the package directory The factory is added to the package and the package is saved.

is_editable()[source]#

A convention (for the GUI) to ensure that the user can modify the package.

remove_files()[source]#

Remove pkg files

set_icon(filename)[source]#

Set package icon Copy filename in the package dir

write()[source]#

Return the writer class

openalea.core.path module#

path.py - An object representing a path to a file or directory.

Original author:

Jason Orendorff <jason.orendorff@gmail.com>

Contributors:

Mikhail Gusarov <dottedmag@dottedmag.net> Marc Abramowitz <marc@marc-abramowitz.com> Jason R. Coombs <jaraco@jaraco.com> Jason Chu <jchu@xentac.net> Vojislav Stojkovic <vstojkovic@syntertainment.com>

Example:

from path import path d = path(‘/home/guido/bin’) for f in d.files(’*.py’):

f.chmod(0755)

path.py requires Python 2.5 or later.

class openalea.core.path.path(other)[source]#

Bases: str

Represents a filesystem path.

For documentation on individual methods, consult their counterparts in os.path.

abspath()[source]#
access(mode)[source]#

Return true if current user has access to this path.

mode - One of the constants os.F_OK, os.R_OK, os.W_OK, os.X_OK

property atime#

Last access time of the file.

basename()[source]#
bytes()[source]#

Open this file, read all bytes, return them as a string.

chmod(mode)[source]#
chown(uid, gid)[source]#
chroot()[source]#
copy(dst, *, follow_symlinks=True)#

Copy data and mode bits (“cp src dst”). Return the file’s destination.

The destination may be a directory.

If follow_symlinks is false, symlinks won’t be followed. This resembles GNU’s “cp -P src dst”.

If source and destination are the same file, a SameFileError will be raised.

copy2(dst, *, follow_symlinks=True)#

Copy data and metadata. Return the file’s destination.

Metadata is copied with copystat(). Please see the copystat function for more information.

The destination may be a directory.

If follow_symlinks is false, symlinks won’t be followed. This resembles GNU’s “cp -P src dst”.

copyfile(dst, *, follow_symlinks=True)#

Copy data from src to dst in the most efficient way possible.

If follow_symlinks is not set and src is a symbolic link, a new symlink will be created instead of copying the file it points to.

copymode(dst, *, follow_symlinks=True)#

Copy mode bits from src to dst.

If follow_symlinks is not set, symlinks aren’t followed if and only if both src and dst are symlinks. If lchmod isn’t available (e.g. Linux) this method does nothing.

copystat(dst, *, follow_symlinks=True)#

Copy file metadata

Copy the permission bits, last access time, last modification time, and flags from src to dst. On Linux, copystat() also copies the “extended attributes” where possible. The file contents, owner, and group are unaffected. src and dst are path-like objects or path names given as strings.

If the optional flag follow_symlinks is not set, symlinks aren’t followed if and only if both src and dst are symlinks.

copytree(dst, symlinks=False, ignore=None, copy_function=<function copy2>, ignore_dangling_symlinks=False, dirs_exist_ok=False)#

Recursively copy a directory tree and return the destination directory.

If exception(s) occur, an Error is raised with a list of reasons.

If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. If the file pointed to by the symlink doesn’t exist, an exception will be added in the list of errors raised in an Error exception at the end of the copy process.

You can set the optional ignore_dangling_symlinks flag to true if you want to silence this exception. Notice that this has no effect on platforms that don’t support os.symlink.

The optional ignore argument is a callable. If given, it is called with the src parameter, which is the directory being visited by copytree(), and names which is the list of src contents, as returned by os.listdir():

callable(src, names) -> ignored_names

Since copytree() is called recursively, the callable will be called once for each directory that is copied. It returns a list of names relative to the src directory that should not be copied.

The optional copy_function argument is a callable that will be used to copy each file. It will be called with the source path and the destination path as arguments. By default, copy2() is used, but any function that supports the same signature (like copy()) can be used.

If dirs_exist_ok is false (the default) and dst already exists, a FileExistsError is raised. If dirs_exist_ok is true, the copying operation will continue if it encounters existing directories, and files within the dst tree will be overwritten by corresponding files from the src tree.

property ctime#

Creation time of the file.

dirname()[source]#
dirs() List of this directory's subdirectories.[source]#

The elements of the list are path objects. This does not walk recursively into subdirectories (but see path.walkdirs).

With the optional ‘pattern’ argument, this only lists directories whose names match the given pattern. For example, d.dirs(‘build-*’).

property drive#

‘. This is always empty on systems that don’t use drive specifiers.

Type:

The drive specifier, for example ‘C

exists()[source]#
expand()[source]#

Clean up a filename by calling expandvars(), expanduser(), and normpath() on it.

This is commonly everything needed to clean up a filename read from a configuration file, for example.

expanduser()[source]#
expandvars()[source]#
property ext#

The file extension, for example ‘.py’.

files() List of the files in this directory.[source]#

The elements of the list are path objects. This does not walk into subdirectories (see path.walkfiles).

With the optional ‘pattern’ argument, this only lists files whose names match the given pattern. For example, d.files(’*.pyc’).

fnmatch(pattern)[source]#

Return True if self.name matches the given pattern.

pattern - A filename pattern with wildcards,

for example ‘*.py’.

get_owner()#

Return the name of the owner of this file or directory. Follow symbolic links.

getatime()[source]#
getctime()[source]#
classmethod getcwd()[source]#

Return the current working directory as a path object.

getmtime()[source]#
getsize()[source]#
glob(pattern)[source]#

Return a list of path objects that match the pattern.

pattern - a path relative to this directory, with wildcards.

For example, path(‘/users’).glob(’/bin/’) returns a list of all the files users have in their bin directories.

isabs()[source]#
isdir()[source]#
isfile()[source]#
ismount()[source]#
joinpath(*others)#

Join first to zero or more path components, adding a separator character (first.module.sep) if needed. Returns a new instance of first._next_class.

lines(encoding=None, errors='strict', retain=True)[source]#

Open this file, read all lines, return them in a list.

Optional arguments:
encoding - The Unicode encoding (or character set) of

the file. The default is None, meaning the content of the file is read as 8-bit characters and returned as a list of (non-Unicode) str objects.

errors - How to handle Unicode errors; see help(str.decode)

for the options. Default is ‘strict’

retain - If true, retain newline characters; but all newline

character combinations (’r’, ‘n’, ‘rn’) are translated to ‘n’. If false, newline characters are stripped off. Default is True.

This uses ‘U’ mode.

Create a hard link at ‘newpath’, pointing to this file.

listdir() List of items in this directory.[source]#

Use D.files() or D.dirs() instead if you want a listing of just files or just subdirectories.

The elements of the list are path objects.

With the optional ‘pattern’ argument, this only lists items whose names match the given pattern.

lstat()[source]#

Like path.stat(), but do not follow symbolic links.

makedirs(mode=511)[source]#
makedirs_p(mode=511)[source]#
mkdir(mode=511)[source]#
mkdir_p(mode=511)[source]#
module = <module 'posixpath' (frozen)>#

The path module to use for path operations.

move(dst, copy_function=<function copy2>)#

Recursively move a file or directory to another location. This is similar to the Unix “mv” command. Return the file or directory’s destination.

If dst is an existing directory or a symlink to a directory, then src is moved inside that directory. The destination path in that directory must not already exist.

If dst already exists but is not a directory, it may be overwritten depending on os.rename() semantics.

If the destination is on our current filesystem, then rename() is used. Otherwise, src is copied to the destination and then removed. Symlinks are recreated under the new name if os.rename() fails because of cross filesystem renames.

The optional copy_function argument is a callable that will be used to copy the source or it will be delegated to copytree. By default, copy2() is used, but any function that supports the same signature (like copy()) can be used.

A lot more could be done here… A look at a mv.c shows a lot of the issues this implementation glosses over.

property mtime#

Last-modified time of the file.

property name#

The name of this file or directory without the full path.

For example, path(‘/usr/local/lib/libpython.so’).name == ‘libpython.so’

property namebase#

The same as path.name, but with one file extension stripped off.

For example, path(‘/home/guido/python.tar.gz’).name == ‘python.tar.gz’, but path(‘/home/guido/python.tar.gz’).namebase == ‘python.tar’

normcase()[source]#
normpath()[source]#
open(mode='rt')[source]#

Open this file. Return a file object.

property owner#

Name of the owner of this file or directory.

property parent#

This path’s parent directory, as a new path object.

For example, path(‘/usr/local/lib/libpython.so’).parent == path(‘/usr/local/lib’)

pathconf(name)[source]#
read_hash(hash_name)[source]#

Calculate given hash for this file.

List of supported hashes can be obtained from hashlib package. This reads the entire file.

read_hexhash(hash_name)[source]#

Calculate given hash for this file, returning hexdigest.

List of supported hashes can be obtained from hashlib package. This reads the entire file.

read_md5()[source]#

Calculate the md5 hash for this file.

This reads through the entire file.

Return the path to which this symbolic link points.

The result may be an absolute or a relative path.

readlinkabs()[source]#

Return the path to which this symbolic link points.

The result is always an absolute path.

realpath()[source]#
relpath()[source]#

Return this path as a relative path, based from the current working directory.

relpathto(dest)[source]#

Return a relative path from self to dest.

If there is no relative path from self to dest, for example if they reside on different drives in Windows, then this returns dest.abspath().

remove()[source]#
remove_p()[source]#
removedirs()[source]#
removedirs_p()[source]#
rename(new)[source]#
renames(new)[source]#
rmdir()[source]#
rmdir_p()[source]#
rmtree(ignore_errors=False, onerror=None, *, onexc=None, dir_fd=None)#

Recursively delete a directory tree.

If dir_fd is not None, it should be a file descriptor open to a directory; path will then be relative to that directory. dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplementedError.

If ignore_errors is set, errors are ignored; otherwise, if onexc or onerror is set, it is called to handle the error with arguments (func, path, exc_info) where func is platform and implementation dependent; path is the argument to that function that caused it to fail; and the value of exc_info describes the exception. For onexc it is the exception instance, and for onerror it is a tuple as returned by sys.exc_info(). If ignore_errors is false and both onexc and onerror are None, the exception is reraised.

onerror is deprecated and only remains for backwards compatibility. If both onerror and onexc are set, onerror is ignored and onexc is used.

rmtree_p()[source]#
samefile()[source]#
property size#

Size of the file, in bytes.

splitall()[source]#

Return a list of the path components in this path.

The first item in the list will be a path. Its value will be either os.curdir, os.pardir, empty, or the root directory of this path (for example, ‘/’ or ‘C:\’). The other items in the list will be strings.

path.path.joinpath(*result) will yield the original path.

splitdrive() Return (p.drive, <the rest of p>).[source]#

Split the drive specifier from this path. If there is no drive specifier, p.drive is empty, so the return value is simply (path(‘’), p). This is always the case on Unix.

splitext() Return (p.stripext(), p.ext).[source]#

Split the filename extension from this path and return the two parts. Either part may be empty.

The extension is everything from ‘.’ to the end of the last path segment. This has the property that if (a, b) == p.splitext(), then a + b == p.

splitpath() Return (p.parent, p.name).[source]#
splitunc()[source]#
stat()[source]#

Perform a stat() system call on this path.

statvfs()[source]#

Perform a statvfs() system call on this path.

stripext() Remove one file extension from the path.[source]#

For example, path(‘/home/guido/python.tar.gz’).stripext() returns path(‘/home/guido/python.tar’).

Create a symbolic link at ‘newlink’, pointing here.

text(encoding=None, errors='strict')[source]#

Open this file, read it in, return the content as a string.

This method uses ‘U’ mode, so ‘rn’ and ‘r’ are automatically translated to ‘n’.

Optional arguments:

encoding - The Unicode encoding (or character set) of

the file. If present, the content of the file is decoded and returned as a unicode object; otherwise it is returned as an 8-bit str.

errors - How to handle Unicode errors; see help(str.decode)

for the options. Default is ‘strict’.

touch()[source]#

Set the access/modified times of this file to the current time. Create the file if it does not exist.

property uncshare#

The UNC mount point for this path. This is empty for paths on local drives.

classmethod using_module(module)[source]#
utime(times)[source]#

Set the access and modified times of this file.

walk() iterator over files and subdirs, recursively.[source]#

The iterator yields path objects naming each child item of this directory and its descendants. This requires that D.isdir().

This performs a depth-first traversal of the directory tree. Each directory is returned just before all its children.

The errors= keyword argument controls behavior when an error occurs. The default is ‘strict’, which causes an exception. The other allowed values are ‘warn’, which reports the error via warnings.warn(), and ‘ignore’.

walkdirs() iterator over subdirs, recursively.[source]#

With the optional ‘pattern’ argument, this yields only directories whose names match the given pattern. For example, mydir.walkdirs(’*test’) yields only directories with names ending in ‘test’.

The errors= keyword argument controls behavior when an error occurs. The default is ‘strict’, which causes an exception. The other allowed values are ‘warn’, which reports the error via warnings.warn(), and ‘ignore’.

walkfiles() iterator over files in D, recursively.[source]#

The optional argument, pattern, limits the results to files with names that match the pattern. For example, mydir.walkfiles(’*.tmp’) yields only files with the .tmp extension.

write_bytes(bytes, append=False)[source]#

Open this file and write the given bytes to it.

Default behavior is to overwrite any existing file. Call p.write_bytes(bytes, append=True) to append instead.

write_lines(lines, encoding=None, errors='strict', linesep='\n', append=False)[source]#

Write the given lines of text to this file.

By default this overwrites any existing file at this path.

This puts a platform-specific newline sequence on every line. See ‘linesep’ below.

lines - A list of strings.

encoding - A Unicode encoding to use. This applies only if

‘lines’ contains any Unicode strings.

errors - How to handle errors in Unicode encoding. This

also applies only to Unicode strings.

linesep - The desired line-ending. This line-ending is

applied to every line. If a line already has any standard line ending (’r’, ‘n’, ‘rn’, u’x85’, u’rx85’, u’u2028’), that will be stripped off and this will be used instead. The default is os.linesep, which is platform-dependent (’rn’ on Windows, ‘n’ on Unix, etc.) Specify None to write the lines as-is, like file.writelines().

Use the keyword argument append=True to append lines to the file. The default is to overwrite the file. Warning: When you use this with Unicode data, if the encoding of the existing data in the file is different from the encoding you specify with the encoding= parameter, the result is mixed-encoding data, which can really confuse someone trying to read the file later.

write_text(text, encoding=None, errors='strict', linesep='\n', append=False)[source]#

Write the given text to this file.

The default behavior is to overwrite any existing file; to append instead, use the ‘append=True’ keyword argument.

There are two differences between path.write_text() and path.write_bytes(): newline handling and Unicode handling. See below.

Parameters:
  • written. (- text - str/unicode - The text to be)

  • used. (- encoding - str - The Unicode encoding that will be) – This is ignored if ‘text’ isn’t a Unicode string.

  • errors. (- errors - str - How to handle Unicode encoding) – Default is ‘strict’. See help(unicode.encode) for the options. This is ignored if ‘text’ isn’t a Unicode string.

  • of (- linesep - keyword argument - str/unicode - The sequence) – characters to be used to mark end-of-line. The default is os.linesep. You can also specify None; this means to leave all newlines as they are in ‘text’.

  • if (- append - keyword argument - bool - Specifies what to do) – the file already exists (True: append to the end of it; False: overwrite it.) The default is False.

— Newline handling.

write_text() converts all standard end-of-line sequences (’n’, ‘r’, and ‘rn’) to your platform’s default end-of-line sequence (see os.linesep; on Windows, for example, the end-of-line marker is ‘rn’).

If you don’t like your platform’s default, you can override it using the ‘linesep=’ keyword argument. If you specifically want write_text() to preserve the newlines as-is, use ‘linesep=None’.

This applies to Unicode text the same as to 8-bit text, except there are three additional standard Unicode end-of-line sequences: u’x85’, u’rx85’, and u’u2028’.

(This is slightly different from when you open a file for writing with fopen(filename, “w”) in C or open(filename, ‘w’) in Python.)

— Unicode

If ‘text’ isn’t Unicode, then apart from newline handling, the bytes are written verbatim to the file. The ‘encoding’ and ‘errors’ arguments are not used and must be omitted.

If ‘text’ is Unicode, it is first converted to bytes using the specified ‘encoding’ (or the default encoding if ‘encoding’ isn’t specified). The ‘errors’ argument applies only to this conversion.

openalea.core.pkgdict module#

Special Dict with case insensitive key and protected field

class openalea.core.pkgdict.PackageDict(*args)[source]#

Bases: dict

Dictionnary with case insensitive key This object is able to handle protected entry begining with an ‘#’

get(key, default=None)[source]#

Return the value for key if key is in the dictionary, else default.

has_key(key)[source]#
iter_public_values()[source]#

Iterate througth dictionnary value (remove protected value)

nb_public_values()[source]#

Return the number of unprotected values

openalea.core.pkgdict.is_protected(item)[source]#

Return true the item is protected

openalea.core.pkgdict.lower(item)[source]#
openalea.core.pkgdict.protected(item)[source]#

Return corresponding protected name for item

openalea.core.pkgmanager module#

This module defines the package manager.

It is able to find installed package and their wralea.py It stores the packages and nodes informations

exception openalea.core.pkgmanager.IllFormedUrlError(url)[source]#

Bases: Exception

class openalea.core.pkgmanager.Logger[source]#

Bases: object

OpenAlea logging class

add(msg)[source]#

Write to log file

print_log()[source]#

Print log file

class openalea.core.pkgmanager.PackageManager(*args, **kw)[source]#

Bases: Observed

The PackageManager is a Dictionary of Packages It can locate OpenAlea packages on the system (with wralea).

add_package(package)[source]#

Add a package to the pkg manager

add_wralea_path(path, container)[source]#

Add a search path for wralea files

Parameters:
  • path – a path string

  • container – set containing the path

clear()[source]#

Remove all packages

create_readers(wralea_files)[source]#
create_user_package(name, metainfo, path=None)[source]#

Create a new package in the user space and register it Return the created package :param path : the directory where to create the package

dependencies(package_or_factory=None)[source]#

Return all the dependencies of a package or a factory.

emit_update()[source]#
find_all_wralea()[source]#

Find on the system all wralea.py files

:return : a list of file paths

find_and_register_packages(no_cache=False)[source]#

Find all wralea on the system and register them If no_cache is True, ignore cache file

find_vlab_dir(directory, recursive=True)[source]#

Find in a directory vlab specification file.

Search recursivly is recursive is True

Returns:

a list of pkgreader instances

find_wralea_dir(directory, recursive=True)[source]#

Find in a directory wralea files, Search recursivly is recursive is True

:return : a list of pkgreader instances

find_wralea_files()[source]#

Find on the system all wralea.py files

:return : a list of pkgreader instances

get(*args)[source]#
get_composite_nodes(pkg_name=None)[source]#
get_data(pattern='*.*', pkg_name=None, as_paths=False)[source]#

Return all data that match the pattern.

get_factory_from_url(url)[source]#

Returns a node instance from the given url.

Parameters:

  • url - is either a string or a urlparse.ParseResult instance.

It is encoded this way: oa://domain/packageName?fac=*factoryName*&ft=*factoryType* . “oa” means that it is meant to be used by openalea. “domain” MUST BE “local” for now. “packageName” is the name of the package “factoryName” is the of factory “factoryType” is one of {“CompositeNodeFactory”, “NodeFactory”, “DataFactory”}

get_node(pkg_id, factory_id)[source]#

Return a node instance giving a pkg_id and a factory_id

get_node_from_url(url)[source]#
get_nodes(pkg_name=None)[source]#
get_package_from_url(url)[source]#
get_packages(pkg_name=None)[source]#

Return all public packages.

get_pkgreader(filename)[source]#

Return the pkg reader corresponding to the filename

get_pseudo_cat()[source]#

Return a pseudo category structure

get_pseudo_pkg()[source]#

Return a pseudopackage structure

get_user_packages()[source]#

Return the list of user packages

get_wralea_path()[source]#

return the list of wralea path (union of user and system)

has_key(key)[source]#
init(dirname=None, verbose=True)[source]#

Initialize package manager

If dirname is None, find wralea files on the system else load directory If verbose is False, don’t print any output

items()[source]#
iteritems()[source]#
iterkeys()[source]#
itervalues()[source]#
keys()[source]#
load_directory(dirname)[source]#

Load a directory containing wraleas

missing_dependencies(package_or_factory=None)[source]#

Return all the dependencies of a package or a factory.

rebuild_category()[source]#

Rebuild all the category

recover_syspath()[source]#

Restore the initial sys path

reload(pkg=None)[source]#

Reload one or all packages.

If the package pkg is None reloa all the packages. Else reload only pkg.

rename_package(old_name, new_name)[source]#

Rename package ‘old_name’ to ‘new_name’

search_node(search_str, nb_inputs=-1, nb_outputs=-1)[source]#

Return a list of Factory corresponding to search_str If nb_inputs or nb_outputs is specified, return only node with the same number of (in/out) ports

The results are sorted in the following way:
1 - Highest Prioritypresence of search_str in factory name

and position in the name (closer to the begining = higher score)

2 - ThenNumber of occurences of search_str in the factory

description.

3 - Then : Number of occurences of search_str in the category name 4 - Finally : presence of search_str in package name and position

in the name (close to the begining = higher score)

set_sys_wralea_path()[source]#

Define the default wralea search path

For that, we look for “wralea” entry points and deprecated_wralea entry point if a package is declared as deprecated_wralea, the module is not load

set_user_wralea_path()[source]#

Read user config

update_category(package)[source]#

Update the category dictionary with package contents

values()[source]#
who_use(factory_name)[source]#

Search who use a package or a factory

return a list of factory.

write_config()[source]#

Write user config

class openalea.core.pkgmanager.PseudoGroup(name)[source]#

Bases: PackageDict

Data structure used to separate dotted naming (packages, category)

add_name(name, value)[source]#

Add a value in the structure with the key name_tuple

get_id()[source]#

todo

get_tip()[source]#

todo

mimetype = 'openalea/package'#
new(name)[source]#

todo

sep = '.'#
class openalea.core.pkgmanager.PseudoPackage(name)[source]#

Bases: PseudoGroup

Package structure used to separate dotted naming (packages, category)

get_metainfo(key)[source]#

todo

get_tip()[source]#

todo

is_real_package()[source]#

todo

new(name)[source]#

todo

exception openalea.core.pkgmanager.UnknowFileType[source]#

Bases: Exception

exception openalea.core.pkgmanager.UnknownPackageError(name)[source]#

Bases: Exception

openalea.core.pkgmanager.cmp(x, y)[source]#

Replacement for built-in function cmp that was removed in Python 3

Compare the two objects x and y and return an integer according to the outcome. The return value is negative if x < y, zero if x == y and strictly positive if x > y.

openalea.core.pkgmanager.cmp_name(x, y)[source]#

Comparison function

openalea.core.pm_extend module#

openalea.core.pm_extend.cn_deps(pm, cn_factory)[source]#

return all the factory dependencies of a composite node.

openalea.core.pm_extend.cn_pkgs_deps(pm, cn_factory)[source]#
openalea.core.pm_extend.composite_dependencies(pm, cn_factory)[source]#
openalea.core.pm_extend.composites(pm, pkg_name=None)[source]#
openalea.core.pm_extend.data(pm, pattern='*.*', pkg_name=None)[source]#
openalea.core.pm_extend.get_packages(pm, pkg_name=None)[source]#
openalea.core.pm_extend.get_pm()[source]#
openalea.core.pm_extend.is_cn(factory)[source]#
openalea.core.pm_extend.is_data(factory)[source]#
openalea.core.pm_extend.is_node(factory)[source]#
openalea.core.pm_extend.nodes(pm, pkg_name=None)[source]#
openalea.core.pm_extend.package_dependencies(pm, package)[source]#
openalea.core.pm_extend.pm_dependencies(pm)[source]#
openalea.core.pm_extend.print_score(score)[source]#
openalea.core.pm_extend.score_packages(pm)[source]#
openalea.core.pm_extend.uid(factory)[source]#

openalea.core.script_library module#

This module defines the ScriptLibrary class to register objects with their names

class openalea.core.script_library.ScriptLibrary(*args, **kw)[source]#

Bases: object

The ScriptLibrary is a library that register python objects with their names

clear()[source]#

Clear all registered names.

find_free_name(prefix)[source]#
name(obj, script)[source]#

Retrieves the name associated with a python object

register(obj, suggested_name='obj')[source]#

Register a python object This method will try to use suggested_name if it is available.

openalea.core.serialization module#

class openalea.core.serialization.AbstractDeserializer[source]#

Bases: object

deserialize(lines, protocol=None, **kwds)[source]#
update(obj, lines, protocol=None, **kwds)[source]#
class openalea.core.serialization.AbstractLoader[source]#

Bases: object

load(path, protocol=None, **kwds)[source]#
update(obj, path, protocol=None, **kwds)[source]#
class openalea.core.serialization.AbstractSaver[source]#

Bases: object

save(obj, path, protocol=None, **kwds)[source]#
class openalea.core.serialization.BGEOMLoader[source]#

Bases: AbstractLoader

Specific loader that is used to manipulate PlantGL objects

default_name = 'BGEOMLoader'#
input_format = '*.BGEOM'#
load(filename)[source]#
Parameters:

filename – filename to convert into python object

Returns:

a python object interpreted from string “text”

class openalea.core.serialization.BGEOMSaver[source]#

Bases: object

Specific loader that is used to manipulate PlantGL objects

default_name = 'BGEOMSaver'#
output_format = '*.BGEOM'#
save(obj, filename)[source]#

Store obj into filename

class openalea.core.serialization.BinaryLoader[source]#

Bases: object

default_name = 'BinaryLoader'#
input_format = '*'#
load(filename)[source]#
class openalea.core.serialization.BinarySaver[source]#

Bases: AbstractSaver

default_name = 'BinarySaver'#
output_format = '*'#
save(obj, filename)[source]#
class openalea.core.serialization.CPickleLoader[source]#

Bases: AbstractLoader

Specific loader that use cPickle.loads

default_name = 'CPickleLoader'#
input_format = '*'#
load(filename)[source]#
Parameters:

filename – filename to convert into python object

Returns:

a python object interpreted from filename

class openalea.core.serialization.CPickleSaver[source]#

Bases: AbstractSaver

Specific saver that use cPickle.dump

default_name = 'CPickleSaver'#
output_format = '*'#
save(obj, path)[source]#

Store obj into filename

class openalea.core.serialization.GenericLoader[source]#

Bases: object

Classical loader that read file

default_name = 'GenericLoader'#
input_format = '*.py'#
load(filename)[source]#
Parameters:

filename – filename to convert into python object

Returns:

a python object interpreted from string “text”

class openalea.core.serialization.GenericTextSaver[source]#

Bases: AbstractSaver

Classical saver that write str(obj) into file

default_name = 'GenericSaver'#
output_format = '*.py'#
class openalea.core.serialization.IDeserializer[source]#

Bases: object

Generic interface class for savers

default_name#

alias of str

deserialize(lines, protocol=None, **kwds)[source]#
dtype = []#
options = []#
protocols = []#
update(lines, obj, protocol=None, **kwds)[source]#
class openalea.core.serialization.ILoader[source]#

Bases: object

default_name#

alias of str

dtype = []#
load(path, protocol=None, **kwds)[source]#
options = []#
protocols = []#
update(obj, path, protocol=None, **kwds)[source]#

Like “load” but update, if available, an existing object and return it. If no update is available, method must return new instance.

Ex:

data = MyData()
loader = MyLoader()
data2 = data.update('test.dat', data)
data is data2 # True if update is supported, else False
class openalea.core.serialization.ISaver[source]#

Bases: object

Generic interface class for savers

default_name#

alias of str

dtype = []#
options = []#
protocols = []#
save(obj, path, protocol=None, **kwds)[source]#
class openalea.core.serialization.ISerializer[source]#

Bases: object

Generic interface class for savers

default_name#

alias of str

dtype = []#
options = []#
protocols = []#
serialize(obj, protocol=None, **kwds)[source]#

This method must return an iterable object, ideally an iterator

class openalea.core.serialization.PythonLoader[source]#

Bases: object

Classical loader that read file and try to eval object

default_name = 'PythonLoader'#
input_format = '*.py'#
load(filename)[source]#
Parameters:

filename – filename to convert into python object

Returns:

a python object interpreted from string “text”

openalea.core.session module#

Session regroups all the data which can be stored between different executions of the system.

class openalea.core.session.Session[source]#

Bases: Observed

A session is composed by different workspaces, and an user package. A workspace is an open node A session can be saved on disk.

USR_PKG_NAME = '__my_package__'#
add_graph_view(view)[source]#
add_workspace(compositenode=None, notify=True)[source]#

Open a new workspace in the session if compositenode = None, create a new empty compositenode

clear(create_workspace=True)[source]#

Reinit Session

close_workspace(index, notify=True)[source]#

Close workspace at index

get_current_workspace()[source]#

Return the current workspace object

get_graph_views()[source]#
init(create_workspace=True)[source]#

Init the Session

load(filename)[source]#

Load session data from filename

load_module(name, path)[source]#
save(filename=None)[source]#

Save session in filename user_pkg and workspaces data are saved

Be careful, this method do not work very well if data are not persistent.

simulate_workspace_addition()[source]#
property ws#

Return the current workspace object

openalea.core.settings module#

Setting class retrieve and set user configuration

class openalea.core.settings.Settings(*args, **kw)[source]#

Bases: object

Retrieve and set user configuration

add_option(section, option, value='NotSet')[source]#
add_section(section)[source]#
add_section_update_handler(section, handler)[source]#
cleanup()[source]#
exists(section)[source]#
get(section, option)[source]#
has_section(section)[source]#
read()[source]#

Overriden method to read the configuration from Openalea’s default configuration file

sections()[source]#
set(section, option, value)[source]#

Set the value of an option within a section. Both must exist

write()[source]#

Overriden method to write the configuration to Openalea’s default configuration file

openalea.core.settings.get_default_home_dir()[source]#

Return the home directory (valid on linux and windows)

openalea.core.settings.get_openalea_home_dir(name='.openalea')[source]#

Return the openalea home dirextory If it doesn’t exist, create it

openalea.core.settings.get_openalea_tmp_dir(name='.openalea')[source]#

Return the openalea temporary project directory If it doesn’t exist, create it

openalea.core.settings.get_project_dir(name='projects')[source]#

Get default directory (the place where the projects will be created). If it doesn’t exist, create it

openalea.core.settings.get_userpkg_dir(name='user_pkg')[source]#

Get user package directory (the place where are the wralea.py files). If it doesn’t exist, create it

openalea.core.signature module#

Signature class that instropect python functor based on the code

class openalea.core.signature.Signature(f)[source]#

Bases: object

Object to represent the signature of a function/method.

Parameters:

f – a function object containing __name__ variable

get_all_parameters(eludeSelf=True)[source]#
static get_callable_arguments(function)[source]#

Static method that returns 5 values for one entry object which can be any callable. The returned 5-uple is as follows: 0 - list-of-simple-arguments. Can be an empty list. 1 - list-of-(argname,argvalue)-arguments-with-defaults. Can be an empty list. 2 - name-of-vararg-argument. Can be None. 3 - name-of-keyword-argument. Can be None. 5 - boolean : True if function is a method, False otherwise… For Python defined callables, uses the “inspect” module. For builtins, tries some regexp parsing of the docstring.

get_doc()[source]#
get_keywords()[source]#
get_name()[source]#
get_parameters(eludeSelf=True)[source]#
get_returns()[source]#

Return the outputs of a functor based on a predifened contract. TO BE DEFINED TODO

get_varargs()[source]#
static regexp_args(function)[source]#

openalea.core.signature2 module#

Signature class that instropect python functor based on the code

openalea.core.signature2.sign_from_string(f, string)[source]#
openalea.core.signature2.sign_inputs(f)[source]#

Return list of inputs detected from f.__inputs__

openalea.core.signature2.sign_outputs(f)[source]#

Return list of outputs detected from f.__outputs__

openalea.core.singleton module#

This module defines the singleton metaclass

class openalea.core.singleton.ProxySingleton(name, bases, dic)[source]#

Bases: Singleton

Singleton Metaclass which returns a proxy

class openalea.core.singleton.Singleton(name, bases, dic)[source]#

Bases: type

Singleton Metaclass

openalea.core.threadmanager module#

This module defines the thread manager The Thread manager provides thread on demand

class openalea.core.threadmanager.ThreadManager(*args, **kw)[source]#

Bases: object

ThreadManager provides thread on demand

NUM_THREAD = 4#
add_task(func, params)[source]#

Add a task to perform :param func: function to call :param params : tuple of parameters

clear()[source]#

clear pending task

openalea.core.threadmanager.worker(queue)[source]#

Thread function

openalea.core.traitsui module#

View for organizing the component lookout.

class openalea.core.traitsui.Group(label, *values, **keys)[source]#

Bases: object

Describes the group for View.

<Long description of the class functionality.>

class openalea.core.traitsui.Item(name, **keys)[source]#

Bases: object

Describes the atom of View.

<Long description of the class functionality.>

class openalea.core.traitsui.View(*values, **kargs)[source]#

Bases: object

Describes the layout of widget.

<Long description of the class functionality.>

openalea.core.unittest_tools module#

class openalea.core.unittest_tools.EventTracker(debug=False)[source]#

Bases: AbstractListener

property events#
notify(sender, event=None)[source]#

This function is called by observed objects

Parameters:
  • sender – the observed object which send notification

  • event – the data associated to the notification

class openalea.core.unittest_tools.TestCase(methodName='runTest')[source]#

Bases: TestCase

check_events(events, names=None, values=None)[source]#

values: dict {idx:[val, val2]}

openalea.core.util module#

openalea.core.util.camel_case_to_lower(name)[source]#
Examples:

>>> camel_case_to_lower('squareRoot')
'square_root'
>>> camel_case_to_lower('SquareRoot')
'square_root'
>>> camel_case_to_lower('ComputeSQRT')
'compute_sqrt'
>>> camel_case_to_lower('SQRTCompute')
'sqrt_compute'
openalea.core.util.camel_case_to_upper(name)[source]#
Examples:

>>> camel_case_to_upper('squareRoot')
'SQUARE_ROOT'
>>> camel_case_to_upper('SquareRoot')
'SQUARE_ROOT'
>>> camel_case_to_upper('ComputeSQRT')
'COMPUTE_SQRT'
>>> camel_case_to_upper('SQRTCompute')
'SQRT_COMPUTE'
>>> camel_case_to_upper('Char_U')
openalea.core.util.to_camel_case(name)[source]#
Examples:

>>> lower_to_camel_case(camel_case_to_lower('squareRoot'))
'SquareRoot'
>>> lower_to_camel_case(camel_case_to_lower('SquareRoot'))
'SquareRoot'
>>> lower_to_camel_case(camel_case_to_lower('ComputeSQRT'))
'ComputeSqrt'
>>> lower_to_camel_case(camel_case_to_lower('SQRTCompute'))
'SqrtCompute'
openalea.core.util.warn_deprecated(old_name, new_name, date=None)[source]#
Parameters:

date – (yyyy, mm, dd) ex: (2014, 9, 25) for 2014, 25th of september

openalea.core.version module#

try:

major, minor, post = numbers[0], numbers[1], numbers[2] patch = ‘.’.join(numbers[3:])

except IndexError:

major, minor, post = ‘2’, ‘4’, ‘3’ patch = ‘0’ __version__ = ‘.’.join([major, minor, post])

openalea.core.vlab module#

doc todo

class openalea.core.vlab.VlabFile(name)[source]#

Bases: object

class openalea.core.vlab.VlabObject(directory, pkgmanager)[source]#

Bases: object

A vlab object is a directory containing a specification file, and a set of data.

build_graph()[source]#

Specify connections between nodes.

build_package()[source]#
editors = ['MAP', 'loadmap', 'savemap', 'EDIT', 'SURFACE', 'bezieredit', 'PALETTE', 'palette', 'MEDIT', 'medit', 'GALLERY', 'gallery', 'EDIT', 'funcedit', 'panel', 'CHAR']#
get_package()[source]#
ignore = [';', '#']#
name2program = {'CHAR': 'edit', 'EDIT': 'edit', 'GALLERY': 'gallery', 'MAP': 'medit', 'MEDIT': 'medit', 'PALETTE': 'palette', 'SURFACE': 'bezieredit', 'loadmap': 'palette'}#
pkgname()[source]#
process_command(name, cmd)[source]#
process_editor(name, command)[source]#

Find the file on which the editor works on.

process_files()[source]#
process_program(name, command)[source]#

Build a process node from the command.

process_text(name, command)[source]#
programs = ['cpfg', 'lpfg']#
read_commands(f)[source]#
read_files(f)[source]#
read_specification()[source]#
text = ['TEXT', 'HINTS']#
class openalea.core.vlab.VlabObject2(*args, **kwds)[source]#

Bases: VlabObject

build_graph()[source]#

Specify connections between nodes.

process_editor(name, command)[source]#

Find the file on which the editor works on.

process_files()[source]#
process_text(name, command)[source]#
read_files(f)[source]#
openalea.core.vlab.compute_layout(sg, vid, x, dx, y, dy)[source]#
openalea.core.vlab.layout(obj)[source]#
openalea.core.vlab.random_layout(obj)[source]#
openalea.core.vlab.search(file, filenames)[source]#

Returns the filenames that are referenced in a file.

openalea.core.vlab.test1(directory)[source]#
openalea.core.vlab.vlab_object(directory, pkgmanager)[source]#

Create an openalea package from a vlab object. First, read the specification file and parse it. Create the list of data, the list of editors, and the list of programs. Build the graph of dependencies. Compute the layout of the graph. Create a package with data and a composite node.

Module contents#

openalea.core.global_module(module)[source]#

Declare a module accessible everywhere.