7.1.2.15. pycropml.package module

from pycropml import composition from pycropml.pparse import model_parser from path import Path import networkx as nx from collections import defaultdict from IPython.display import Image, display from networkx.drawing.nx_pydot import to_pydot from pycropml.render_cyml import signature

class pycropml.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 pycropml.package.Package(name, metainfo, path=None)[source]

Bases: pycropml.package.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_modelunit(modelunit)[source]

Add to the package a factory ( node or subgraph )

get_crop2ml_path()[source]

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

get_id()[source]

Return the package id

get_metainfo(key)[source]

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

get_modelunit(modelid)[source]

Return the factory associated with id

get_names()[source]

Return all the factory names in a list

get_pkg_files()[source]

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

get_tip()[source]

Return the package description

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 = 'pycrop2ml/package'
reload()[source]

Reload all xml file of the package

remove_files()[source]

Remove pkg files

update_modelunit(old_name, modelunit)[source]

Update factory (change its name)

class pycropml.package.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

class pycropml.package.PackageManager[source]

Bases: object

add_crop2ml_path(path, container)[source]

Add a search path for wralea files

Parameters:
  • path – a path string
  • container – set containing the path
add_package(package)[source]

Add a package to the pkg manager

clear()[source]

Remove all packages

create_readers(crop2ml_files)[source]
find_and_register_packages(no_cache=False)[source]

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

find_crop2ml_dir(directory, recursive=True)[source]

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

:return : a list of pkgreader instances

get(*args)[source]
get_pkgreader(filename)[source]

Return the pkg reader corresponding to the filename

has_key(*args)[source]
init(dirname=None, verbose=True)[source]

Initialize package manager

If dirname is None, find composition files on the system else load directory

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

Load a directory containing wraleas

rebuild_category()[source]

Rebuild all the category

reload(pkg=None)[source]

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

set_sys_crop2ml_path()[source]

Define the default composition files search path

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

update_category(package)[source]

Update the category dictionary with package contents

values()[source]
class pycropml.package.PseudoGroup(name)[source]

Bases: pycropml.package.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 = 'pycrop2ml/package'
new(name)[source]

todo

sep = '.'
class pycropml.package.PyPackageReader(filename)[source]

Bases: pycropml.package.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 model.py

class pycropml.package.PyPackageReaderModel(filename)[source]

Bases: pycropml.package.PyPackageReader

Build a package from a __wralea__.py Use module variable

build_package(wraleamodule, pkgmanager)[source]

Build package and update pkgmanager

check_exist()[source]
contain_pkg(pkg)[source]
get_path(pkg, name)[source]
class pycropml.package.PyPackageWriter(package)[source]

Bases: object

Write a wralea python file

get_str()[source]

Return string to write

pkg_template = '\n$PKGNAME\n$METAINFO\n'
wralea_template = '\n# This file has been generated at $TIME\n$PKG_DECLARATION\n'
write_wralea(full_filename)[source]

Write the wralea.py in the specified filename

exception pycropml.package.UnknownNodeError(name)[source]

Bases: Exception

class pycropml.package.UserPackage(name, metainfo, path=None)[source]

Bases: pycropml.package.Package

Package user editable and persistent

pycropml.package.get_default_home_dir()[source]

Return the home directory (valid on linux and windows)

pycropml.package.get_openalea_home_dir(name='.pycrop2ml')[source]

Return the crop2ml home directory If it doesn’t exist, create it

pycropml.package.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

pycropml.package.is_protected(item)[source]

Return true the item is protected

pycropml.package.lower(item)[source]
pycropml.package.protected(item)[source]

Return corresponding protected name for item