Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/fastavro/io/symbols.py: 74%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

69 statements  

1class _NoDefault: 

2 pass 

3 

4 

5NO_DEFAULT = _NoDefault() 

6 

7 

8class Symbol: 

9 def __init__(self, production=None, default=NO_DEFAULT): 

10 self.production = production 

11 self.default = default 

12 

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 

18 

19 def __eq__(self, other): 

20 return self.__class__ == other.__class__ 

21 

22 def __ne__(self, other): 

23 return not self.__eq__(other) 

24 

25 

26class Root(Symbol): 

27 pass 

28 

29 

30class Terminal(Symbol): 

31 pass 

32 

33 

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,), {}) 

43 

44Union = type("Union", (Terminal,), {}) 

45 

46MapEnd = type("MapEnd", (Terminal,), {}) 

47MapStart = type("MapStart", (Terminal,), {}) 

48MapKeyMarker = type("MapKeyMarker", (Terminal,), {}) 

49ItemEnd = type("ItemEnd", (Terminal,), {}) 

50 

51ArrayEnd = type("ArrayEnd", (Terminal,), {}) 

52ArrayStart = type("ArrayStart", (Terminal,), {}) 

53 

54Enum = type("Enum", (Terminal,), {}) 

55 

56 

57class Sequence(Symbol): 

58 def __init__(self, *symbols, default=NO_DEFAULT): 

59 super().__init__(list(symbols), default) 

60 

61 

62class Repeater(Symbol): 

63 """Arrays""" 

64 

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 

69 

70 

71class Alternative(Symbol): 

72 """Unions""" 

73 

74 def __init__(self, symbols, labels, default=NO_DEFAULT): 

75 super().__init__(symbols, default) 

76 self.labels = labels 

77 

78 def get_symbol(self, index): 

79 return self.production[index] 

80 

81 def get_label(self, index): 

82 return self.labels[index] 

83 

84 

85class Action(Symbol): 

86 pass 

87 

88 

89class EnumLabels(Action): 

90 def __init__(self, labels): 

91 self.labels = labels 

92 

93 

94class UnionEnd(Action): 

95 pass 

96 

97 

98class RecordStart(Action): 

99 pass 

100 

101 

102class RecordEnd(Action): 

103 pass 

104 

105 

106class FieldStart(Action): 

107 def __init__(self, field_name): 

108 self.field_name = field_name 

109 

110 

111class FieldEnd(Action): 

112 pass