class LocalWWWInfo_Cluster(ProtocolBuffer.ProtocolMessage): def __init__(self, contents=None): self.clusterdocid_ = 0 self.clusterid_ = "" self.latitude_e6_ = 0 self.longitude_e6_ = 0 self.title_ = "" self.postal_address_ = None self.phone_number_ = None self.confidence_ = 0.0 self.source_ = [] self.show_in_snippets_ = 0 self.include_in_index_ = 0 self.has_clusterdocid_ = 0 self.has_clusterid_ = 0 self.has_latitude_e6_ = 0 self.has_longitude_e6_ = 0 self.has_title_ = 0 self.has_postal_address_ = 0 self.has_phone_number_ = 0 self.has_confidence_ = 0 self.has_show_in_snippets_ = 0 self.has_include_in_index_ = 0 self.lazy_init_lock_ = thread.allocate_lock() if contents is not None: self.MergeFromString(contents) def clusterdocid(self): return self.clusterdocid_ def set_clusterdocid(self, x): self.has_clusterdocid_ = 1 self.clusterdocid_ = x def clear_clusterdocid(self): self.has_clusterdocid_ = 0 self.clusterdocid_ = 0 def has_clusterdocid(self): return self.has_clusterdocid_ def clusterid(self): return self.clusterid_ def set_clusterid(self, x): self.has_clusterid_ = 1 self.clusterid_ = x def clear_clusterid(self): self.has_clusterid_ = 0 self.clusterid_ = "" def has_clusterid(self): return self.has_clusterid_ def latitude_e6(self): return self.latitude_e6_ def set_latitude_e6(self, x): self.has_latitude_e6_ = 1 self.latitude_e6_ = x def clear_latitude_e6(self): self.has_latitude_e6_ = 0 self.latitude_e6_ = 0 def has_latitude_e6(self): return self.has_latitude_e6_ def longitude_e6(self): return self.longitude_e6_ def set_longitude_e6(self, x): self.has_longitude_e6_ = 1 self.longitude_e6_ = x def clear_longitude_e6(self): self.has_longitude_e6_ = 0 self.longitude_e6_ = 0 def has_longitude_e6(self): return self.has_longitude_e6_ def title(self): return self.title_ def set_title(self, x): self.has_title_ = 1 self.title_ = x def clear_title(self): self.has_title_ = 0 self.title_ = "" def has_title(self): return self.has_title_ def postal_address(self): if self.postal_address_ is None: self.lazy_init_lock_.acquire() try: if self.postal_address_ is None: self.postal_address_ = PostalAddress() finally: self.lazy_init_lock_.release() return self.postal_address_ def mutable_postal_address(self): self.has_postal_address_ = 1; return self.postal_address() def clear_postal_address(self): #Warning: this method does not acquire the lock. self.has_postal_address_ = 0; if self.postal_address_ is not None: self.postal_address_.Clear() def has_postal_address(self): return self.has_postal_address_ def phone_number(self): if self.phone_number_ is None: self.lazy_init_lock_.acquire() try: if self.phone_number_ is None: self.phone_number_ = TelephoneNumber() finally: self.lazy_init_lock_.release() return self.phone_number_ def mutable_phone_number(self): self.has_phone_number_ = 1; return self.phone_number() def clear_phone_number(self): #Warning: this method does not acquire the lock. self.has_phone_number_ = 0; if self.phone_number_ is not None: self.phone_number_.Clear() def has_phone_number(self): return self.has_phone_number_ def confidence(self): return self.confidence_ def set_confidence(self, x): self.has_confidence_ = 1 self.confidence_ = x def clear_confidence(self): self.has_confidence_ = 0 self.confidence_ = 0.0 def has_confidence(self): return self.has_confidence_ def source_size(self): return len(self.source_) def source_list(self): return self.source_ def source(self, i): return self.source_[i] def set_source(self, i, x): self.source_[i] = x def add_source(self, x): self.source_.append(x) def clear_source(self): self.source_ = [] def show_in_snippets(self): return self.show_in_snippets_ def set_show_in_snippets(self, x): self.has_show_in_snippets_ = 1 self.show_in_snippets_ = x def clear_show_in_snippets(self): self.has_show_in_snippets_ = 0 self.show_in_snippets_ = 0 def has_show_in_snippets(self): return self.has_show_in_snippets_ def include_in_index(self): return self.include_in_index_ def set_include_in_index(self, x): self.has_include_in_index_ = 1 self.include_in_index_ = x def clear_include_in_index(self): self.has_include_in_index_ = 0 self.include_in_index_ = 0 def has_include_in_index(self): return self.has_include_in_index_ def MergeFrom(self, x): assert x is not self if (x.has_clusterdocid()): self.set_clusterdocid(x.clusterdocid()) if (x.has_clusterid()): self.set_clusterid(x.clusterid()) if (x.has_latitude_e6()): self.set_latitude_e6(x.latitude_e6()) if (x.has_longitude_e6()): self.set_longitude_e6(x.longitude_e6()) if (x.has_title()): self.set_title(x.title()) if (x.has_postal_address()): self.mutable_postal_address().MergeFrom(x.postal_address()) if (x.has_phone_number()): self.mutable_phone_number().MergeFrom(x.phone_number()) if (x.has_confidence()): self.set_confidence(x.confidence()) for i in xrange(x.source_size()): self.add_source(x.source(i)) if (x.has_show_in_snippets()): self.set_show_in_snippets(x.show_in_snippets()) if (x.has_include_in_index()): self.set_include_in_index(x.include_in_index()) def _CMergeFromString(self, s): _net_proto___parse__python.MergeFromString(self, 'LocalWWWInfo', s) def _CEncode(self): return _net_proto___parse__python.Encode(self, 'LocalWWWInfo') def _CToASCII(self, output_format): return _net_proto___parse__python.ToASCII(self, 'LocalWWWInfo', output_format) def ParseASCII(self, s): _net_proto___parse__python.ParseASCII(self, 'LocalWWWInfo', s) def ParseASCIIIgnoreUnknown(self, s): _net_proto___parse__python.ParseASCIIIgnoreUnknown(self, 'LocalWWWInfo', s) def Equals(self, x): if x is self: return 1 if self.has_clusterdocid_ != x.has_clusterdocid_: return 0 if self.has_clusterdocid_ and self.clusterdocid_ != x.clusterdocid_: return 0 if self.has_clusterid_ != x.has_clusterid_: return 0 if self.has_clusterid_ and self.clusterid_ != x.clusterid_: return 0 if self.has_latitude_e6_ != x.has_latitude_e6_: return 0 if self.has_latitude_e6_ and self.latitude_e6_ != x.latitude_e6_: return 0 if self.has_longitude_e6_ != x.has_longitude_e6_: return 0 if self.has_longitude_e6_ and self.longitude_e6_ != x.longitude_e6_: return 0 if self.has_title_ != x.has_title_: return 0 if self.has_title_ and self.title_ != x.title_: return 0 if self.has_postal_address_ != x.has_postal_address_: return 0 if self.has_postal_address_ and self.postal_address_ != x.postal_address_: return 0 if self.has_phone_number_ != x.has_phone_number_: return 0 if self.has_phone_number_ and self.phone_number_ != x.phone_number_: return 0 if self.has_confidence_ != x.has_confidence_: return 0 if self.has_confidence_ and self.confidence_ != x.confidence_: return 0 if len(self.source_) != len(x.source_): return 0 for e1, e2 in zip(self.source_, x.source_): if e1 != e2: return 0 if self.has_show_in_snippets_ != x.has_show_in_snippets_: return 0 if self.has_show_in_snippets_ and self.show_in_snippets_ != x.show_in_snippets_: return 0 if self.has_include_in_index_ != x.has_include_in_index_: return 0 if self.has_include_in_index_ and self.include_in_index_ != x.include_in_index_: return 0 return 1 def __eq__(self, other): return (other is not None) and (other.__class__ == self.__class__) and self.Equals(other) def __ne__(self, other): return not (self == other) def IsInitialized(self, debug_strs=None): initialized = 1 if (self.has_postal_address_ and not self.postal_address_.IsInitialized(debug_strs)): initialized = 0 if (self.has_phone_number_ and not self.phone_number_.IsInitialized(debug_strs)): initialized = 0 return initialized def ByteSize(self): n = 0 if (self.has_clusterdocid_): n += 1 + self.lengthVarInt64(self.clusterdocid_) if (self.has_clusterid_): n += 1 + self.lengthString(len(self.clusterid_)) if (self.has_latitude_e6_): n += 1 + self.lengthVarInt64(self.latitude_e6_) if (self.has_longitude_e6_): n += 1 + self.lengthVarInt64(self.longitude_e6_) if (self.has_title_): n += 1 + self.lengthString(len(self.title_)) if (self.has_postal_address_): n += 1 + self.lengthString(self.postal_address_.ByteSize()) if (self.has_phone_number_): n += 1 + self.lengthString(self.phone_number_.ByteSize()) if (self.has_confidence_): n += 5 n += 1 * len(self.source_) for i in xrange(len(self.source_)): n += self.lengthString(len(self.source_[i])) if (self.has_show_in_snippets_): n += 2 if (self.has_include_in_index_): n += 3 return n + 0 def Clear(self): self.clear_clusterdocid() self.clear_clusterid() self.clear_latitude_e6() self.clear_longitude_e6() self.clear_title() self.clear_postal_address() self.clear_phone_number() self.clear_confidence() self.clear_source() self.clear_show_in_snippets() self.clear_include_in_index() def OutputUnchecked(self, out): if (self.has_clusterdocid_): out.putVarInt32(48) out.putVarUint64(self.clusterdocid_) if (self.has_latitude_e6_): out.putVarInt32(56) out.putVarInt32(self.latitude_e6_) if (self.has_longitude_e6_): out.putVarInt32(64) out.putVarInt32(self.longitude_e6_) if (self.has_title_): out.putVarInt32(74) out.putPrefixedString(self.title_) if (self.has_postal_address_): out.putVarInt32(82) out.putVarInt32(self.postal_address_.ByteSize()) self.postal_address_.OutputUnchecked(out) if (self.has_phone_number_): out.putVarInt32(90) out.putVarInt32(self.phone_number_.ByteSize()) self.phone_number_.OutputUnchecked(out) if (self.has_confidence_): out.putVarInt32(101) out.putFloat(self.confidence_) if (self.has_clusterid_): out.putVarInt32(106) out.putPrefixedString(self.clusterid_) for i in xrange(len(self.source_)): out.putVarInt32(114) out.putPrefixedString(self.source_[i]) if (self.has_show_in_snippets_): out.putVarInt32(120) out.putBoolean(self.show_in_snippets_) if (self.has_include_in_index_): out.putVarInt32(128) out.putBoolean(self.include_in_index_) def TryMerge(self, d): while 1: tt = d.getVarInt32() if tt == 44: break if tt == 48: self.set_clusterdocid(d.getVarUint64()) continue if tt == 56: self.set_latitude_e6(d.getVarInt32()) continue if tt == 64: self.set_longitude_e6(d.getVarInt32()) continue if tt == 74: self.set_title(d.getPrefixedString()) continue if tt == 82: length = d.getVarInt32() tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length) d.skip(length) self.mutable_postal_address().TryMerge(tmp) continue if tt == 90: length = d.getVarInt32() tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length) d.skip(length) self.mutable_phone_number().TryMerge(tmp) continue if tt == 101: self.set_confidence(d.getFloat()) continue if tt == 106: self.set_clusterid(d.getPrefixedString()) continue if tt == 114: self.add_source(d.getPrefixedString()) continue if tt == 120: self.set_show_in_snippets(d.getBoolean()) continue if tt == 128: self.set_include_in_index(d.getBoolean()) continue # tag 0 is special: it's used to indicate an error. # so if we see it we raise an exception. if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError d.skipData(tt) def __str__(self, prefix="", printElemNumber=0): res="" if self.has_clusterdocid_: res+=prefix+("clusterdocid: %s\n" % self.DebugFormatInt64(self.clusterdocid_)) if self.has_clusterid_: res+=prefix+("clusterid: %s\n" % self.DebugFormatString(self.clusterid_)) if self.has_latitude_e6_: res+=prefix+("latitude_e6: %s\n" % self.DebugFormatInt32(self.latitude_e6_)) if self.has_longitude_e6_: res+=prefix+("longitude_e6: %s\n" % self.DebugFormatInt32(self.longitude_e6_)) if self.has_title_: res+=prefix+("title: %s\n" % self.DebugFormatString(self.title_)) if self.has_postal_address_: res+=prefix+"postal_address <\n" res+=self.postal_address_.__str__(prefix + " ", printElemNumber) res+=prefix+">\n" if self.has_phone_number_: res+=prefix+"phone_number <\n" res+=self.phone_number_.__str__(prefix + " ", printElemNumber) res+=prefix+">\n" if self.has_confidence_: res+=prefix+("confidence: %s\n" % self.DebugFormatFloat(self.confidence_)) cnt=0 for e in self.source_: elm="" if printElemNumber: elm="(%d)" % cnt res+=prefix+("source%s: %s\n" % (elm, self.DebugFormatString(e))) cnt+=1 if self.has_show_in_snippets_: res+=prefix+("show_in_snippets: %s\n" % self.DebugFormatBool(self.show_in_snippets_)) if self.has_include_in_index_: res+=prefix+("include_in_index: %s\n" % self.DebugFormatBool(self.include_in_index_)) return res