pycitydata.map.format_converter¶
Module Contents¶
Functions¶
Convert a protobuf message to a JSON string. |
|
Convert a protobuf message to a Python dictionary. |
|
Convert a protobuf message to a MongoDB collection. |
|
Convert a JSON string to a protobuf message. |
|
Convert a Python dictionary to a protobuf message. |
|
Convert a MongoDB collection to a protobuf message. |
Data¶
API¶
- pycitydata.map.format_converter.__all__¶
[‘pb2json’, ‘pb2dict’, ‘pb2coll’, ‘json2pb’, ‘dict2pb’, ‘coll2pb’]
- pycitydata.map.format_converter.pb2json(pb: google.protobuf.message.Message)¶
Convert a protobuf message to a JSON string.
Args:
pb: The protobuf message to be converted.
Returns:
The JSON string.
- pycitydata.map.format_converter.pb2dict(pb: google.protobuf.message.Message)¶
Convert a protobuf message to a Python dictionary.
Args:
pb: The protobuf message to be converted.
Returns:
The Python dict.
- pycitydata.map.format_converter.pb2coll(pb: google.protobuf.message.Message, coll: pymongo.collection.Collection, insert_chunk_size: int = 0, drop: bool = False)¶
Convert a protobuf message to a MongoDB collection.
Args:
pb: The protobuf message to be converted.
coll: The MongoDB collection to be inserted.
insert_chunk_size: The chunk size for inserting the collection. If it is 0, insert all the data at once.
drop: Drop the MongoDB collection or not. True for drop, False for not.
- pycitydata.map.format_converter.T¶
‘TypeVar(…)’
- pycitydata.map.format_converter.json2pb(json: str, pb: pycitydata.map.format_converter.T) pycitydata.map.format_converter.T¶
Convert a JSON string to a protobuf message.
Args:
json: The JSON string to be converted.
pb: The protobuf message to be filled.
Returns:
The protobuf message.
- pycitydata.map.format_converter.dict2pb(d: dict, pb: pycitydata.map.format_converter.T) pycitydata.map.format_converter.T¶
Convert a Python dictionary to a protobuf message.
Args:
d: The Python dict to be converted.
pb: The protobuf message to be filled.
Returns:
The protobuf message.
- pycitydata.map.format_converter.coll2pb(coll: pymongo.collection.Collection, pb: pycitydata.map.format_converter.T) pycitydata.map.format_converter.T¶
Convert a MongoDB collection to a protobuf message.
Args:
coll: The MongoDB collection to be converted.
pb: The protobuf message to be filled.
Returns:
The protobuf message.