here.platform.schema.protobuf_parser module#
Protobuf Parser module
- class here.platform.schema.protobuf_parser.ProtobufParser(schema_pkg_file: str | Path | BytesIO)[source]#
Bases:
ParserA class for parsing Protobuf data of a catalog layer partition.
- static access_field(message: Message, path: str | None)[source]#
Return the data at the given path.
- Parameters:
message – a decoded Protobuf message
path – path to the field, concatenate field names with ‘.’ to select nested fields
- Returns:
the field referenced by the
pathparameter. This is either aMessagein case the field contains a nested Protobuf structure, a simple value for integers, strings and other native types, or a container that can be iterated for a repeated field in Protobuf.
- get_message_class(fully_qualified_message_name: str) Any[source]#
Get Message class by fully qualified message name.
- Parameters:
fully_qualified_message_name – fully qualified message name of the proto class
- Returns:
message class
- parse_message(message: bytes) Message[source]#
Parse a Protobuf message and returns the corresponding partition class instance.
- Parameters:
message – message received as blob
- Returns:
parsed Protobuf message
- parse_message_by_class(message: bytes, fully_qualified_message_name: str) Message | Any[source]#
Parse a Protobuf message by proto class and returns the corresponding partition class instance.
- Parameters:
message – message received as blob
fully_qualified_message_name – fully qualified message name of the proto class
- Returns:
parsed Protobuf message
- primary_fields(all_fields: bool = False) List[FieldDescriptor][source]#
Return the field descriptors of the root partition class.
- Parameters:
all_fields – Return all field descriptors of the root partition class that are labeled ‘repeated’ if all is set to False. Return all the field descriptors otherwise.
- Returns:
List of field descriptors