OpenAlea core's API

openalea.core.package

This module defines Package classes.

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

exception openalea.core.package.FactoryExistsError[source]
exception openalea.core.package.UnknownNodeError(name)[source]
class openalea.core.package.AbstractPackageReader(filename)[source]

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]

Package for dynamical parsing of python file

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

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.

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)

mimetype = 'openalea/package'
class openalea.core.package.PyPackageReader(filename)[source]

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]

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]

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]

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

write_wralea(full_filename)[source]

Write the wralea.py in the specified filename

pkg_template = '\n$PKGNAME\n\n$METAINFO\n\n$ALL\n\n$FACTORY_DECLARATION\n'
wralea_template = '\n# This file has been generated at $TIME\n\nfrom openalea.core import *\n\n$PKG_DECLARATION\n\n'
class openalea.core.package.UserPackage(name, metainfo, path=None)[source]

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]
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.pkgmanager

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]
exception openalea.core.pkgmanager.UnknowFileType[source]
exception openalea.core.pkgmanager.UnknownPackageError(name)[source]
class openalea.core.pkgmanager.Logger[source]

OpenAlea logging class

add(msg)[source]

Write to log file

print_log()[source]

Print log file

class openalea.core.pkgmanager.PackageManager(verbose=True)[source]

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(*args)[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 Priority : presence of search_str in factory name
and position in the name (closer to the begining = higher score)
2 - Then : Number 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]

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

new(name)[source]

todo

mimetype = 'openalea/package'
sep = '.'
class openalea.core.pkgmanager.PseudoPackage(name)[source]

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

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

Comparison function

Table Of Contents

This Page