1 """
2 Common code for DaCHS's base package.
3 """
4
5
6
7
8
9
10
11 from __future__ import print_function
12
13 from gavo.utils.excs import *
14 from gavo.utils import excs
15
16
29
30
32 """A sentinel class for defaultless values that can remain undefined.
33 """
34 __metaclass__ = NotGivenType
35
36
37 -class Ignore(excs.ExecutiveAction):
38 """An executive action causing an element to be not adopted by its
39 parent.
40
41 Raise this in -- typically -- onElementComplete if the element just
42 built goes somewhere else but into its parent structure (or is
43 somehow benignly unusable). Classic use case: Active Tags.
44 """
45
46
47 -class Replace(excs.ExecutiveAction):
48 """An executive action replacing the current child with the Exception's
49 argument.
50
51 Use this sparingly. I'd like to get rid of it.
52 """
53 - def __init__(self, newOb, newName=None):
54 self.newOb, self.newName = newOb, newName
55
56
58 """is an object that routes events.
59
60 It is constructed with up to three functions for handling start,
61 value, and end events; these would override methods start_, end_,
62 or value_. Thus, you can simply implement when inheriting from
63 Parser. In that case, no call the the constructor is necessary
64 (i.e., Parser works as a mixin as well).
65 """
66 - def __init__(self, start=None, value=None, end=None):
68
79
80
82 """put this before Parser in the parent class list of a struct,
83 and you'll see the events coming in to your parser.
84 """
88