footprints

A generic multi-purpose fabric for objects with tunable footprints, i.e. some set of key/value pairs that attributes (possibly optional) could cover.

Functions

footprints.collected_classes()[source]

Return a set of all collected footprint-based classes.

footprints.collected_priorities(tag)[source]

Print a table of collected classes with a priority level higher or equal to tag.

footprints.default(**kw)[source]

Try to find in existing instances tracked by the tag collector a suitable candidate according to description.

footprints.grep(**kw)[source]

Try to find any instance in all collectors that could match given attributes.

footprints.load(**kw)[source]

Same as pickup but operates on an expanded dictionary. Return either None or an object compatible with the tag.

footprints.pickup(rd)[source]

Find in current description the attributes that are collected under the tag name.

footprints.reset_package_priority(packname, tag)[source]

Reset priority level in all collectors for the specified package.

Classes

class footprints.DecorativeFootprint(*args, **kw)[source]

Bases: Footprint

This class extends the Footprint class. In addition to the definition and processing of the footprint itself, a class decorator can be registered.

The FootprintBaseMeta will apply this decorator on the target class only when the footprint is used directly (i.e. not when inherited).

Initialisation and checking of a given set of footprint.

class footprints.Footprint(*args, **kw)[source]

Bases: object

This class defines the objects in charge of handling the footprint definition itself and the resolution mecanism through keys-values description matching.

Initialisation and checking of a given set of footprint.

allkeys()[source]

Return a set of possible keys for the footprint’s attributes.

as_copy()[source]

Returns a deep copy of the internal footprint structure as a pure dictionary. Be aware that some objects such as compiled regular expressions remain identical through this indeep copy operation.

as_dict()[source]

Returns a shallow copy of the internal footprint structure as a pure dictionary.

as_opts()[source]

Returns the list of all the possible values as attributes or aliases.

property attr

Read-only property. Direct access to internal footprint set of attributes.

property bind

Read-only property. Direct access to internal footprint binding between attributes.

checkonly(rd, report=<footprints.reporting.NullReport object>, resolvecache=None)[source]

Ensure that the resolved description also matches at least one item per only feature.

get_outcast(attrname)[source]

Return inacceptable values for a given attrname.

get_values(attrname)[source]

Return acceptable values for a given attrname.

in_values(item, values)[source]

Check that item is inside values or compares as equal to one of these values.

property info

Read-only property. Direct access to internal footprint informative description.

property level

Read-only property. Direct access to internal footprint priority level.

mandatory()[source]

Returns the list of mandatory attributes in the current footprint.

nice()[source]

Returns a nice dump version of the actual footprint.

property only

Read-only property. Direct access to internal footprint restriction rules.

optional(a)[source]

Returns whether the given attribute a is optional or not in the current footprint.

property priority

Read-only property. Direct access to internal footprint priority rules.

resolve(desc, **kw)[source]

Try to guess how the given description desc could possibly match the current footprint.

track(desc)[source]

Returns if the items of desc are found in the specified footstep fp.

class footprints.FootprintBase(*args, **kw)[source]

Bases: object

Base class for any other thematic class that would need to incorporate a Footprint. Its metaclass is FootprintBaseMeta.

SUPER()[source]

A kind of shortcut to parent class. Warning: use with care.

property footprint

Footprint associated to current object’s class.

classmethod footprint_abstract()[source]

Returns whether the current class could be instanciated or not.

classmethod footprint_access(attrname)[source]

Return the access mode of a footprint attribute.

footprint_as_dict()[source]

Returns a dictionary that contains a deepcopy of the current attributes.

footprint_as_shallow_dict()[source]

Returns a dictionary that contains the current attributes (shallow copy).

property footprint_attributes

Returns the list of current attributes.

property footprint_attributes_values

Returns the list of current attributes values.

footprint_cleanup(rd)[source]

Removes in the specified rd description the keys that are tracked as part of the footprint of the current object.

footprint_clone(full=False, extra=None)[source]

Return a deep copy of the current object as a brand new one. Only footprint attributes are carried around. Attributes to be replaced or added can be specified in dict extra.

classmethod footprint_clskind()[source]

Return a lower-case string of the name of the current footprint class.

footprint_clsname()[source]

Returns the short name of the object’s class.

classmethod footprint_clsrealkind()[source]

Return the realkind property value of the current class.

footprint_compatible(rd)[source]

Resolve a subset of a description according to my footprint, and then compare to my actual values.

classmethod footprint_couldbe(rd, report=None, mkreport=False, resolvecache=None)[source]

This is the heart of any selection purpose, particularly in relation with the find_all() mechanism of footprints.Collector classes. It returns the resolved form in which the current rd description could be recognized as a footprint of the current class, False otherwise.

footprint_delattr(attr, auth=None)[source]

Delete actual attribute. Protected method.

footprint_export()[source]

See the current footprint as a pure dictionary when exported.

footprint_getattr(attr, auth=None)[source]

Return actual attribute value in internal storage. Protected method.

footprint_has_attribute(attr)[source]

Check if the footprint contains the attr attribute

property footprint_info

Information from the current footprint.

classmethod footprint_level()[source]

Return the tag name of the priority level of the current class footprint object.

classmethod footprint_mandatory()[source]

Returns the attributes that should be present in a description in order to be able to match the current object.

classmethod footprint_optional(a)[source]

Returns whether the specified attribute a is optional or not.

classmethod footprint_pl()[source]

Return the priority level of the current class footprint object.

classmethod footprint_retrieve(**kw)[source]

Returns the internal checked footprint of the current class object.

classmethod footprint_reusable()[source]

Returns whether the current class could be used for default loading.

footprint_riseup()[source]

Things to do after new or init construction.

footprint_setattr(attr, value, auth=None)[source]

Set actual attribute to the value specified. Protected method.

footprint_undefs()[source]

Return list of attributes which are still None.

classmethod footprint_values(attrname)[source]

Return the list of authorized values of a footprint attribute (if any).

classmethod footprint_weight(realinputs)[source]

Tuple with ordered weights to make a choice possible between various electible footprints.

classmethod fullname()[source]

Returns a nicely formatted name of the current class (dump usage).

property realkind

Actual footprint kind, by default the clskind.

class footprints.FootprintBaseMeta(n, b, d)[source]

Bases: type

Meta class constructor for FootprintBase. The current _footprint data which could be a simple dict or a Footprint object is used to instantiate a new Footprint, built as a merge of the footprint of the base classes.

This meta-constructor is in charge of the footprints merging, class registering in footprint collectors and documentation setting.

Exceptions

exception footprints.FootprintException[source]

Bases: Exception

exception footprints.FootprintFatalError[source]

Bases: FootprintException

exception footprints.FootprintInvalidDefinition[source]

Bases: FootprintException

exception footprints.FootprintMaxIter[source]

Bases: FootprintException

exception footprints.FootprintUnreachableAttr[source]

Bases: FootprintException

Sub-Modules

footprints.access

Footprint descriptors for attributes access.

footprints.collectors

Handling of footprints collectors.

footprints.config

Footprint dynamic configuration.

footprints.doc

Footprint's docstring generator

footprints.loggers

This module provides a few functions on top of the standard logging module in order to easily create new loggers (including root ones) and control their verbosity level.

footprints.priorities

Footprint utilities to handle the priority footprint's attribute.

footprints.proxies

Proxy objects to footprints catalogs.

footprints.reporting

Hierarchical documents to store footprints information.

footprints.stdtypes

Special derivated builtins to be used as attributes in footprints descriptions in order to avoid automatic value expansion (for example).

footprints.util

Utility functions of the footprints package.