gavo.base.common module

Common code for DaCHS’s base package.

exception gavo.base.common.Ignore[source]

Bases: ExecutiveAction

An executive action causing an element to be not adopted by its parent.

Raise this in – typically – onElementComplete if the element just built goes somewhere else but into its parent structure (or is somehow benignly unusable). Classic use case: Active Tags.

class gavo.base.common.NotGiven[source]

Bases: object

A sentinel class for defaultless values that can remain undefined.

class gavo.base.common.NotGivenType[source]

Bases: type

class gavo.base.common.Parser(start=None, value=None, end=None)[source]

Bases: object

is an object that routes events.

It is constructed with up to three functions for handling start, value, and end events; these would override methods start_, end_, or value_. Thus, you can simply implement when inheriting from Parser. In that case, no call the the constructor is necessary (i.e., Parser works as a mixin as well).

feedEvent(ctx, type, name, value)[source]
exception gavo.base.common.Replace(newOb, newName=None)[source]

Bases: ExecutiveAction

An executive action replacing the current child with the Exception’s argument.

Use this sparingly. I’d like to get rid of it.

class gavo.base.common.StructCallbacks[source]

Bases: object

A class terminating super() calls for the structure callbacks.

Structs, when finished, call completeElement(ctx), validate(), and onElementComplete() in sequence. All these need to up-call. This mixin provides non-upcalling implementations of these methods, and it needs to be present in mixins for structure.

This will only work properly if self actually is a struct, as we rely on the presence of name_ attributes in case of prematurely terminated method resolution.

class gavo.base.common.StructParseDebugMixin[source]

Bases: object

put this before Parser in the parent class list of a struct, and you’ll see the events coming in to your parser.

feedEvent(ctx, type, name, value)[source]