Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"name",
candidate_schema.get("type")
)
)
else:
labels.append(candidate_schema)
return Sequence(Alternative(symbols, labels), Union())
elif record_type == "map":
repeat = Repeater(
MapEnd(),
# ItemEnd(), # TODO: Maybe need this?
self._parse(schema["values"]),
MapKeyMarker(),
String(),
)
return Sequence(repeat, MapStart())
elif record_type == "array":
repeat = Repeater(
ArrayEnd(),
ItemEnd(),
self._parse(schema["items"]),
)
return Sequence(repeat, ArrayStart())
elif record_type == "enum":
return Sequence(EnumLabels(schema["symbols"]), Enum())
elif record_type == "null":
return Null()
def write_utf8(self, value):
self._parser.advance(String())
if self._parser.stack[-1] == MapKeyMarker():
self._parser.advance(MapKeyMarker())
self.write_object_key(value)
else:
self.write_value(value)
repeat = Repeater(
ArrayEnd(),
ItemEnd(),
self._parse(schema["items"]),
)
return Sequence(repeat, ArrayStart())
elif record_type == "enum":
return Sequence(EnumLabels(schema["symbols"]), Enum())
elif record_type == "null":
return Null()
elif record_type == "boolean":
return Boolean()
elif record_type == "string":
return String()
elif record_type == "bytes":
return Bytes()
elif record_type == "int":
return Int()
elif record_type == "long":
return Long()
elif record_type == "float":
return Float()
elif record_type == "double":
return Double()
elif record_type == "fixed":
return Fixed()
else:
raise Exception("Unhandled type: {}".format(record_type))
def read_utf8(self):
self._parser.advance(String())
if self._parser.stack[-1] == MapKeyMarker():
self._parser.advance(MapKeyMarker())
for key in self._current:
self._key = key
break
return self._key
else:
return self.read_value()