anise.framework package

Submodules

anise.framework.engine module

The anise engine initializes all the anise plattform stuff and executes a task from a project file.

anise.framework.engine.HOOK_AFTER_PREPARATION = <anise.framework.features.Hook object>

Hook triggered after the project description file is applied to the universe object.

anise.framework.engine.HOOK_SHUTDOWN = <anise.framework.features.Hook object>

Hook triggered in the end of the execution.

anise.framework.engine.HOOK_TASK_RESULT_AVAILABLE = <anise.framework.features.Hook object>

Hook triggered when the task result is available.

class anise.framework.engine.SpecialPaths(projectfile, projectdir)

Bases: object

A data structure of some particular special paths.

Parameters
  • projectfile (str) – The path to the anise project description file. Their name is usually _projectdesc.

  • projectdir (str) – The path to the project root directory.

anise.framework.engine._cmdline(args)

Parses the command line.

Parameters

args (List[str]) –

Return type

Any

anise.framework.engine._parsevalue(sl)

Parses a command line universe object value assignment like s:name=foo.

Returns

A tuple of type,name,value

Parameters

sl (str) –

Return type

Tuple[Optional[str], Optional[str], Optional[str]]

anise.framework.engine.execute(taskname, projectfile, projectdir, values, loadfeaturesfrom)

Executes a task.

Parameters
  • taskname (str) – The name of the task to be executed.

  • projectfile (str) – The path to the anise project description file. Their name is usually _projectdesc.

  • projectdir (str) – The path to the project root directory.

  • values (Dict[str, Any]) – Additional values to be set to the universe object.

  • loadfeaturesfrom (List[str]) – List of paths where anise features shall be loaded from.

Return type

Any

anise.framework.engine.main()

The main method when called from command line. Parses command line arguments and executes the chosen task.

Return type

None

anise.framework.exceptions module

Exception subclasses.

exception anise.framework.exceptions.AniseError

Bases: Exception

An error in the execution of Anise.

exception anise.framework.exceptions.BadCommunicationError

Bases: anise.framework.exceptions.AniseError

The communication with some other component failed.

exception anise.framework.exceptions.BadFormatError

Bases: anise.framework.exceptions.AniseError

Some input is wrongly formatted.

exception anise.framework.exceptions.BadInputError

Bases: anise.framework.exceptions.AniseError

A bad value was given as some input.

exception anise.framework.exceptions.ImplementationError

Bases: anise.framework.exceptions.AniseError

A software error in an implementation occurred.

exception anise.framework.exceptions.InternalError

Bases: anise.framework.exceptions.ImplementationError

An internal error in the anise code occurred.

exception anise.framework.exceptions.NotImplementedError

Bases: anise.framework.exceptions.InternalError

Some unimplemented functionality was called.

exception anise.framework.exceptions.ProcessExecutionFailedError(text, output=None)

Bases: anise.framework.exceptions.AniseError

The execution of an external process failed.

Parameters
  • text (str) –

  • output (str) –

exception anise.framework.exceptions.RequirementsMissingError

Bases: anise.framework.exceptions.AniseError

Something required is not in place.

exception anise.framework.exceptions.UnexpectedSituationError

Bases: anise.framework.exceptions.AniseError

An unexpected situation led to an error.

anise.framework.features module

The Anise plug-in system.

This package does not include the Anise high-level features itself. You would find them in anise.features. This package is the part of the Anise infrastructure that loads and manages those features.

For each Anise run, it automatically loads the built-in anise.features as well as custom features from ~/.anise/features and /var/lib/anise/features. Due to their locations, the latter ones are useful for per-machine and per-user customization.

In an arbitrary Anise execution context, you may call anise.framework.features.loadfeature() in order to access functionality from other features, like here:

from anise.framework import features
_somefeature = features.loadfeature("somefeature").featuremodule
_somefeature.some_method()
x = _somefeature.some_variable
class anise.framework.features.Feature(name, hookhandlers, featuremodule, hooks)

Bases: object

A feature is some encapsuled part of anise high-level functionality. This class represents a loaded feature at runtime. The framework as well as other features access this object for interacting with that feature. Direct usage of high-level features from within _projectdesc is intended to not use this Feature objects but to use the embedded properties of the universe object.

Parameters
  • name (str) – The optional name of the feature.

  • hookhandlers (List[Any]) – All hook handlers this feature registers globally (it may do that later on in a function as well).

  • featuremodule (Any) – The feature module.

  • hooks (Dict[str, anise.framework.features.Hook]) – List of Hook instances.

anise.framework.features.HOOK_BEFORE_DEFINITION = <anise.framework.features.Hook object>

This hook gets executed by the Anise engine right before the _projectdesc file is loaded.

anise.framework.features.HOOK_BEFORE_EXECUTION = <anise.framework.features.Hook object>

This hook gets executed by the Anise engine after the _projectdesc file is loaded and right before the chosen task itself is called. At this time all the assignments and global statements in the _projectdesc are already applied.

class anise.framework.features.Hook(hookkind='FUNCTION', *, hide=False, interesting=5, doc=None, wizard_functionparams=None, wizard_functionadditionallog=None, wizard_functionbody=None, wizard_classbase=None, wizard_classbody=None, wizard_loadfeatures=None)

Bases: object

A hook. See documentation for details.

Parameters
  • hookkind (str) – A hook kind (one of HookKind).

  • hide (bool) – If this hook is to be hidden in hook choosers.

  • interesting (int) – A number that controls how interesting this hook is in a chooser.

  • doc (Optional[str]) – Hook documentation text.

  • wizard_functionparams (Optional[List[str]]) – Info for hook handler wizards. List of function parameters.

  • wizard_functionadditionallog (Optional[List[str]]) – Info for hook handler wizards. List of additional variable to log out in a function.

  • wizard_functionbody (Optional[str]) – Info for hook handler wizards. Additional function body part.

  • wizard_classbase (Optional[str]) – Info for hook handler wizards. Base class.

  • wizard_classbody (Optional[str]) – Info for hook handler wizards. Additional class body part.

  • wizard_loadfeatures (Optional[List[str]]) – Info for hook handler wizards. Additional features to load.

class anise.framework.features.HookHandler(hookobj, function, provides, requires, prepares)

Bases: object

A hook handler bound to some hook. See documentation for details.

Parameters
  • hookobj (anise.framework.features.Hook) – The hook.

  • function (Callable) – The handler function/class.

  • provides (Optional[Union[str, List[str]]]) – A list of symbol names this hook participates to provide (dependency provider).

  • requires (Optional[Union[str, List[str]]]) – A list of symbol names this hook requires to be executed before.

  • prepares (Optional[Union[str, List[str]]]) – A list of symbol names this hook must prepend.

property function

The handler function/class.

Return type

Callable

Return type

Callable

Return type

Callable

property hookobj

The hook.

Return type

Hook

Return type

Hook

Return type

Hook

property prepares

The symbol names this hook must prepend.

Return type

List[str]

Return type

List[str]

Return type

List[str]

property provides

The symbol names this hook participates to provide (dependency provider).

Return type

List[str]

Return type

List[str]

Return type

List[str]

property requires

The symbol names this hook requires to be executed before.

Return type

List[str]

Return type

List[str]

Return type

List[str]

class anise.framework.features.HookKind

Bases: object

Enumeration of hook kinds.

CLASS = 'CLASS'

A class kind hook.

FUNCTION = 'FUNCTION'

A function kind hook.

class anise.framework.features.Internals

Bases: object

Internal stuff.

static inject_defaults_to_universe(u)

Adds feature data structures to the universe object.

Parameters

u (projects.Universe) –

Return type

None

static inject_hooks_to_universe(u)

Adds hooks to the universe object, which are loaded in feature loading.

Parameters

u (projects.Universe) –

Return type

None

static loadfeatures(featurespath)

Loads features from a path.

Parameters

featurespath (str) –

Return type

None

static resetfeatures()

Resets the features.

Return type

None

class anise.framework.features.PseudoFeature

Bases: object

This is an auxiliary class, which fixes the gap that appears, e.g. if a feature foo.bar exists, but no foo one.

anise.framework.features.getfeatures()

Returns a list of all features.

Return type

List[anise.framework.features.Feature]

anise.framework.features.hookhandler(hookobj, *, provides=None, requires=None, prepares=None)

Used by a feature module to register a handler for a hook globally. The result should be used as Python function decorator.

Parameters
  • hookobj (anise.framework.features.Hook) – The hook.

  • provides (Optional[Union[str, List[str]]]) – A list of symbol names this hook participates to provide (dependency provider).

  • requires (Optional[Union[str, List[str]]]) – A list of symbol names this hook requires to be executed before.

  • prepares (Optional[Union[str, List[str]]]) – A list of symbol names this hook must prepend.

Return type

Callable

anise.framework.features.loadfeature(name)

Load a feature by name from the predefined sources (as optional command-line argument). If if is already loaded, it returns the existing one.

Parameters

name (str) –

Return type

anise.framework.features.Feature

anise.framework.files module

File structures, used for data exchange between methods or as result.

class anise.framework.files.AbstractRebuildDirectoriesFilestructure

Bases: anise.framework.files.TaskExecution

Abstract base class for merging directory structures together.

See the subclasses.

Parameters

task – The task implementation for execution.

__getmerged()
Return type

anise.framework.files.Filestructure

getdests()

Returns a list of transfer destinations.

Returns

A list of tuples, each beginning with the destination path (and other custom ones).

Return type

List[Tuple[str, anise.framework.files.Filestructure]]

getsource(desttuple)

Returns the transfer source for a destination tuple (as it was part of getdests()’ result).

Parameters

desttuple (Tuple[str, anise.framework.files.Filestructure]) –

Return type

anise.framework.files.Filestructure

class anise.framework.files.ExcludeByName(source, names)

Bases: anise.framework.files.TempDir

Excludes some files/directories in a directory by name.

Parameters
_initialize()

The internal initialization routine, which fetches dynamic content (if any). Called from outside before actual accesses occur. Override this method in custom subclasses or leave the default implementation.

class anise.framework.files.Filestructure(path, relative=False)

Bases: object

This class represents a file or a directory structure with many subdirectories and files. There are methods for writing those items to disk and/or to modify the original structure in the filesystem.

It is more powerful for file exchange than working just with file paths, because a file structure can also carry arbitrary metadata information and allows dynamic content creation (see e.g. TaskExecution).

Instances of this class (and its subclasses) are used by many features for file exchange.

Parameters
  • path (Optional[str]) – Path to the file or directory.

  • relative (bool) – If path is relative to the project directory.

_initialize()

The internal initialization routine, which fetches dynamic content (if any). Called from outside before actual accesses occur. Override this method in custom subclasses or leave the default implementation.

Return type

None

property data

The file structure metadata.

Return type

Dict[str, Any]

Return type

Dict[str, Any]

Return type

Dict[str, Any]

datakeys()

Returns a list of keys for all stored metadata properties.

Return type

List[str]

dl(to=None, *, subpath='', progresscallback=None)

Copies the complete filestructure or a subdirectory to a new destination.

Parameters
  • to (Optional[str]) – If given, it specifies the destination path; if not given, a new directory in the current working directory will be used.

  • subpath (str) – If given, only this subdirectory will be copied.

  • progresscallback (Optional[Callable[[int, int], None]]) – Callback function for retrieving progress information.

Returns

The destination path.

Return type

str

getdata(k, deflt)

Gets a metadata property.

Parameters
  • k (str) – The key name.

  • deflt (Optional[Any]) – The default value (returned if the key does not exist).

Return type

Optional[Any]

initialize()

Initializes this Filestructure. When this is called, the dynamic content (if any) is created and written to disc. It is automatically called for typical usage and is not required to be called manually.

Return type

None

mv(newname)

Moves the file structure to a new path. Returns a new file structure resulting in a movement from the old one, but also updates this one internally.

Parameters

newname (str) – The new name (absolute or relative).

Return type

anise.framework.files.Filestructure

property path

The path to this file structure in the filesystem.

Return type

str

Return type

str

Return type

str

setautoopen(path, interminal=False)

Places a hint that requests the Anise engine to automatically open a file within this structure when it is returned to the user.

Parameters
  • path (str) – The relative path to the file that should automatically be opened.

  • interminal (bool) – If this hint is for terminal (non-graphical) usage.

Return type

None

setdata(k, v)

Sets a metadata property.

Parameters
  • k (str) – The key name.

  • v (Optional[Any]) – The value.

Return type

None

with_modified_rootname(newname)

Returns a (temporary) file structure clone with a new directory name.

Parameters

newname (str) – The name that the new root directory should get.

Return type

anise.framework.files.Filestructure

class anise.framework.files.MergedFilestructure(fromlist=None, frommap=None)

Bases: anise.framework.files.AbstractRebuildDirectoriesFilestructure

Merges many file structures together in one tree.

Parameters
getdests()

Returns a list of transfer destinations.

Returns

A list of tuples, each beginning with the destination path (and other custom ones).

getsource(desttuple)

Returns the transfer source for a destination tuple (as it was part of getdests()’ result).

class anise.framework.files.RemappedFilestructure(source, frommap=None)

Bases: anise.framework.files.AbstractRebuildDirectoriesFilestructure

Remaps a file structure’s inner directory hierarchy into a new tree.

Parameters
  • source (anise.framework.files.Filestructure) – The source file structure.

  • frommap (Optional[Union[Dict[str, str], List[Tuple[str, str]]]]) – A dict of string/filestructure. Values are relative source paths with the dict key specifying a target subpath.

getdests()

Returns a list of transfer destinations.

Returns

A list of tuples, each beginning with the destination path (and other custom ones).

getsource(desttuple)

Returns the transfer source for a destination tuple (as it was part of getdests()’ result).

class anise.framework.files.TaskExecution(task, **kwargs)

Bases: anise.framework.files.Filestructure

Holds a function and some parameters for calling later on (like a delegate; or a more explicit, specialized and ‘xml-compatible’ version of a lambda) in order to get a file structure as function result. It acts as a proxy on top of this file structure.

Parameters

task (Callable) – The task implementation for execution.

_initialize()

The internal initialization routine, which fetches dynamic content (if any). Called from outside before actual accesses occur. Override this method in custom subclasses or leave the default implementation.

class anise.framework.files.TempDir(dirname=None, temprootpath=None, namepattern='anise.{pid}.{i}')

Bases: anise.framework.files.Filestructure

A special file structure that automatically creates a temporary directory in background.

Example:

def sometask():
    mytmp = files.TempDir()
    with open(mytmp.path + "/somefile", "w") as f:
        f.write("some content for our new file")
    return mytmp
Parameters
  • dirname (Optional[str]) – An optional name that the root directory should get; if not given, it gets an random name.

  • temprootpath (Optional[str]) – An optional alternate temp root directory path.

  • namepattern (str) – The directory name pattern.

__cleanup()

Deletes the original temp dir from the hard drive.

Return type

None

mv(*a, **b)

Moves the file structure to a new path. Returns a new file structure resulting in a movement from the old one, but also updates this one internally.

Parameters

newname – The new name (absolute or relative).

class anise.framework.files.TextFileByContent(content)

Bases: anise.framework.files.Filestructure

Holds a function and some parameters for calling later on (like a delegate; or a more explicit, specialized and ‘xml-compatible’ version of a lambda) in order to get a file structure as function result. It acts as a proxy on top of this file structure.

Parameters

content (str) – The text content for the file.

anise.framework.globalvars module

Global variables that control some global aspects of anise behavior. They are potentially influenced by command line.

anise.framework.imports module

Imports some modules for availability within _projectdesc.

Used internally.

anise.framework.projectinformations module

anise.framework.projects module

Implementation for the Anise universe object and some services around it.

class anise.framework.projects.IntermediateStructure(entries=None)

Bases: object

A data structure that holds an in-memory representation of the project description. It is not the in-memory representation of the live universe object state. It is like the file structure of the project description file, but not exactly the same. There is a parser and a generator for translating between a project description file and an IntermediateStructure.

Parameters

entries (Optional[List[IntermediateStructure.Node]]) – The new list of direct subitems.

Return type

None

class Let(k, **args)

Bases: anise.framework.projects.IntermediateStructure.Node

A Let entry in the project description structure. This corresponds to a let node in the xml format. It represents the execution of a parameterized part of anise feature program logic.

:param k The full qualified method name.

Parameters

k (str) –

class Node(k, **args)

Bases: object

A node in the intermediate structure.

Parameters

k (str) – The node key.

args()

Returns the list of stored argument keys.

Return type

List[str]

clearargs()

Clears the list of arguments.

Return type

None

getarg(key)

Returns an argument.

Parameters

key (str) – The argument key.

Return type

anise.framework.projects.IntermediateStructure.Value

property isvalue

If this is a value node. See also IntermediateStructure.Value.

Return type

bool

Return type

bool

Return type

bool

property key

The key name.

Return type

str

Return type

str

Return type

str

property parent

The parent node.

The root node returns its IntermediateStructure.

Return type

Union[‘IntermediateStructure.Node’, ‘IntermediateStructure’]

Return type

Union[‘IntermediateStructure.Node’, ‘IntermediateStructure’]

Return type

Union[‘IntermediateStructure.Node’, ‘IntermediateStructure’]

remove()

Removes this node.

Return type

None

removearg(key)

Removes an argument.

Parameters

key (str) – The argument key.

Return type

anise.framework.projects.IntermediateStructure.Value

setarg(key, node)

Sets an argument.

Parameters
Return type

None

exception ParseProjectDescriptionError

Bases: anise.framework.exceptions.BadFormatError

Parsing error like bad input xml.

exception ParseProjectDescriptionInternalError

Bases: anise.framework.exceptions.InternalError

Parsing error that seems like a bug.

class Value(t, *, k=None, v=None, oref=None, **args)

Bases: anise.framework.projects.IntermediateStructure.Node

A Value entry in the project description structure. This corresponds to a val node in the xml format. It represents an arbitrary value (primitive or composed type).

:param t The value type. :param k The key (i.e. property name in parent object). :param v (optional) The value string for a primitive value. :param oref (optional) The oref string for a objectref value.

Parameters
  • t (str) –

  • k (Optional[str]) –

  • v (Optional[str]) –

  • oref (Optional[str]) –

_realign_listvalues()

Makes internal list realignment tasks.

This is required to call after the list structure changes.

Return type

None

appendarg(node)

Appends a new value node to a list node.

Parameters

node (anise.framework.projects.IntermediateStructure.Value) –

Return type

None

static frombool(val, key=None)

Convenience method that creates a boolean Value.

Parameters
  • val (Any) –

  • key (Optional[str]) –

Return type

anise.framework.projects.IntermediateStructure.Value

static fromstring(val, key=None)

Convenience method that creates a string Value.

Parameters
  • val (Any) –

  • key (Optional[str]) –

Return type

anise.framework.projects.IntermediateStructure.Value

getprimitiverepr()

Returns a string representation of the value, if it is a primitive one (None otherwise).

Return type

Optional[str]

static istrue(s)

Returns True iff the given string can represent a boolean True value.

Parameters

s (str) –

Return type

bool

property isvalue

If this is a value node. See also IntermediateStructure.Value.

Return type

bool

Return type

bool

Return type

bool

property oref

The objectref (for oref values).

Return type

str

This property is also settable.

Return type

str

This property is also settable.

Return type

str

This property is also settable.

property value

The value (for primitive values).

Return type

str

This property is also settable.

Return type

str

This property is also settable.

Return type

str

This property is also settable.

property vtype

The value type name.

Return type

str

This property is also settable.

Return type

str

This property is also settable.

Return type

str

This property is also settable.

static _fromxml_let(xentry)

Creates a let node from an xml node.

Parameters

xentry (xml.etree.ElementTree.Element) –

Return type

anise.framework.projects.IntermediateStructure.Let

static _fromxml_val(xentry)

Creates a value node from an xml node.

Parameters

xentry (xml.etree.ElementTree.Element) –

Return type

anise.framework.projects.IntermediateStructure.Value

static _fromxml_val_isdict(xentry, withoutkeys=False)

Checks if a particular xml node represents a value dict.

Parameters
  • xentry (xml.etree.ElementTree.Element) –

  • withoutkeys (bool) –

Return type

bool

static _fromxml_val_islist(xentry)

Checks if a particular xml node represents a value list.

Parameters

xentry (xml.etree.ElementTree.Element) –

Return type

bool

static _fromxml_val_isstring(xentry)

Checks if a particular xml node represents a string.

Parameters

xentry (xml.etree.ElementTree.Element) –

Return type

bool

static _inject_to_universe_let(entry, g, l)

Executes the let action from a let node.

Parameters
Return type

None

static _inject_to_universe_resolve(oref, g, l)

Returns the resolved object for an objectref string.

Parameters
  • oref (str) –

  • g (Dict[str, Optional[Any]]) –

  • l (Dict[str, Optional[Any]]) –

Return type

Optional[Any]

static _inject_to_universe_value(entry, g, l)

Returns a plain Python value from a value node.

Parameters
Return type

Optional[Any]

static _toxml_let(entry)

Converts a let node to an xml node.

Parameters

entry (anise.framework.projects.IntermediateStructure.Let) –

Return type

xml.etree.ElementTree.Element

static _toxml_val(entry, xcurr)

Converts a value node to an xml node.

Parameters

entry (anise.framework.projects.IntermediateStructure.Value) –

Return type

xml.etree.ElementTree.Element

addentry(node)

Adds a new entry to the list of direct subentries.

Parameters

node (anise.framework.projects.IntermediateStructure.Node) – The new node.

Return type

None

entries()

Returns the list of direct subitems.

Return type

List[anise.framework.projects.IntermediateStructure.Node]

find(key, lets=False, vals=False)

Find all :samp:`let`s and/or :samp:`val`s with a certain key.

Parameters
  • key (str) –

  • lets (bool) –

  • vals (bool) –

Return type

List[anise.framework.projects.IntermediateStructure.Node]

static fromfile(filename)

Generates an IntermediateStructure for an xml file.

Parameters

filename (str) – Path to the project description file.

Return type

anise.framework.projects.IntermediateStructure

static fromxml(xmlstring, sourcefilepath=None)

Generates an IntermediateStructure for an xml document.

Parameters
  • xmlstring (str) – XML content.

  • sourcefilepath (Optional[str]) – Path to the source file, e.g. used for save().

Return type

anise.framework.projects.IntermediateStructure

inject_to_universe(u, g, l)

Injects the (always static) information from this project description into a living universe object (typically for executing a task on top of it).

Parameters
  • u (anise.framework.projects.Universe) – The universe object.

  • g (Dict[str, Optional[Any]]) – The globals dict.

  • l (Dict[str, Optional[Any]]) – The locals dict.

Return type

None

removeentry(node)

Removes an entry from the list of direct subentries.

Parameters

node (anise.framework.projects.IntermediateStructure.Node) – The child node to remove.

Return type

None

removeentryat(i)

Removes an entry from the list of direct subentries.

Parameters

i (int) – The entry position to remove.

Returns

The deleted node.

Return type

anise.framework.projects.IntermediateStructure.Node

static resolveobjectref(oref)

Returns the resolved object for an objectref string.

Parameters

oref (str) – The objectref string (e.g. 'homepage.makehomepage' or 'some.foo.Class().meth()+1').

Return type

Optional[Any]

save()

Saves the current state of this intermediate structure back to the disk.

This typically works only for instances that were loaded from disk.

Return type

None

setentries(entries)

Sets the list of direct subentries.

Parameters

entries (List[IntermediateStructure.Node]) – The new list of nodes.

Return type

None

tofile(filename)

Saves the current state of this intermediate structure to a file.

Parameters

filename (str) – The destination path.

Return type

None

toxml()

Generates an xml representation for this intermediate structure.

Return type

str

class anise.framework.projects.Universe(d, executionscope=None)

Bases: object

Implementation for universe objects.

Parameters
class RegisteredTask(parentname, taskname, label, important, invisible, sortindex, function)

Bases: object

A task that is registered to the universe object. You typically do not need to work with this structure directly. Use Universe.addtask() to add new tasks.

Parameters
  • parentname (str) –

  • taskname (str) –

  • label (Optional[str]) –

  • important (bool) –

  • invisible (bool) –

  • sortindex (int) –

  • function (Callable) –

addhook(hookobj, fct, params=None, provides=None, requires=None, prepares=None)

Adds a handler for a hook to the universe object.

Parameters
  • hookobj (anise.framework.features.Hook) –

  • fct (Callable) –

  • params (Optional[Dict[str, Optional[Any]]]) –

  • provides (Optional[Union[str, List[str]]]) –

  • requires (Optional[Union[str, List[str]]]) –

  • prepares (Optional[Union[str, List[str]]]) –

Return type

anise.framework.features.HookHandler

addtask(function, name='', *, label=None, important=True, invisible=False, sortindex=0)

Registers a task and makes it available for execution.

Parameters
  • function (Callable) – The function that implements the task.

  • name (str) – The task name.

  • label (Optional[str]) – The task label text.

  • important (bool) – If this is an important/interesting task (presented differently in choosers).

  • invisible (bool) – If this task should be hidden in choosers.

  • sortindex (int) – A number that controls the display order of tasks in choosers.

Return type

None

append(d)

Stores a dictionary of values as properties of this universe object.

Parameters

d (Dict[str, Optional[Any]]) –

Return type

None

gethooks(hookobj)

Gets the handlers for a hook in the correct order.

Parameters

hookobj (anise.framework.features.Hook) – The hook you want to get handlers for.

Return type

List[Callable]

getvalue(key, defaultvalue=None)

Returns the value of a certain property for the current universe object.

If this property does not exist, it returns the defaultval. Beyond that, getvalue("foo.bar") is similar to universe.foo.bar.

Parameters
  • key (str) – The key name of the property to get.

  • defaultvalue (Optional[Any]) – This value is returned if the specified property does not exist.

Return type

Optional[Any]

registeredtasks()

Returns a list of all registered tasks.

Return type

List[anise.framework.projects.Universe.RegisteredTask]

removehook(hookhandler)

Removes a hook that was added before.

Parameters

hookhandler (anise.framework.features.HookHandler) – The HookHandler you got in addhook().

Return type

None

setvalue(key, value)

Sets the value of a certain property for the current universe object.

If a parent property does not exist, it does nothing. setvalue("foo.bar", "baz") is similar to universe.foo.bar = "baz".

Parameters
  • key (str) – The key name of the property to set.

  • value (Optional[Any]) – The new value for the specified property.

Returns

If successful.

Return type

bool

class anise.framework.projects._UniverseProxy

Bases: object

Internally used for the universe object for allowing just to write universe instead of universe().

anise.framework.projects.currentuniverse()

Returns the current universe object.

Return type

Optional[anise.framework.projects.Universe]

anise.framework.projects.getvalue(key, defaultvalue=None)

A convenience method returning the value of a certain property for the current universe object.

Parameters
  • key (str) – The key name of the property to get.

  • defaultvalue (Optional[Any]) – This value is returned if the specified property does not exist.

Return type

Optional[Any]

anise.framework.projects.setcurrentuniverse(u)

Sets the current universe object. If another one is currently set, it becomes active again when u is unset. This is part of a particular piece of internal infrastructure and is typically not required to be used directly.

Parameters

u (anise.framework.projects.Universe) –

Return type

None

anise.framework.projects.setvalue(key, value)

A convenience method setting the value of a certain property for the current universe object.

Parameters
  • key (str) – The key name of the property to set.

  • value (Optional[Any]) – The new value for the specified property.

Returns

If successful.

Return type

bool

anise.framework.projects.universe = <anise.framework.projects._UniverseProxy object>

The universe object. See Universe.

anise.framework.projects.unsetcurrentuniverse()

Unsets the current universe object. This is part of a particular piece of internal infrastructure and is typically not required to be used directly.

Return type

None

anise.framework.report module

The Anise report facility keeps track of the steps of the execution process, the progresses and all output messages.

class anise.framework.report.AniseOutputStream(originalstream)

Bases: object

Proxy for terminal output/error channel, so we can record output messages.

Parameters

originalstream (TextIO) –

write(b)
class anise.framework.report.ExecutionScope(title)

Bases: anise.framework.report.ExecutionScopePart

An execution scope is one piece of work to do in a complete task executions.

It is the parent of another execution scope (just the root scope does not have a parent) and can have child scopes. This leads to a tree structure of scope nodes. Each node can have metadata infos like a title or a progress. Those are displayed during the execution of a task (together with other ExecutionScopePart subclasses’ instances).

Parameters

title (str) – The scope title text.

class Progress

Bases: object

Progress info for an execution scope.

tojson()

Returns a simple object structure for json transfers.

Return type

Dict[str, Optional[Any]]

class ProgressDeterminate(value)

Bases: anise.framework.report.ExecutionScope.Progress

Progress info for a determinate progress.

Parameters

value (float) – The progress between 0.0 and 1.0.

class ProgressDoneWithUnknownSuccess

Bases: anise.framework.report.ExecutionScope.Progress

Progress info for an execution that is terminated but without explicit success information.

class ProgressFailed

Bases: anise.framework.report.ExecutionScope.Progress

Progress info for a failed execution.

class ProgressFinished

Bases: anise.framework.report.ExecutionScope.Progress

Progress info for a finished execution.

class ProgressIndeterminate

Bases: anise.framework.report.ExecutionScope.Progress

Progress info for an indeterminate progress.

appendchild(child)

Appends a child scope to this scope.

Parameters

child (anise.framework.report.ExecutionScopePart) –

Return type

None

newsubscope(title)

Adds a new sub scope to the current top scope.

Parameters

title (str) – The scope title text.

Return type

anise.framework.report.ExecutionScopePart

property progress

The current progress state of this scope.

Return type

Progress

This property is also settable.

Return type

Progress

This property is also settable.

Return type

Progress

This property is also settable.

property rawsubparts

List of all direct subparts of this scope.

Return type

List[‘ExecutionScopePart’]

Return type

List[‘ExecutionScopePart’]

Return type

List[‘ExecutionScopePart’]

property title

The title string of this scope.

Return type

str

Return type

str

Return type

str

class anise.framework.report.ExecutionScopePart(value, hints=None)

Bases: object

Base class of ExecutionScope (read there for more). It also includes logging output or output from external programs, which are displayed together with real execution scopes during task execution.

Parameters
  • value (str) – The content value.

  • hints (Optional[List[str]]) – A list of hint symbols (typically used for log message severity).

property address

The address of this part.

Return type

Tuple

Return type

Tuple

Return type

Tuple

getscopepartsbyidrange(minid=None, maxid=None)

Gets a list of execution scope parts by a range of IDs.

Parameters
  • minid (Optional[int]) –

  • maxid (Optional[int]) –

Return type

List[anise.framework.report.ExecutionScopePart]

property hints

The content hint.

This is typically used for storing the severity of log messages, so the presentation can differ.

Return type

List[str]

Return type

List[str]

Return type

List[str]

property id

The ID of this part.

Return type

int

Return type

int

Return type

int

property value

The content value of this execution scope.

Return type

str

Return type

str

Return type

str

class anise.framework.report.RootExecutionScope

Bases: anise.framework.report.ExecutionScope

The root execution scope.

Parameters

title – The scope title text.

anise.framework.report._logmessage(text, severity, terminalonly, tofile, textescaper)

A message logger implementation that also records the logging output to the report.

Parameters
  • text (str) – The text to log.

  • severity (int) – The severity. One of anise.utils.logging.Severity.

  • terminalonly (bool) – If to log only to terminal/file.

  • tofile (TextIO) – Log to this file instead of terminal.

  • textescaper (Callable[[str], str]) – A function that escapes text in a custom way before logging.

Return type

None

anise.framework.report.install_proxies()

Installs stdout/stderr proxies, so we can record all output made.

Return type

None

anise.framework.report.topscope(i=0)

Returns a scope from the top of the stack (without removing it).

Parameters

i (int) – Which scope to return (counting from top).

Return type

anise.framework.report.ExecutionScope

Module contents

The infrastructure parts of Anise.

The infrastructure executes Python code in a _projectdesc file and makes some syntactical tricks leading to shorter (and better readable) files. This tricks include the direct access to the universe object and the automatic imports it makes before executing _projectdesc.

In most places, the Anise infrastructure tries to be as thin a layer above Python as possible instead of reinventing the wheel again and again. Although on some places Anise actually has to do some more own stuff in order to bring some functionality.

Read about the individual infrastructure parts in the subpackages here.

The starting point is anise.framework.engine, which is the active part responsible for executing tasks.