<s> """<STR_LIT>""" <EOL> from google . net . proto import ProtocolBuffer <EOL> import logging <EOL> try : <EOL> from google3 . net . proto import _net_proto___parse__python <EOL> except ImportError : <EOL> _net_proto___parse__python = None <EOL> TAG_BEGIN_ITEM_GROUP = <NUM_LIT:11> <EOL> TAG_END_ITEM_GROUP = <NUM_LIT:12> <EOL> TAG_TYPE_ID = <NUM_LIT:16> <EOL> TAG_MESSAGE = <NUM_LIT> <EOL> class Item : <EOL> def __init__ ( self , message , message_class = None ) : <EOL> self . message = message <EOL> self . message_class = message_class <EOL> def SetToDefaultInstance ( self , message_class ) : <EOL> self . message = message_class ( ) <EOL> self . message_class = message_class <EOL> def Parse ( self , message_class ) : <EOL> if self . message_class is not None : <EOL> return <NUM_LIT:1> <EOL> try : <EOL> message_obj = message_class ( ) <EOL> message_obj . MergePartialFromString ( self . message ) <EOL> self . message = message_obj <EOL> self . message_class = message_class <EOL> return <NUM_LIT:1> <EOL> except ProtocolBuffer . ProtocolBufferDecodeError : <EOL> logging . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" + message_class . __name__ ) <EOL> return <NUM_LIT:0> <EOL> def MergeFrom ( self , other ) : <EOL> if self . message_class is not None : <EOL> if other . Parse ( self . message_class ) : <EOL> self . message . MergeFrom ( other . message ) <EOL> elif other . message_class is not None : <EOL> if not self . Parse ( other . message_class ) : <EOL> self . message = other . message_class ( ) <EOL> self . message_class = other . message_class <EOL> self . message . MergeFrom ( other . message ) <EOL> else : <EOL> self . message += other . message <EOL> def Copy ( self ) : <EOL> if self . message_class is None : <EOL> return Item ( self . message ) <EOL> else : <EOL> new_message = self . message_class ( ) <EOL> new_message . CopyFrom ( self . message ) <EOL> return Item ( new_message , self . message_class ) <EOL> def Equals ( self , other ) : <EOL> if self . message_class is not None : <EOL> if not other . Parse ( self . message_class ) : return <NUM_LIT:0> <EOL> return self . message . Equals ( other . message ) <EOL> elif other . message_class is not None : <EOL> if not self . Parse ( other . message_class ) : return <NUM_LIT:0> <EOL> return self . message . Equals ( other . message ) <EOL> else : <EOL> return self . message == other . message <EOL> def IsInitialized ( self , debug_strs = None ) : <EOL> if self . message_class is None : <EOL> return <NUM_LIT:1> <EOL> else : <EOL> return self . message . IsInitialized ( debug_strs ) <EOL> def ByteSize ( self , pb , type_id ) : <EOL> message_length = <NUM_LIT:0> <EOL> if self . message_class is None : <EOL> message_length = len ( self . message ) <EOL> else : <EOL> message_length = self . message . ByteSize ( ) <EOL> return pb . lengthString ( message_length ) + pb . lengthVarInt64 ( type_id ) + <NUM_LIT:2> <EOL> def ByteSizePartial ( self , pb , type_id ) : <EOL> message_length = <NUM_LIT:0> <EOL> if self . message_class is None : <EOL> message_length = len ( self . message ) <EOL> else : <EOL> message_length = self . message . ByteSizePartial ( ) <EOL> return pb . lengthString ( message_length ) + pb . lengthVarInt64 ( type_id ) + <NUM_LIT:2> <EOL> def OutputUnchecked ( self , out , type_id ) : <EOL> out . putVarInt32 ( TAG_TYPE_ID ) <EOL> out . putVarUint64 ( type_id ) <EOL> out . putVarInt32 ( TAG_MESSAGE ) <EOL> if self . message_class is None : <EOL> out . putPrefixedString ( self . message ) <EOL> else : <EOL> out . putVarInt32 ( self . message . ByteSize ( ) ) <EOL> self . message . OutputUnchecked ( out ) <EOL> def OutputPartial ( self , out , type_id ) : <EOL> out . putVarInt32 ( TAG_TYPE_ID ) <EOL> out . putVarUint64 ( type_id ) <EOL> out . putVarInt32 ( TAG_MESSAGE ) <EOL> if self . message_class is None : <EOL> out . putPrefixedString ( self . message ) <EOL> else : <EOL> out . putVarInt32 ( self . message . ByteSizePartial ( ) ) <EOL> self . message . OutputPartial ( out ) <EOL> def Decode ( decoder ) : <EOL> type_id = <NUM_LIT:0> <EOL> message = None <EOL> while <NUM_LIT:1> : <EOL> tag = decoder . getVarInt32 ( ) <EOL> if tag == TAG_END_ITEM_GROUP : <EOL> break <EOL> if tag == TAG_TYPE_ID : <EOL> type_id = decoder . getVarUint64 ( ) <EOL> continue <EOL> if tag == TAG_MESSAGE : <EOL> message = decoder . getPrefixedString ( ) <EOL> continue <EOL> if tag == <NUM_LIT:0> : raise ProtocolBuffer . ProtocolBufferDecodeError <EOL> decoder . skipData ( tag ) <EOL> if type_id == <NUM_LIT:0> or message is None : <EOL> raise ProtocolBuffer . ProtocolBufferDecodeError <EOL> return ( type_id , message ) <EOL> Decode = staticmethod ( Decode ) <EOL> class MessageSet ( ProtocolBuffer . ProtocolMessage ) : <EOL> def __init__ ( self , contents = None ) : <EOL> self . items = dict ( ) <EOL> if contents is not None : self . MergeFromString ( contents ) <EOL> def get ( self , message_class ) : <EOL> if message_class . MESSAGE_TYPE_ID not in self . items : <EOL> return message_class ( ) <EOL> item = self . items [ message_class . MESSAGE_TYPE_ID ] <EOL> if item . Parse ( message_class ) : <EOL> return item . message <EOL> else : <EOL> return message_class ( ) <EOL> def mutable ( self , message_class ) : <EOL> if message_class . MESSAGE_TYPE_ID not in self . items : <EOL> message = message_class ( ) <EOL> self . items [ message_class . MESSAGE_TYPE_ID ] = Item ( message , message_class ) <EOL> return message <EOL> item = self . items [ message_class . MESSAGE_TYPE_ID ] <EOL> if not item . Parse ( message_class ) : <EOL> item . SetToDefaultInstance ( message_class ) <EOL> return item . message <EOL> def has ( self , message_class ) : <EOL> if message_class . MESSAGE_TYPE_ID not in self . items : <EOL> return <NUM_LIT:0> <EOL> item = self . items [ message_class . MESSAGE_TYPE_ID ] <EOL> return item . Parse ( message_class ) <EOL> def has_unparsed ( self , message_class ) : <EOL> return message_class . MESSAGE_TYPE_ID in self . items <EOL> def GetTypeIds ( self ) : <EOL> return self . items . keys ( ) <EOL> def NumMessages ( self ) : <EOL> return len ( self . items ) <EOL> def remove ( self , message_class ) : <EOL> if message_class . MESSAGE_TYPE_ID in self . items : <EOL> del self . items [ message_class . MESSAGE_TYPE_ID ] <EOL> def __getitem__ ( self , message_class ) : <EOL> if message_class . MESSAGE_TYPE_ID not in self . items : <EOL> raise KeyError ( message_class ) <EOL> item = self . items [ message_class . MESSAGE_TYPE_ID ] <EOL> if item . Parse ( message_class ) : <EOL> return item . message <EOL> else : <EOL> raise KeyError ( message_class ) <EOL> def __setitem__ ( self , message_class , message ) : <EOL> self . items [ message_class . MESSAGE_TYPE_ID ] = Item ( message , message_class ) <EOL> def __contains__ ( self , message_class ) : <EOL> return self . has ( message_class ) <EOL> def __delitem__ ( self , message_class ) : <EOL> self . remove ( message_class ) <EOL> def __len__ ( self ) : <EOL> return len ( self . items ) <EOL> def MergeFrom ( self , other ) : <EOL> assert other is not self <EOL> for ( type_id , item ) in other . items . items ( ) : <EOL> if type_id in self . items : <EOL> self . items [ type_id ] . MergeFrom ( item ) <EOL> else : <EOL> self . items [ type_id ] = item . Copy ( ) <EOL> def Equals ( self , other ) : <EOL> if other is self : return <NUM_LIT:1> <EOL> if len ( self . items ) != len ( other . items ) : return <NUM_LIT:0> <EOL> for ( type_id , item ) in other . items . items ( ) : <EOL> if type_id not in self . items : return <NUM_LIT:0> <EOL> if not self . items [ type_id ] . Equals ( item ) : return <NUM_LIT:0> <EOL> return <NUM_LIT:1> <EOL> def __eq__ ( self , other ) : <EOL> return ( ( other is not None ) <EOL> and ( other . __class__ == self . __class__ ) <EOL> and self . Equals ( other ) ) <EOL> def __ne__ ( self , other ) : <EOL> return not ( self == other ) <EOL> def IsInitialized ( self , debug_strs = None ) : <EOL> initialized = <NUM_LIT:1> <EOL> for item in self . items . values ( ) : <EOL> if not item . IsInitialized ( debug_strs ) : <EOL> initialized = <NUM_LIT:0> <EOL> return initialized <EOL> def ByteSize ( self ) : <EOL> n = <NUM_LIT:2> * len ( self . items ) <EOL> for ( type_id , item ) in self . items . items ( ) : <EOL> n += item . ByteSize ( self , type_id ) <EOL> return n <EOL> def ByteSizePartial ( self ) : <EOL> n = <NUM_LIT:2> * len ( self . items ) <EOL> for ( type_id , item ) in self . items . items ( ) : <EOL> n += item . ByteSizePartial ( self , type_id ) <EOL> return n <EOL> def Clear ( self ) : <EOL> self . items = dict ( ) <EOL> def OutputUnchecked ( self , out ) : <EOL> for ( type_id , item ) in self . items . items ( ) : <EOL> out . putVarInt32 ( TAG_BEGIN_ITEM_GROUP ) <EOL> item . OutputUnchecked ( out , type_id ) <EOL> out . putVarInt32 ( TAG_END_ITEM_GROUP ) <EOL> def OutputPartial ( self , out ) : <EOL> for ( type_id , item ) in self . items . items ( ) : <EOL> out . putVarInt32 ( TAG_BEGIN_ITEM_GROUP ) <EOL> item . OutputPartial ( out , type_id ) <EOL> out . putVarInt32 ( TAG_END_ITEM_GROUP ) <EOL> def TryMerge ( self , decoder ) : <EOL> while decoder . avail ( ) > <NUM_LIT:0> : <EOL> tag = decoder . getVarInt32 ( ) <EOL> if tag == TAG_BEGIN_ITEM_GROUP : <EOL> ( type_id , message ) = Item . Decode ( decoder ) <EOL> if type_id in self . items : <EOL> self . items [ type_id ] . MergeFrom ( Item ( message ) ) <EOL> else : <EOL> self . items [ type_id ] = Item ( message ) <EOL> continue <EOL> if ( tag == <NUM_LIT:0> ) : raise ProtocolBuffer . ProtocolBufferDecodeError <EOL> decoder . skipData ( tag ) <EOL> def _CToASCII ( self , output_format ) : <EOL> if _net_proto___parse__python is None : <EOL> return ProtocolBuffer . ProtocolMessage . _CToASCII ( self , output_format ) <EOL> else : <EOL> return _net_proto___parse__python . ToASCII ( <EOL> self , "<STR_LIT>" , output_format ) <EOL> def ParseASCII ( self , s ) : <EOL> if _net_proto___parse__python is None : <EOL> ProtocolBuffer . ProtocolMessage . ParseASCII ( self , s ) <EOL> else : <EOL> _net_proto___parse__python . ParseASCII ( self , "<STR_LIT>" , s ) <EOL> def ParseASCIIIgnoreUnknown ( self , s ) : <EOL> if _net_proto___parse__python is None : <EOL> ProtocolBuffer . ProtocolMessage . ParseASCIIIgnoreUnknown ( self , s ) <EOL> else : <EOL> _net_proto___parse__python . ParseASCIIIgnoreUnknown ( <EOL> self , "<STR_LIT>" , s ) <EOL> def __str__ ( self , prefix = "<STR_LIT>" , printElemNumber = <NUM_LIT:0> ) : <EOL> text = "<STR_LIT>" <EOL> for ( type_id , item ) in self . items . items ( ) : <EOL> if item . message_class is None : <EOL> text += "<STR_LIT>" % ( prefix , type_id ) <EOL> text += "<STR_LIT>" % ( prefix , len ( item . message ) ) <EOL> text += "<STR_LIT>" % prefix <EOL> else : <EOL> text += "<STR_LIT>" % ( prefix , item . message_class . __name__ ) <EOL> text += item . message . __str__ ( prefix + "<STR_LIT:U+0020>" , printElemNumber ) <EOL> text += "<STR_LIT>" % prefix <EOL> return text <EOL> _PROTO_DESCRIPTOR_NAME = '<STR_LIT>' <EOL> __all__ = [ '<STR_LIT>' ] </s>
