Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/fastavro/io/symbols.py: 75%
68 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:10 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:10 +0000
1class _NoDefault:
2 pass
5NO_DEFAULT = _NoDefault()
8class Symbol:
9 def __init__(self, production=None, default=NO_DEFAULT):
10 self.production = production
11 self.default = default
13 def get_default(self):
14 if self.default == NO_DEFAULT:
15 raise ValueError("no value and no default")
16 else:
17 return self.default
19 def __eq__(self, other):
20 return self.__class__ == other.__class__
22 def __ne__(self, other):
23 return not self.__eq__(other)
26class Root(Symbol):
27 pass
30class Terminal(Symbol):
31 pass
34Null = type("Null", (Terminal,), {})
35Boolean = type("Boolean", (Terminal,), {})
36String = type("String", (Terminal,), {})
37Bytes = type("Bytes", (Terminal,), {})
38Int = type("Int", (Terminal,), {})
39Long = type("Long", (Terminal,), {})
40Float = type("Float", (Terminal,), {})
41Double = type("Double", (Terminal,), {})
42Fixed = type("Fixed", (Terminal,), {})
44Union = type("Union", (Terminal,), {})
46MapEnd = type("MapEnd", (Terminal,), {})
47MapStart = type("MapStart", (Terminal,), {})
48MapKeyMarker = type("MapKeyMarker", (Terminal,), {})
49ItemEnd = type("ItemEnd", (Terminal,), {})
51ArrayEnd = type("ArrayEnd", (Terminal,), {})
52ArrayStart = type("ArrayStart", (Terminal,), {})
54Enum = type("Enum", (Terminal,), {})
57class Sequence(Symbol):
58 def __init__(self, *symbols, default=NO_DEFAULT):
59 super().__init__(list(symbols), default)
62class Repeater(Symbol):
63 """Arrays"""
65 def __init__(self, end, *symbols, default=NO_DEFAULT):
66 super().__init__(list(symbols), default)
67 self.production.insert(0, self)
68 self.end = end
71class Alternative(Symbol):
72 """Unions"""
74 def __init__(self, symbols, labels, default=NO_DEFAULT):
75 super().__init__(symbols, default)
76 self.labels = labels
78 def get_symbol(self, index):
79 return self.production[index]
81 def get_label(self, index):
82 return self.labels[index]
85class Action(Symbol):
86 pass
89class EnumLabels(Action):
90 def __init__(self, labels):
91 self.labels = labels
94class UnionEnd(Action):
95 pass
98class RecordStart(Action):
99 pass
102class RecordEnd(Action):
103 pass
106class FieldStart(Action):
107 def __init__(self, field_name):
108 self.field_name = field_name
111class FieldEnd(Action):
112 pass