<s> from groundstation . objects . base_object_pb2 import BaseObject , ROOT as TYPE_ROOT , UPDATE as TYPE_UPDATE , UNSET as TYPE_UNSET <EOL> from groundstation . objects . root_object import RootObject <EOL> from groundstation . objects . update_object import UpdateObject <EOL> def type_of ( protobuf ) : <EOL> base = BaseObject ( ) <EOL> base . ParseFromString ( protobuf ) <EOL> return base . type <EOL> def hydrate_object ( protobuf ) : <EOL> _type = type_of ( protobuf ) <EOL> if _type == TYPE_ROOT : <EOL> return RootObject . from_object ( protobuf ) <EOL> elif _type == TYPE_UPDATE : <EOL> return UpdateObject . from_object ( protobuf ) <EOL> elif _type == TYPE_UNSET : <EOL> obj = RootObject . from_object ( protobuf ) <EOL> if not obj . protocol : <EOL> obj = UpdateObject . from_object ( protobuf ) <EOL> return obj <EOL> else : <EOL> raise Exception ( "<STR_LIT>" % ( str ( _type ) ) ) </s>
