def attributes(self): if self.attributes_ is None: self.lazy_init_lock_.acquire() try: if self.attributes_ is None: self.attributes_ = ReviewAttributes() finally: self.lazy_init_lock_.release() return self.attributes_
class DocInfo_Content(ProtocolBuffer.ProtocolMessage): def __init__(self, contents=None): self.clusterdocid_ = 0 self.content_id_ = 0 self.language_ = 0 self.context_ = [] self.highlight_ = [] self.attributes_ = None self.scraped_ = 0 self.inferred_ = 0 self.authority_ = 0.0 self.has_clusterdocid_ = 0 self.has_content_id_ = 0 self.has_language_ = 0 self.has_attributes_ = 0 self.has_scraped_ = 0 self.has_inferred_ = 0 self.has_authority_ = 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 content_id(self): return self.content_id_ def set_content_id(self, x): self.has_content_id_ = 1 self.content_id_ = x def clear_content_id(self): self.has_content_id_ = 0 self.content_id_ = 0 def has_content_id(self): return self.has_content_id_ def language(self): return self.language_ def set_language(self, x): self.has_language_ = 1 self.language_ = x def clear_language(self): self.has_language_ = 0 self.language_ = 0 def has_language(self): return self.has_language_ def context_size(self): return len(self.context_) def context_list(self): return self.context_ def context(self, i): return self.context_[i] def mutable_context(self, i): return self.context_[i] def add_context(self): x = DocInfo_ContentContext() self.context_.append(x) return x def clear_context(self): self.context_ = [] def highlight_size(self): return len(self.highlight_) def highlight_list(self): return self.highlight_ def highlight(self, i): return self.highlight_[i] def mutable_highlight(self, i): return self.highlight_[i] def add_highlight(self): x = DocInfo_ContentHighlight() self.highlight_.append(x) return x def clear_highlight(self): self.highlight_ = [] def attributes(self): if self.attributes_ is None: self.lazy_init_lock_.acquire() try: if self.attributes_ is None: self.attributes_ = ReviewAttributes() finally: self.lazy_init_lock_.release() return self.attributes_ def mutable_attributes(self): self.has_attributes_ = 1 return self.attributes() def clear_attributes(self): # Warning: this method does not acquire the lock. self.has_attributes_ = 0 if self.attributes_ is not None: self.attributes_.Clear() def has_attributes(self): return self.has_attributes_ def scraped(self): return self.scraped_ def set_scraped(self, x): self.has_scraped_ = 1 self.scraped_ = x def clear_scraped(self): self.has_scraped_ = 0 self.scraped_ = 0 def has_scraped(self): return self.has_scraped_ def inferred(self): return self.inferred_ def set_inferred(self, x): self.has_inferred_ = 1 self.inferred_ = x def clear_inferred(self): self.has_inferred_ = 0 self.inferred_ = 0 def has_inferred(self): return self.has_inferred_ def authority(self): return self.authority_ def set_authority(self, x): self.has_authority_ = 1 self.authority_ = x def clear_authority(self): self.has_authority_ = 0 self.authority_ = 0.0 def has_authority(self): return self.has_authority_ def MergeFrom(self, x): assert x is not self if x.has_clusterdocid(): self.set_clusterdocid(x.clusterdocid()) if x.has_content_id(): self.set_content_id(x.content_id()) if x.has_language(): self.set_language(x.language()) for i in xrange(x.context_size()): self.add_context().CopyFrom(x.context(i)) for i in xrange(x.highlight_size()): self.add_highlight().CopyFrom(x.highlight(i)) if x.has_attributes(): self.mutable_attributes().MergeFrom(x.attributes()) if x.has_scraped(): self.set_scraped(x.scraped()) if x.has_inferred(): self.set_inferred(x.inferred()) if x.has_authority(): self.set_authority(x.authority()) def _CMergeFromString(self, s): _net_proto___parse__python.MergeFromString(self, "localsearch.DocInfo", s) def _CEncode(self): return _net_proto___parse__python.Encode(self, "localsearch.DocInfo") def _CToASCII(self, output_format): return _net_proto___parse__python.ToASCII(self, "localsearch.DocInfo", output_format) def ParseASCII(self, s): _net_proto___parse__python.ParseASCII(self, "localsearch.DocInfo", s) def ParseASCIIIgnoreUnknown(self, s): _net_proto___parse__python.ParseASCIIIgnoreUnknown(self, "localsearch.DocInfo", 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_content_id_ != x.has_content_id_: return 0 if self.has_content_id_ and self.content_id_ != x.content_id_: return 0 if self.has_language_ != x.has_language_: return 0 if self.has_language_ and self.language_ != x.language_: return 0 if len(self.context_) != len(x.context_): return 0 for e1, e2 in zip(self.context_, x.context_): if e1 != e2: return 0 if len(self.highlight_) != len(x.highlight_): return 0 for e1, e2 in zip(self.highlight_, x.highlight_): if e1 != e2: return 0 if self.has_attributes_ != x.has_attributes_: return 0 if self.has_attributes_ and self.attributes_ != x.attributes_: return 0 if self.has_scraped_ != x.has_scraped_: return 0 if self.has_scraped_ and self.scraped_ != x.scraped_: return 0 if self.has_inferred_ != x.has_inferred_: return 0 if self.has_inferred_ and self.inferred_ != x.inferred_: return 0 if self.has_authority_ != x.has_authority_: return 0 if self.has_authority_ and self.authority_ != x.authority_: 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 not self.has_clusterdocid_: initialized = 0 if debug_strs is not None: debug_strs.append("Required field: clusterdocid not set.") if not self.has_content_id_: initialized = 0 if debug_strs is not None: debug_strs.append("Required field: content_id not set.") for i in xrange(len(self.context_)): if not self.context_[i].IsInitialized(debug_strs): initialized = 0 for i in xrange(len(self.highlight_)): if not self.highlight_[i].IsInitialized(debug_strs): initialized = 0 if self.has_attributes_ and not self.attributes_.IsInitialized(debug_strs): initialized = 0 return initialized def ByteSize(self): n = 0 n += self.lengthVarInt64(self.content_id_) if self.has_language_: n += 1 + self.lengthVarInt64(self.language_) n += 2 * len(self.context_) for i in xrange(len(self.context_)): n += self.context_[i].ByteSize() n += 2 * len(self.highlight_) for i in xrange(len(self.highlight_)): n += self.highlight_[i].ByteSize() if self.has_attributes_: n += 1 + self.lengthString(self.attributes_.ByteSize()) if self.has_scraped_: n += 3 if self.has_inferred_: n += 3 if self.has_authority_: n += 10 return n + 10 def Clear(self): self.clear_clusterdocid() self.clear_content_id() self.clear_language() self.clear_context() self.clear_highlight() self.clear_attributes() self.clear_scraped() self.clear_inferred() self.clear_authority() def OutputUnchecked(self, out): out.putVarInt32(17) out.put64(self.clusterdocid_) out.putVarInt32(24) out.putVarInt32(self.content_id_) if self.has_language_: out.putVarInt32(32) out.putVarInt32(self.language_) for i in xrange(len(self.context_)): out.putVarInt32(43) self.context_[i].OutputUnchecked(out) out.putVarInt32(44) for i in xrange(len(self.highlight_)): out.putVarInt32(67) self.highlight_[i].OutputUnchecked(out) out.putVarInt32(68) if self.has_attributes_: out.putVarInt32(98) out.putVarInt32(self.attributes_.ByteSize()) self.attributes_.OutputUnchecked(out) if self.has_scraped_: out.putVarInt32(144) out.putBoolean(self.scraped_) if self.has_inferred_: out.putVarInt32(152) out.putBoolean(self.inferred_) if self.has_authority_: out.putVarInt32(161) out.putDouble(self.authority_) def TryMerge(self, d): while 1: tt = d.getVarInt32() if tt == 12: break if tt == 17: self.set_clusterdocid(d.get64()) continue if tt == 24: self.set_content_id(d.getVarInt32()) continue if tt == 32: self.set_language(d.getVarInt32()) continue if tt == 43: self.add_context().TryMerge(d) continue if tt == 67: self.add_highlight().TryMerge(d) continue if tt == 98: length = d.getVarInt32() tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length) d.skip(length) self.mutable_attributes().TryMerge(tmp) continue if tt == 144: self.set_scraped(d.getBoolean()) continue if tt == 152: self.set_inferred(d.getBoolean()) continue if tt == 161: self.set_authority(d.getDouble()) 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.DebugFormatFixed64(self.clusterdocid_)) if self.has_content_id_: res += prefix + ("content_id: %s\n" % self.DebugFormatInt32(self.content_id_)) if self.has_language_: res += prefix + ("language: %s\n" % self.DebugFormatInt32(self.language_)) cnt = 0 for e in self.context_: elm = "" if printElemNumber: elm = "(%d)" % cnt res += prefix + ("Context%s {\n" % elm) res += e.__str__(prefix + " ", printElemNumber) res += prefix + "}\n" cnt += 1 cnt = 0 for e in self.highlight_: elm = "" if printElemNumber: elm = "(%d)" % cnt res += prefix + ("Highlight%s {\n" % elm) res += e.__str__(prefix + " ", printElemNumber) res += prefix + "}\n" cnt += 1 if self.has_attributes_: res += prefix + "attributes <\n" res += self.attributes_.__str__(prefix + " ", printElemNumber) res += prefix + ">\n" if self.has_scraped_: res += prefix + ("scraped: %s\n" % self.DebugFormatBool(self.scraped_)) if self.has_inferred_: res += prefix + ("inferred: %s\n" % self.DebugFormatBool(self.inferred_)) if self.has_authority_: res += prefix + ("authority: %s\n" % self.DebugFormat(self.authority_)) return res
class DocInfo_Content(ProtocolBuffer.ProtocolMessage): def __init__(self, contents=None): self.clusterdocid_ = 0 self.content_id_ = 0 self.language_ = 0 self.context_ = [] self.highlight_ = [] self.attributes_ = None self.scraped_ = 0 self.inferred_ = 0 self.authority_ = 0.0 self.has_clusterdocid_ = 0 self.has_content_id_ = 0 self.has_language_ = 0 self.has_attributes_ = 0 self.has_scraped_ = 0 self.has_inferred_ = 0 self.has_authority_ = 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 content_id(self): return self.content_id_ def set_content_id(self, x): self.has_content_id_ = 1 self.content_id_ = x def clear_content_id(self): self.has_content_id_ = 0 self.content_id_ = 0 def has_content_id(self): return self.has_content_id_ def language(self): return self.language_ def set_language(self, x): self.has_language_ = 1 self.language_ = x def clear_language(self): self.has_language_ = 0 self.language_ = 0 def has_language(self): return self.has_language_ def context_size(self): return len(self.context_) def context_list(self): return self.context_ def context(self, i): return self.context_[i] def mutable_context(self, i): return self.context_[i] def add_context(self): x = DocInfo_ContentContext() self.context_.append(x) return x def clear_context(self): self.context_ = [] def highlight_size(self): return len(self.highlight_) def highlight_list(self): return self.highlight_ def highlight(self, i): return self.highlight_[i] def mutable_highlight(self, i): return self.highlight_[i] def add_highlight(self): x = DocInfo_ContentHighlight() self.highlight_.append(x) return x def clear_highlight(self): self.highlight_ = [] def attributes(self): if self.attributes_ is None: self.lazy_init_lock_.acquire() try: if self.attributes_ is None: self.attributes_ = ReviewAttributes() finally: self.lazy_init_lock_.release() return self.attributes_ def mutable_attributes(self): self.has_attributes_ = 1; return self.attributes() def clear_attributes(self): #Warning: this method does not acquire the lock. self.has_attributes_ = 0; if self.attributes_ is not None: self.attributes_.Clear() def has_attributes(self): return self.has_attributes_ def scraped(self): return self.scraped_ def set_scraped(self, x): self.has_scraped_ = 1 self.scraped_ = x def clear_scraped(self): self.has_scraped_ = 0 self.scraped_ = 0 def has_scraped(self): return self.has_scraped_ def inferred(self): return self.inferred_ def set_inferred(self, x): self.has_inferred_ = 1 self.inferred_ = x def clear_inferred(self): self.has_inferred_ = 0 self.inferred_ = 0 def has_inferred(self): return self.has_inferred_ def authority(self): return self.authority_ def set_authority(self, x): self.has_authority_ = 1 self.authority_ = x def clear_authority(self): self.has_authority_ = 0 self.authority_ = 0.0 def has_authority(self): return self.has_authority_ def MergeFrom(self, x): assert x is not self if (x.has_clusterdocid()): self.set_clusterdocid(x.clusterdocid()) if (x.has_content_id()): self.set_content_id(x.content_id()) if (x.has_language()): self.set_language(x.language()) for i in xrange(x.context_size()): self.add_context().CopyFrom(x.context(i)) for i in xrange(x.highlight_size()): self.add_highlight().CopyFrom(x.highlight(i)) if (x.has_attributes()): self.mutable_attributes().MergeFrom(x.attributes()) if (x.has_scraped()): self.set_scraped(x.scraped()) if (x.has_inferred()): self.set_inferred(x.inferred()) if (x.has_authority()): self.set_authority(x.authority()) def _CMergeFromString(self, s): _net_proto___parse__python.MergeFromString(self, 'localsearch.DocInfo', s) def _CEncode(self): return _net_proto___parse__python.Encode(self, 'localsearch.DocInfo') def _CToASCII(self, output_format): return _net_proto___parse__python.ToASCII(self, 'localsearch.DocInfo', output_format) def ParseASCII(self, s): _net_proto___parse__python.ParseASCII(self, 'localsearch.DocInfo', s) def ParseASCIIIgnoreUnknown(self, s): _net_proto___parse__python.ParseASCIIIgnoreUnknown(self, 'localsearch.DocInfo', 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_content_id_ != x.has_content_id_: return 0 if self.has_content_id_ and self.content_id_ != x.content_id_: return 0 if self.has_language_ != x.has_language_: return 0 if self.has_language_ and self.language_ != x.language_: return 0 if len(self.context_) != len(x.context_): return 0 for e1, e2 in zip(self.context_, x.context_): if e1 != e2: return 0 if len(self.highlight_) != len(x.highlight_): return 0 for e1, e2 in zip(self.highlight_, x.highlight_): if e1 != e2: return 0 if self.has_attributes_ != x.has_attributes_: return 0 if self.has_attributes_ and self.attributes_ != x.attributes_: return 0 if self.has_scraped_ != x.has_scraped_: return 0 if self.has_scraped_ and self.scraped_ != x.scraped_: return 0 if self.has_inferred_ != x.has_inferred_: return 0 if self.has_inferred_ and self.inferred_ != x.inferred_: return 0 if self.has_authority_ != x.has_authority_: return 0 if self.has_authority_ and self.authority_ != x.authority_: 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 (not self.has_clusterdocid_): initialized = 0 if debug_strs is not None: debug_strs.append('Required field: clusterdocid not set.') if (not self.has_content_id_): initialized = 0 if debug_strs is not None: debug_strs.append('Required field: content_id not set.') for i in xrange(len(self.context_)): if (not self.context_[i].IsInitialized(debug_strs)): initialized=0 for i in xrange(len(self.highlight_)): if (not self.highlight_[i].IsInitialized(debug_strs)): initialized=0 if (self.has_attributes_ and not self.attributes_.IsInitialized(debug_strs)): initialized = 0 return initialized def ByteSize(self): n = 0 n += self.lengthVarInt64(self.content_id_) if (self.has_language_): n += 1 + self.lengthVarInt64(self.language_) n += 2 * len(self.context_) for i in xrange(len(self.context_)): n += self.context_[i].ByteSize() n += 2 * len(self.highlight_) for i in xrange(len(self.highlight_)): n += self.highlight_[i].ByteSize() if (self.has_attributes_): n += 1 + self.lengthString(self.attributes_.ByteSize()) if (self.has_scraped_): n += 3 if (self.has_inferred_): n += 3 if (self.has_authority_): n += 10 return n + 10 def Clear(self): self.clear_clusterdocid() self.clear_content_id() self.clear_language() self.clear_context() self.clear_highlight() self.clear_attributes() self.clear_scraped() self.clear_inferred() self.clear_authority() def OutputUnchecked(self, out): out.putVarInt32(17) out.put64(self.clusterdocid_) out.putVarInt32(24) out.putVarInt32(self.content_id_) if (self.has_language_): out.putVarInt32(32) out.putVarInt32(self.language_) for i in xrange(len(self.context_)): out.putVarInt32(43) self.context_[i].OutputUnchecked(out) out.putVarInt32(44) for i in xrange(len(self.highlight_)): out.putVarInt32(67) self.highlight_[i].OutputUnchecked(out) out.putVarInt32(68) if (self.has_attributes_): out.putVarInt32(98) out.putVarInt32(self.attributes_.ByteSize()) self.attributes_.OutputUnchecked(out) if (self.has_scraped_): out.putVarInt32(144) out.putBoolean(self.scraped_) if (self.has_inferred_): out.putVarInt32(152) out.putBoolean(self.inferred_) if (self.has_authority_): out.putVarInt32(161) out.putDouble(self.authority_) def TryMerge(self, d): while 1: tt = d.getVarInt32() if tt == 12: break if tt == 17: self.set_clusterdocid(d.get64()) continue if tt == 24: self.set_content_id(d.getVarInt32()) continue if tt == 32: self.set_language(d.getVarInt32()) continue if tt == 43: self.add_context().TryMerge(d) continue if tt == 67: self.add_highlight().TryMerge(d) continue if tt == 98: length = d.getVarInt32() tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length) d.skip(length) self.mutable_attributes().TryMerge(tmp) continue if tt == 144: self.set_scraped(d.getBoolean()) continue if tt == 152: self.set_inferred(d.getBoolean()) continue if tt == 161: self.set_authority(d.getDouble()) 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.DebugFormatFixed64(self.clusterdocid_)) if self.has_content_id_: res+=prefix+("content_id: %s\n" % self.DebugFormatInt32(self.content_id_)) if self.has_language_: res+=prefix+("language: %s\n" % self.DebugFormatInt32(self.language_)) cnt=0 for e in self.context_: elm="" if printElemNumber: elm="(%d)" % cnt res+=prefix+("Context%s {\n" % elm) res+=e.__str__(prefix + " ", printElemNumber) res+=prefix+"}\n" cnt+=1 cnt=0 for e in self.highlight_: elm="" if printElemNumber: elm="(%d)" % cnt res+=prefix+("Highlight%s {\n" % elm) res+=e.__str__(prefix + " ", printElemNumber) res+=prefix+"}\n" cnt+=1 if self.has_attributes_: res+=prefix+"attributes <\n" res+=self.attributes_.__str__(prefix + " ", printElemNumber) res+=prefix+">\n" if self.has_scraped_: res+=prefix+("scraped: %s\n" % self.DebugFormatBool(self.scraped_)) if self.has_inferred_: res+=prefix+("inferred: %s\n" % self.DebugFormatBool(self.inferred_)) if self.has_authority_: res+=prefix+("authority: %s\n" % self.DebugFormat(self.authority_)) return res