bouwer package

Submodules

bouwer.action module

Bouwer action layer

This layer is responsible for executing actions. An action can be a shell command or a python function. The action layer does not know about the other layers (build and configuration).

class bouwer.action.Action(target, sources, command, tags, builder)[source]

Bases: builtins.object

Represents an executable action.

Constructor

Parameters:
  • target (str) – target file for the action
  • sources (list) – a list of source files as dependency
  • command (str) – Either a str with a shell command or a python function
  • tags (dict) – Dictionary with parameters called tags

:param Plugin builder: the builder that generated this action

class bouwer.action.ActionEvent(worker, target, event_type, result=None)[source]

Bases: builtins.object

Represents an event which occurred for an Action

Constructor

Parameters:
  • worker (str) – the name of the Worker that caused the event
  • target (str) – target of the Action for this event
  • event_type (str) – type of event
  • result (int) – exit code of the Action
CREATE = 'create'
EXECUTE = 'execute'
FINISH = 'finish'
class bouwer.action.ActionManager[source]

Bases: builtins.object

Manages all Action objects registered for execution.

Constructor

run(clean=False)[source]

Run all registered Action objects

Parameters:clean (bool) – True to remove the targets. False to execute.
submit(target, sources, command, tags, builder)[source]

Submit a new Action for execution

Parameters:
  • target (str) – target file for the action
  • sources (list) – a list of source files as dependency
  • command (str) – Either a str with a shell command or a python function
  • tags (dict) – Dictionary with parameters called tags

:param Plugin builder: the builder that generated this action

class bouwer.action.Worker(actions, work, events)[source]

Bases: multiprocessing.context.Process

Implements a consumer process for executable Action objects.

The Worker class implements a simple consumer for executing Action objects. It takes a dict of available actions and receives target names of the appropriate action to execute from the work Queue. The worker sends an ActionEvent on the events Queue before with type ActionEvent.EXECUTE and after executing an action with type ActionEvent.FINISH.

Constructor

Parameters:actions (dict) – Dictionary with Action objects

:param Queue work: Queue to receive target names to execute :param Queue events: Queue to publish events to the WorkerManager

run()[source]

Main execution loop of the Worker. Does not return.

class bouwer.action.WorkerManager(actions)[source]

Bases: builtins.object

Manages a pool of Worker processes

Constructor

Parameters:actions (dict) – Dictionary with Action objects
decide(action)[source]

Decide if this action needs to run.

:param Action action: the action to try

Returns True if the Action needs to run or False otherwise.

execute()[source]

Execute all Action objects

bouwer.builder module

bouwer.cli module

Bouwer command line interface

class bouwer.cli.CommandLine[source]

Bases: bouwer.util.Singleton

Represents the command line interface to bouwer

TODO: extend somekind of argparse class here

Constructor

VERSION = '0.1.0'
parse()[source]

Interpret all command line arguments

bouwer.config module

Bouwer configuration layer

Configuration allows the user to influence the execution of the build automation system. A user can create and modify a (set of) configuration(s) using any available configuration frontend. For example, the LineConfig plugin allows the user to change configuration items via the command line.

class bouwer.config.BouwConfigParser(conf)[source]

Bases: builtins.object

Parser for Bouwconfig files

Constructor

CHOICE_MODE = 2
CONFIG_MODE = 1
HELP_MODE = 4
KEYWORD_MODE = 3
TREE_MODE = 5
parse(filename)[source]

Parse a Bouwconfig file

class bouwer.config.Config(name, value, path=None, **keywords)[source]

Bases: builtins.object

Represents a single generic configuration item

Constructor

add_dependency(item_name)[source]

Introduce a new dependency on item_name

get_key(key, default=None)[source]

Wrapper for the dict.get function

keys()[source]

Retrieve a list of keyword keys

satisfied(tree=None)[source]

See if we are satisfied with all our dependencies in tree

If no tree is specified, the currently active tree will be searched

serialize(tree)[source]

Return serializable representation of the item

update(value)[source]

Assign a new value to the configuration item

value(tree=None)[source]

Retrieve the current value of the configuration item

class bouwer.config.ConfigBool(name, value, path=None, **keywords)[source]

Bases: bouwer.config.Config

Boolean configuration item

This type of configuration item can only be True or False.

Constructor

update(value)[source]

Update the value of this boolean item

value(tree=None)[source]

Retrieve our value, also taking dependencies into account.

class bouwer.config.ConfigFloat[source]

Bases: builtins.object

Floating point number configuration item

class bouwer.config.ConfigInt[source]

Bases: builtins.object

Integer configuration item

class bouwer.config.ConfigList(name, value, path=None, **keywords)[source]

Bases: bouwer.config.Config

List configuration item

Constructor

add(item)[source]

Add an option to the list

class bouwer.config.ConfigString(name, value, path=None, **keywords)[source]

Bases: bouwer.config.Config

String configuration item

This type of configuration item contains any string value, which must be of the basic type str. Empty strings are allowed.

Constructor

update(value)[source]

Update the value of this string item

class bouwer.config.ConfigTree(name, value, path=None, parent=None, **keywords)[source]

Bases: bouwer.config.ConfigBool

Tree configuration items can contain other configuration items

Constructor

add(item, path=None)[source]

Introduce a new Config item to the tree

get(item_name)[source]

Retrieve item in this tree with the given item_name

get_items_by_path()[source]

Return a dictionary with path as key and items as value

satisfied(tree=None)[source]

See if we are satisfied with all our dependencies in tree

If no tree is specified, the currently active tree will be searched

value(tree=None)[source]

Retrieve value of the tree. Either True or False.

class bouwer.config.ConfigTri[source]

Bases: builtins.object

Tristate configuration item

class bouwer.config.Configuration(cli=None)[source]

Bases: bouwer.util.Singleton

Represents the current configuration

Constructor

dump()[source]

Dump the current configuration to the debug log

get(item_name)[source]

Retrieve item named item_name from the active tree

load(filename='.bouwconf')[source]

Load a saved configuration from the given filename

put(item, tree_name='DEFAULT', path=None)[source]

Introduce a new Config object item

reset()[source]

Reset configuration to the initial predefined state using Bouwconfigs

save(filename='.bouwconf')[source]

Save the current configuration to filename

bouwer.core module

Bouwer core functionality

bouwer.core.execute()[source]

Execute Bouwfiles with the current configuration

bouwer.plugin module

Plugin extensions support

class bouwer.plugin.Plugin[source]

Bases: builtins.object

Bouwer plugin class

Constructor

action_event(action, event)[source]

Default ActionEvent handler

This function is called when an ActionEvent occurs for any submitted Actions. For example, when the Action begins or has finished execution.

config_action_output()[source]

Configuration items as output that need to run an Action

config_input()[source]

Configuration items as input

config_output()[source]

Configuration items as output

initialize()[source]

Initialize the plugin

class bouwer.plugin.PluginManager[source]

Bases: bouwer.util.Singleton

Manages loading plugins

Constructor

load_builders(module)[source]

Load all builders from the given module.

load_path(path)[source]

Load all plugins in the given directory path

bouwer.util module

class bouwer.util.AsciiDecoder(encoding=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=<class 'collections.OrderedDict'>)[source]

Bases: json.decoder.JSONDecoder

Translate JSON to python objects in ASCII instead of Unicode.

Class constructor.

Uses an OrderedDict to preserve the order of JSON items read from file.

convert(data)[source]

Convert unicode strings to ascii

decode(json_string)[source]

Called to decode a json string to python object.

class bouwer.util.Cache(name)[source]

Bases: builtins.object

Generic caching implementation

Class constructor

classmethod FlushAll()[source]

Flush all instances

classmethod Instance(name)[source]

Retrieve instance of a Cache

flush()[source]
get(key)[source]
instances = {}
put(key, value)[source]
timestamp()[source]
class bouwer.util.Singleton[source]

Bases: builtins.object

Singleton classes may have only one instance

classmethod Destroy()[source]

Remove a Singleton instance

classmethod Instance(*args, **kwargs)[source]

Called to lookup the Singleton instance

bouwer.util.compare_str(s1, s2)[source]

Compare strings s1 and s1. Return the number of characters that are equal.

bouwer.util.str2bool(s)[source]

Convert string to bool type.

bouwer.util.tempfile(filename)[source]

Create a temporary builder file

Module contents

Bouwer top level module