3 # Copyright 2007 Google Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 from google
.net
.proto
import ProtocolBuffer
22 import dummy_thread
as thread
24 __pychecker__
= """maxreturns=0 maxbranches=0 no-callinit
25 unusednames=printElemNumber,debug_strs no-special"""
27 if hasattr(ProtocolBuffer
, 'ExtendableProtocolMessage'):
28 _extension_runtime
= True
29 _ExtendableProtocolMessage
= ProtocolBuffer
.ExtendableProtocolMessage
31 _extension_runtime
= False
32 _ExtendableProtocolMessage
= ProtocolBuffer
.ProtocolMessage
34 from google
.appengine
.datastore
.acl_pb
import *
35 import google
.appengine
.datastore
.acl_pb
36 class FieldValue_Geo(ProtocolBuffer
.ProtocolMessage
):
42 def __init__(self
, contents
=None):
43 if contents
is not None: self
.MergeFromString(contents
)
45 def lat(self
): return self
.lat_
56 def has_lat(self
): return self
.has_lat_
58 def lng(self
): return self
.lng_
69 def has_lng(self
): return self
.has_lng_
72 def MergeFrom(self
, x
):
74 if (x
.has_lat()): self
.set_lat(x
.lat())
75 if (x
.has_lng()): self
.set_lng(x
.lng())
78 if x
is self
: return 1
79 if self
.has_lat_
!= x
.has_lat_
: return 0
80 if self
.has_lat_
and self
.lat_
!= x
.lat_
: return 0
81 if self
.has_lng_
!= x
.has_lng_
: return 0
82 if self
.has_lng_
and self
.lng_
!= x
.lng_
: return 0
85 def IsInitialized(self
, debug_strs
=None):
87 if (not self
.has_lat_
):
89 if debug_strs
is not None:
90 debug_strs
.append('Required field: lat not set.')
91 if (not self
.has_lng_
):
93 if debug_strs
is not None:
94 debug_strs
.append('Required field: lng not set.')
101 def ByteSizePartial(self
):
113 def OutputUnchecked(self
, out
):
115 out
.putDouble(self
.lat_
)
117 out
.putDouble(self
.lng_
)
119 def OutputPartial(self
, out
):
122 out
.putDouble(self
.lat_
)
125 out
.putDouble(self
.lng_
)
127 def TryMerge(self
, d
):
132 self
.set_lat(d
.getDouble())
135 self
.set_lng(d
.getDouble())
139 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
143 def __str__(self
, prefix
="", printElemNumber
=0):
145 if self
.has_lat_
: res
+=prefix
+("lat: %s\n" % self
.DebugFormat(self
.lat_
))
146 if self
.has_lng_
: res
+=prefix
+("lng: %s\n" % self
.DebugFormat(self
.lng_
))
149 class FieldValue(ProtocolBuffer
.ProtocolMessage
):
159 _ContentType_NAMES
= {
168 def ContentType_Name(cls
, x
): return cls
._ContentType
_NAMES
.get(x
, "")
169 ContentType_Name
= classmethod(ContentType_Name
)
175 has_string_value_
= 0
180 def __init__(self
, contents
=None):
181 self
.lazy_init_lock_
= thread
.allocate_lock()
182 if contents
is not None: self
.MergeFromString(contents
)
184 def type(self
): return self
.type_
186 def set_type(self
, x
):
190 def clear_type(self
):
195 def has_type(self
): return self
.has_type_
197 def language(self
): return self
.language_
199 def set_language(self
, x
):
200 self
.has_language_
= 1
203 def clear_language(self
):
204 if self
.has_language_
:
205 self
.has_language_
= 0
206 self
.language_
= "en"
208 def has_language(self
): return self
.has_language_
210 def string_value(self
): return self
.string_value_
212 def set_string_value(self
, x
):
213 self
.has_string_value_
= 1
214 self
.string_value_
= x
216 def clear_string_value(self
):
217 if self
.has_string_value_
:
218 self
.has_string_value_
= 0
219 self
.string_value_
= ""
221 def has_string_value(self
): return self
.has_string_value_
224 if self
.geo_
is None:
225 self
.lazy_init_lock_
.acquire()
227 if self
.geo_
is None: self
.geo_
= FieldValue_Geo()
229 self
.lazy_init_lock_
.release()
232 def mutable_geo(self
): self
.has_geo_
= 1; return self
.geo()
238 if self
.geo_
is not None: self
.geo_
.Clear()
240 def has_geo(self
): return self
.has_geo_
243 def MergeFrom(self
, x
):
245 if (x
.has_type()): self
.set_type(x
.type())
246 if (x
.has_language()): self
.set_language(x
.language())
247 if (x
.has_string_value()): self
.set_string_value(x
.string_value())
248 if (x
.has_geo()): self
.mutable_geo().MergeFrom(x
.geo())
251 if x
is self
: return 1
252 if self
.has_type_
!= x
.has_type_
: return 0
253 if self
.has_type_
and self
.type_
!= x
.type_
: return 0
254 if self
.has_language_
!= x
.has_language_
: return 0
255 if self
.has_language_
and self
.language_
!= x
.language_
: return 0
256 if self
.has_string_value_
!= x
.has_string_value_
: return 0
257 if self
.has_string_value_
and self
.string_value_
!= x
.string_value_
: return 0
258 if self
.has_geo_
!= x
.has_geo_
: return 0
259 if self
.has_geo_
and self
.geo_
!= x
.geo_
: return 0
262 def IsInitialized(self
, debug_strs
=None):
264 if (self
.has_geo_
and not self
.geo_
.IsInitialized(debug_strs
)): initialized
= 0
269 if (self
.has_type_
): n
+= 1 + self
.lengthVarInt64(self
.type_
)
270 if (self
.has_language_
): n
+= 1 + self
.lengthString(len(self
.language_
))
271 if (self
.has_string_value_
): n
+= 1 + self
.lengthString(len(self
.string_value_
))
272 if (self
.has_geo_
): n
+= 2 + self
.geo_
.ByteSize()
275 def ByteSizePartial(self
):
277 if (self
.has_type_
): n
+= 1 + self
.lengthVarInt64(self
.type_
)
278 if (self
.has_language_
): n
+= 1 + self
.lengthString(len(self
.language_
))
279 if (self
.has_string_value_
): n
+= 1 + self
.lengthString(len(self
.string_value_
))
280 if (self
.has_geo_
): n
+= 2 + self
.geo_
.ByteSizePartial()
285 self
.clear_language()
286 self
.clear_string_value()
289 def OutputUnchecked(self
, out
):
292 out
.putVarInt32(self
.type_
)
293 if (self
.has_language_
):
295 out
.putPrefixedString(self
.language_
)
296 if (self
.has_string_value_
):
298 out
.putPrefixedString(self
.string_value_
)
301 self
.geo_
.OutputUnchecked(out
)
304 def OutputPartial(self
, out
):
307 out
.putVarInt32(self
.type_
)
308 if (self
.has_language_
):
310 out
.putPrefixedString(self
.language_
)
311 if (self
.has_string_value_
):
313 out
.putPrefixedString(self
.string_value_
)
316 self
.geo_
.OutputPartial(out
)
319 def TryMerge(self
, d
):
323 self
.set_type(d
.getVarInt32())
326 self
.set_language(d
.getPrefixedString())
329 self
.set_string_value(d
.getPrefixedString())
332 self
.mutable_geo().TryMerge(d
)
336 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
340 def __str__(self
, prefix
="", printElemNumber
=0):
342 if self
.has_type_
: res
+=prefix
+("type: %s\n" % self
.DebugFormatInt32(self
.type_
))
343 if self
.has_language_
: res
+=prefix
+("language: %s\n" % self
.DebugFormatString(self
.language_
))
344 if self
.has_string_value_
: res
+=prefix
+("string_value: %s\n" % self
.DebugFormatString(self
.string_value_
))
346 res
+=prefix
+"Geo {\n"
347 res
+=self
.geo_
.__str
__(prefix
+ " ", printElemNumber
)
352 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
353 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
362 _TEXT
= _BuildTagLookupTable({
372 _TYPES
= _BuildTagLookupTable({
373 0: ProtocolBuffer
.Encoder
.NUMERIC
,
374 1: ProtocolBuffer
.Encoder
.NUMERIC
,
375 2: ProtocolBuffer
.Encoder
.STRING
,
376 3: ProtocolBuffer
.Encoder
.STRING
,
377 4: ProtocolBuffer
.Encoder
.STARTGROUP
,
378 5: ProtocolBuffer
.Encoder
.DOUBLE
,
379 6: ProtocolBuffer
.Encoder
.DOUBLE
,
380 }, 6, ProtocolBuffer
.Encoder
.MAX_TYPE
)
384 _STYLE_CONTENT_TYPE
= """"""
385 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.FieldValue'
386 class Field(ProtocolBuffer
.ProtocolMessage
):
391 def __init__(self
, contents
=None):
392 self
.value_
= FieldValue()
393 if contents
is not None: self
.MergeFromString(contents
)
395 def name(self
): return self
.name_
397 def set_name(self
, x
):
401 def clear_name(self
):
406 def has_name(self
): return self
.has_name_
408 def value(self
): return self
.value_
410 def mutable_value(self
): self
.has_value_
= 1; return self
.value_
412 def clear_value(self
):self
.has_value_
= 0; self
.value_
.Clear()
414 def has_value(self
): return self
.has_value_
417 def MergeFrom(self
, x
):
419 if (x
.has_name()): self
.set_name(x
.name())
420 if (x
.has_value()): self
.mutable_value().MergeFrom(x
.value())
423 if x
is self
: return 1
424 if self
.has_name_
!= x
.has_name_
: return 0
425 if self
.has_name_
and self
.name_
!= x
.name_
: return 0
426 if self
.has_value_
!= x
.has_value_
: return 0
427 if self
.has_value_
and self
.value_
!= x
.value_
: return 0
430 def IsInitialized(self
, debug_strs
=None):
432 if (not self
.has_name_
):
434 if debug_strs
is not None:
435 debug_strs
.append('Required field: name not set.')
436 if (not self
.has_value_
):
438 if debug_strs
is not None:
439 debug_strs
.append('Required field: value not set.')
440 elif not self
.value_
.IsInitialized(debug_strs
): initialized
= 0
445 n
+= self
.lengthString(len(self
.name_
))
446 n
+= self
.lengthString(self
.value_
.ByteSize())
449 def ByteSizePartial(self
):
453 n
+= self
.lengthString(len(self
.name_
))
454 if (self
.has_value_
):
456 n
+= self
.lengthString(self
.value_
.ByteSizePartial())
463 def OutputUnchecked(self
, out
):
465 out
.putPrefixedString(self
.name_
)
467 out
.putVarInt32(self
.value_
.ByteSize())
468 self
.value_
.OutputUnchecked(out
)
470 def OutputPartial(self
, out
):
473 out
.putPrefixedString(self
.name_
)
474 if (self
.has_value_
):
476 out
.putVarInt32(self
.value_
.ByteSizePartial())
477 self
.value_
.OutputPartial(out
)
479 def TryMerge(self
, d
):
483 self
.set_name(d
.getPrefixedString())
486 length
= d
.getVarInt32()
487 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
489 self
.mutable_value().TryMerge(tmp
)
493 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
497 def __str__(self
, prefix
="", printElemNumber
=0):
499 if self
.has_name_
: res
+=prefix
+("name: %s\n" % self
.DebugFormatString(self
.name_
))
501 res
+=prefix
+"value <\n"
502 res
+=self
.value_
.__str
__(prefix
+ " ", printElemNumber
)
507 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
508 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
513 _TEXT
= _BuildTagLookupTable({
519 _TYPES
= _BuildTagLookupTable({
520 0: ProtocolBuffer
.Encoder
.NUMERIC
,
521 1: ProtocolBuffer
.Encoder
.STRING
,
522 2: ProtocolBuffer
.Encoder
.STRING
,
523 }, 2, ProtocolBuffer
.Encoder
.MAX_TYPE
)
527 _STYLE_CONTENT_TYPE
= """"""
528 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.Field'
529 class FieldTypes(ProtocolBuffer
.ProtocolMessage
):
533 def __init__(self
, contents
=None):
535 if contents
is not None: self
.MergeFromString(contents
)
537 def name(self
): return self
.name_
539 def set_name(self
, x
):
543 def clear_name(self
):
548 def has_name(self
): return self
.has_name_
550 def type_size(self
): return len(self
.type_
)
551 def type_list(self
): return self
.type_
556 def set_type(self
, i
, x
):
559 def add_type(self
, x
):
562 def clear_type(self
):
566 def MergeFrom(self
, x
):
568 if (x
.has_name()): self
.set_name(x
.name())
569 for i
in xrange(x
.type_size()): self
.add_type(x
.type(i
))
572 if x
is self
: return 1
573 if self
.has_name_
!= x
.has_name_
: return 0
574 if self
.has_name_
and self
.name_
!= x
.name_
: return 0
575 if len(self
.type_
) != len(x
.type_
): return 0
576 for e1
, e2
in zip(self
.type_
, x
.type_
):
577 if e1
!= e2
: return 0
580 def IsInitialized(self
, debug_strs
=None):
582 if (not self
.has_name_
):
584 if debug_strs
is not None:
585 debug_strs
.append('Required field: name not set.')
590 n
+= self
.lengthString(len(self
.name_
))
591 n
+= 1 * len(self
.type_
)
592 for i
in xrange(len(self
.type_
)): n
+= self
.lengthVarInt64(self
.type_
[i
])
595 def ByteSizePartial(self
):
599 n
+= self
.lengthString(len(self
.name_
))
600 n
+= 1 * len(self
.type_
)
601 for i
in xrange(len(self
.type_
)): n
+= self
.lengthVarInt64(self
.type_
[i
])
608 def OutputUnchecked(self
, out
):
610 out
.putPrefixedString(self
.name_
)
611 for i
in xrange(len(self
.type_
)):
613 out
.putVarInt32(self
.type_
[i
])
615 def OutputPartial(self
, out
):
618 out
.putPrefixedString(self
.name_
)
619 for i
in xrange(len(self
.type_
)):
621 out
.putVarInt32(self
.type_
[i
])
623 def TryMerge(self
, d
):
627 self
.set_name(d
.getPrefixedString())
630 self
.add_type(d
.getVarInt32())
634 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
638 def __str__(self
, prefix
="", printElemNumber
=0):
640 if self
.has_name_
: res
+=prefix
+("name: %s\n" % self
.DebugFormatString(self
.name_
))
644 if printElemNumber
: elm
="(%d)" % cnt
645 res
+=prefix
+("type%s: %s\n" % (elm
, self
.DebugFormatInt32(e
)))
650 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
651 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
656 _TEXT
= _BuildTagLookupTable({
662 _TYPES
= _BuildTagLookupTable({
663 0: ProtocolBuffer
.Encoder
.NUMERIC
,
664 1: ProtocolBuffer
.Encoder
.STRING
,
665 2: ProtocolBuffer
.Encoder
.NUMERIC
,
666 }, 2, ProtocolBuffer
.Encoder
.MAX_TYPE
)
670 _STYLE_CONTENT_TYPE
= """"""
671 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.FieldTypes'
672 class IndexMetadata(ProtocolBuffer
.ProtocolMessage
):
673 has_is_over_field_number_threshold_
= 0
674 is_over_field_number_threshold_
= 0
676 def __init__(self
, contents
=None):
677 if contents
is not None: self
.MergeFromString(contents
)
679 def is_over_field_number_threshold(self
): return self
.is_over_field_number_threshold_
681 def set_is_over_field_number_threshold(self
, x
):
682 self
.has_is_over_field_number_threshold_
= 1
683 self
.is_over_field_number_threshold_
= x
685 def clear_is_over_field_number_threshold(self
):
686 if self
.has_is_over_field_number_threshold_
:
687 self
.has_is_over_field_number_threshold_
= 0
688 self
.is_over_field_number_threshold_
= 0
690 def has_is_over_field_number_threshold(self
): return self
.has_is_over_field_number_threshold_
693 def MergeFrom(self
, x
):
695 if (x
.has_is_over_field_number_threshold()): self
.set_is_over_field_number_threshold(x
.is_over_field_number_threshold())
698 if x
is self
: return 1
699 if self
.has_is_over_field_number_threshold_
!= x
.has_is_over_field_number_threshold_
: return 0
700 if self
.has_is_over_field_number_threshold_
and self
.is_over_field_number_threshold_
!= x
.is_over_field_number_threshold_
: return 0
703 def IsInitialized(self
, debug_strs
=None):
709 if (self
.has_is_over_field_number_threshold_
): n
+= 2
712 def ByteSizePartial(self
):
714 if (self
.has_is_over_field_number_threshold_
): n
+= 2
718 self
.clear_is_over_field_number_threshold()
720 def OutputUnchecked(self
, out
):
721 if (self
.has_is_over_field_number_threshold_
):
723 out
.putBoolean(self
.is_over_field_number_threshold_
)
725 def OutputPartial(self
, out
):
726 if (self
.has_is_over_field_number_threshold_
):
728 out
.putBoolean(self
.is_over_field_number_threshold_
)
730 def TryMerge(self
, d
):
734 self
.set_is_over_field_number_threshold(d
.getBoolean())
738 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
742 def __str__(self
, prefix
="", printElemNumber
=0):
744 if self
.has_is_over_field_number_threshold_
: res
+=prefix
+("is_over_field_number_threshold: %s\n" % self
.DebugFormatBool(self
.is_over_field_number_threshold_
))
748 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
749 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
751 kis_over_field_number_threshold
= 1
753 _TEXT
= _BuildTagLookupTable({
755 1: "is_over_field_number_threshold",
758 _TYPES
= _BuildTagLookupTable({
759 0: ProtocolBuffer
.Encoder
.NUMERIC
,
760 1: ProtocolBuffer
.Encoder
.NUMERIC
,
761 }, 1, ProtocolBuffer
.Encoder
.MAX_TYPE
)
765 _STYLE_CONTENT_TYPE
= """"""
766 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.IndexMetadata'
767 class FacetValue(ProtocolBuffer
.ProtocolMessage
):
773 _ContentType_NAMES
= {
778 def ContentType_Name(cls
, x
): return cls
._ContentType
_NAMES
.get(x
, "")
779 ContentType_Name
= classmethod(ContentType_Name
)
783 has_string_value_
= 0
786 def __init__(self
, contents
=None):
787 if contents
is not None: self
.MergeFromString(contents
)
789 def type(self
): return self
.type_
791 def set_type(self
, x
):
795 def clear_type(self
):
800 def has_type(self
): return self
.has_type_
802 def string_value(self
): return self
.string_value_
804 def set_string_value(self
, x
):
805 self
.has_string_value_
= 1
806 self
.string_value_
= x
808 def clear_string_value(self
):
809 if self
.has_string_value_
:
810 self
.has_string_value_
= 0
811 self
.string_value_
= ""
813 def has_string_value(self
): return self
.has_string_value_
816 def MergeFrom(self
, x
):
818 if (x
.has_type()): self
.set_type(x
.type())
819 if (x
.has_string_value()): self
.set_string_value(x
.string_value())
822 if x
is self
: return 1
823 if self
.has_type_
!= x
.has_type_
: return 0
824 if self
.has_type_
and self
.type_
!= x
.type_
: return 0
825 if self
.has_string_value_
!= x
.has_string_value_
: return 0
826 if self
.has_string_value_
and self
.string_value_
!= x
.string_value_
: return 0
829 def IsInitialized(self
, debug_strs
=None):
835 if (self
.has_type_
): n
+= 1 + self
.lengthVarInt64(self
.type_
)
836 if (self
.has_string_value_
): n
+= 1 + self
.lengthString(len(self
.string_value_
))
839 def ByteSizePartial(self
):
841 if (self
.has_type_
): n
+= 1 + self
.lengthVarInt64(self
.type_
)
842 if (self
.has_string_value_
): n
+= 1 + self
.lengthString(len(self
.string_value_
))
847 self
.clear_string_value()
849 def OutputUnchecked(self
, out
):
852 out
.putVarInt32(self
.type_
)
853 if (self
.has_string_value_
):
855 out
.putPrefixedString(self
.string_value_
)
857 def OutputPartial(self
, out
):
860 out
.putVarInt32(self
.type_
)
861 if (self
.has_string_value_
):
863 out
.putPrefixedString(self
.string_value_
)
865 def TryMerge(self
, d
):
869 self
.set_type(d
.getVarInt32())
872 self
.set_string_value(d
.getPrefixedString())
876 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
880 def __str__(self
, prefix
="", printElemNumber
=0):
882 if self
.has_type_
: res
+=prefix
+("type: %s\n" % self
.DebugFormatInt32(self
.type_
))
883 if self
.has_string_value_
: res
+=prefix
+("string_value: %s\n" % self
.DebugFormatString(self
.string_value_
))
887 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
888 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
893 _TEXT
= _BuildTagLookupTable({
899 _TYPES
= _BuildTagLookupTable({
900 0: ProtocolBuffer
.Encoder
.NUMERIC
,
901 1: ProtocolBuffer
.Encoder
.NUMERIC
,
902 3: ProtocolBuffer
.Encoder
.STRING
,
903 }, 3, ProtocolBuffer
.Encoder
.MAX_TYPE
)
907 _STYLE_CONTENT_TYPE
= """"""
908 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.FacetValue'
909 class Facet(ProtocolBuffer
.ProtocolMessage
):
914 def __init__(self
, contents
=None):
915 self
.value_
= FacetValue()
916 if contents
is not None: self
.MergeFromString(contents
)
918 def name(self
): return self
.name_
920 def set_name(self
, x
):
924 def clear_name(self
):
929 def has_name(self
): return self
.has_name_
931 def value(self
): return self
.value_
933 def mutable_value(self
): self
.has_value_
= 1; return self
.value_
935 def clear_value(self
):self
.has_value_
= 0; self
.value_
.Clear()
937 def has_value(self
): return self
.has_value_
940 def MergeFrom(self
, x
):
942 if (x
.has_name()): self
.set_name(x
.name())
943 if (x
.has_value()): self
.mutable_value().MergeFrom(x
.value())
946 if x
is self
: return 1
947 if self
.has_name_
!= x
.has_name_
: return 0
948 if self
.has_name_
and self
.name_
!= x
.name_
: return 0
949 if self
.has_value_
!= x
.has_value_
: return 0
950 if self
.has_value_
and self
.value_
!= x
.value_
: return 0
953 def IsInitialized(self
, debug_strs
=None):
955 if (not self
.has_name_
):
957 if debug_strs
is not None:
958 debug_strs
.append('Required field: name not set.')
959 if (not self
.has_value_
):
961 if debug_strs
is not None:
962 debug_strs
.append('Required field: value not set.')
963 elif not self
.value_
.IsInitialized(debug_strs
): initialized
= 0
968 n
+= self
.lengthString(len(self
.name_
))
969 n
+= self
.lengthString(self
.value_
.ByteSize())
972 def ByteSizePartial(self
):
976 n
+= self
.lengthString(len(self
.name_
))
977 if (self
.has_value_
):
979 n
+= self
.lengthString(self
.value_
.ByteSizePartial())
986 def OutputUnchecked(self
, out
):
988 out
.putPrefixedString(self
.name_
)
990 out
.putVarInt32(self
.value_
.ByteSize())
991 self
.value_
.OutputUnchecked(out
)
993 def OutputPartial(self
, out
):
996 out
.putPrefixedString(self
.name_
)
997 if (self
.has_value_
):
999 out
.putVarInt32(self
.value_
.ByteSizePartial())
1000 self
.value_
.OutputPartial(out
)
1002 def TryMerge(self
, d
):
1003 while d
.avail() > 0:
1004 tt
= d
.getVarInt32()
1006 self
.set_name(d
.getPrefixedString())
1009 length
= d
.getVarInt32()
1010 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1012 self
.mutable_value().TryMerge(tmp
)
1016 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1020 def __str__(self
, prefix
="", printElemNumber
=0):
1022 if self
.has_name_
: res
+=prefix
+("name: %s\n" % self
.DebugFormatString(self
.name_
))
1024 res
+=prefix
+"value <\n"
1025 res
+=self
.value_
.__str
__(prefix
+ " ", printElemNumber
)
1030 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
1031 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
1036 _TEXT
= _BuildTagLookupTable({
1042 _TYPES
= _BuildTagLookupTable({
1043 0: ProtocolBuffer
.Encoder
.NUMERIC
,
1044 1: ProtocolBuffer
.Encoder
.STRING
,
1045 2: ProtocolBuffer
.Encoder
.STRING
,
1046 }, 2, ProtocolBuffer
.Encoder
.MAX_TYPE
)
1050 _STYLE_CONTENT_TYPE
= """"""
1051 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.Facet'
1052 class DocumentMetadata(ProtocolBuffer
.ProtocolMessage
):
1056 def __init__(self
, contents
=None):
1057 if contents
is not None: self
.MergeFromString(contents
)
1059 def version(self
): return self
.version_
1061 def set_version(self
, x
):
1062 self
.has_version_
= 1
1065 def clear_version(self
):
1066 if self
.has_version_
:
1067 self
.has_version_
= 0
1070 def has_version(self
): return self
.has_version_
1073 def MergeFrom(self
, x
):
1074 assert x
is not self
1075 if (x
.has_version()): self
.set_version(x
.version())
1077 def Equals(self
, x
):
1078 if x
is self
: return 1
1079 if self
.has_version_
!= x
.has_version_
: return 0
1080 if self
.has_version_
and self
.version_
!= x
.version_
: return 0
1083 def IsInitialized(self
, debug_strs
=None):
1089 if (self
.has_version_
): n
+= 1 + self
.lengthVarInt64(self
.version_
)
1092 def ByteSizePartial(self
):
1094 if (self
.has_version_
): n
+= 1 + self
.lengthVarInt64(self
.version_
)
1098 self
.clear_version()
1100 def OutputUnchecked(self
, out
):
1101 if (self
.has_version_
):
1103 out
.putVarInt64(self
.version_
)
1105 def OutputPartial(self
, out
):
1106 if (self
.has_version_
):
1108 out
.putVarInt64(self
.version_
)
1110 def TryMerge(self
, d
):
1111 while d
.avail() > 0:
1112 tt
= d
.getVarInt32()
1114 self
.set_version(d
.getVarInt64())
1118 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1122 def __str__(self
, prefix
="", printElemNumber
=0):
1124 if self
.has_version_
: res
+=prefix
+("version: %s\n" % self
.DebugFormatInt64(self
.version_
))
1128 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
1129 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
1133 _TEXT
= _BuildTagLookupTable({
1138 _TYPES
= _BuildTagLookupTable({
1139 0: ProtocolBuffer
.Encoder
.NUMERIC
,
1140 1: ProtocolBuffer
.Encoder
.NUMERIC
,
1141 }, 1, ProtocolBuffer
.Encoder
.MAX_TYPE
)
1145 _STYLE_CONTENT_TYPE
= """"""
1146 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.DocumentMetadata'
1147 class Document(ProtocolBuffer
.ProtocolMessage
):
1156 def Storage_Name(cls
, x
): return cls
._Storage
_NAMES
.get(x
, "")
1157 Storage_Name
= classmethod(Storage_Name
)
1170 def __init__(self
, contents
=None):
1173 self
.lazy_init_lock_
= thread
.allocate_lock()
1174 if contents
is not None: self
.MergeFromString(contents
)
1176 def id(self
): return self
.id_
1178 def set_id(self
, x
):
1187 def has_id(self
): return self
.has_id_
1189 def language(self
): return self
.language_
1191 def set_language(self
, x
):
1192 self
.has_language_
= 1
1195 def clear_language(self
):
1196 if self
.has_language_
:
1197 self
.has_language_
= 0
1198 self
.language_
= "en"
1200 def has_language(self
): return self
.has_language_
1202 def field_size(self
): return len(self
.field_
)
1203 def field_list(self
): return self
.field_
1206 return self
.field_
[i
]
1208 def mutable_field(self
, i
):
1209 return self
.field_
[i
]
1211 def add_field(self
):
1213 self
.field_
.append(x
)
1216 def clear_field(self
):
1218 def order_id(self
): return self
.order_id_
1220 def set_order_id(self
, x
):
1221 self
.has_order_id_
= 1
1224 def clear_order_id(self
):
1225 if self
.has_order_id_
:
1226 self
.has_order_id_
= 0
1229 def has_order_id(self
): return self
.has_order_id_
1231 def storage(self
): return self
.storage_
1233 def set_storage(self
, x
):
1234 self
.has_storage_
= 1
1237 def clear_storage(self
):
1238 if self
.has_storage_
:
1239 self
.has_storage_
= 0
1242 def has_storage(self
): return self
.has_storage_
1245 if self
.acl_
is None:
1246 self
.lazy_init_lock_
.acquire()
1248 if self
.acl_
is None: self
.acl_
= AccessControlList()
1250 self
.lazy_init_lock_
.release()
1253 def mutable_acl(self
): self
.has_acl_
= 1; return self
.acl()
1255 def clear_acl(self
):
1259 if self
.acl_
is not None: self
.acl_
.Clear()
1261 def has_acl(self
): return self
.has_acl_
1263 def facet_size(self
): return len(self
.facet_
)
1264 def facet_list(self
): return self
.facet_
1267 return self
.facet_
[i
]
1269 def mutable_facet(self
, i
):
1270 return self
.facet_
[i
]
1272 def add_facet(self
):
1274 self
.facet_
.append(x
)
1277 def clear_facet(self
):
1280 def MergeFrom(self
, x
):
1281 assert x
is not self
1282 if (x
.has_id()): self
.set_id(x
.id())
1283 if (x
.has_language()): self
.set_language(x
.language())
1284 for i
in xrange(x
.field_size()): self
.add_field().CopyFrom(x
.field(i
))
1285 if (x
.has_order_id()): self
.set_order_id(x
.order_id())
1286 if (x
.has_storage()): self
.set_storage(x
.storage())
1287 if (x
.has_acl()): self
.mutable_acl().MergeFrom(x
.acl())
1288 for i
in xrange(x
.facet_size()): self
.add_facet().CopyFrom(x
.facet(i
))
1290 def Equals(self
, x
):
1291 if x
is self
: return 1
1292 if self
.has_id_
!= x
.has_id_
: return 0
1293 if self
.has_id_
and self
.id_
!= x
.id_
: return 0
1294 if self
.has_language_
!= x
.has_language_
: return 0
1295 if self
.has_language_
and self
.language_
!= x
.language_
: return 0
1296 if len(self
.field_
) != len(x
.field_
): return 0
1297 for e1
, e2
in zip(self
.field_
, x
.field_
):
1298 if e1
!= e2
: return 0
1299 if self
.has_order_id_
!= x
.has_order_id_
: return 0
1300 if self
.has_order_id_
and self
.order_id_
!= x
.order_id_
: return 0
1301 if self
.has_storage_
!= x
.has_storage_
: return 0
1302 if self
.has_storage_
and self
.storage_
!= x
.storage_
: return 0
1303 if self
.has_acl_
!= x
.has_acl_
: return 0
1304 if self
.has_acl_
and self
.acl_
!= x
.acl_
: return 0
1305 if len(self
.facet_
) != len(x
.facet_
): return 0
1306 for e1
, e2
in zip(self
.facet_
, x
.facet_
):
1307 if e1
!= e2
: return 0
1310 def IsInitialized(self
, debug_strs
=None):
1312 for p
in self
.field_
:
1313 if not p
.IsInitialized(debug_strs
): initialized
=0
1314 if (self
.has_acl_
and not self
.acl_
.IsInitialized(debug_strs
)): initialized
= 0
1315 for p
in self
.facet_
:
1316 if not p
.IsInitialized(debug_strs
): initialized
=0
1321 if (self
.has_id_
): n
+= 1 + self
.lengthString(len(self
.id_
))
1322 if (self
.has_language_
): n
+= 1 + self
.lengthString(len(self
.language_
))
1323 n
+= 1 * len(self
.field_
)
1324 for i
in xrange(len(self
.field_
)): n
+= self
.lengthString(self
.field_
[i
].ByteSize())
1325 if (self
.has_order_id_
): n
+= 1 + self
.lengthVarInt64(self
.order_id_
)
1326 if (self
.has_storage_
): n
+= 1 + self
.lengthVarInt64(self
.storage_
)
1327 if (self
.has_acl_
): n
+= 1 + self
.lengthString(self
.acl_
.ByteSize())
1328 n
+= 1 * len(self
.facet_
)
1329 for i
in xrange(len(self
.facet_
)): n
+= self
.lengthString(self
.facet_
[i
].ByteSize())
1332 def ByteSizePartial(self
):
1334 if (self
.has_id_
): n
+= 1 + self
.lengthString(len(self
.id_
))
1335 if (self
.has_language_
): n
+= 1 + self
.lengthString(len(self
.language_
))
1336 n
+= 1 * len(self
.field_
)
1337 for i
in xrange(len(self
.field_
)): n
+= self
.lengthString(self
.field_
[i
].ByteSizePartial())
1338 if (self
.has_order_id_
): n
+= 1 + self
.lengthVarInt64(self
.order_id_
)
1339 if (self
.has_storage_
): n
+= 1 + self
.lengthVarInt64(self
.storage_
)
1340 if (self
.has_acl_
): n
+= 1 + self
.lengthString(self
.acl_
.ByteSizePartial())
1341 n
+= 1 * len(self
.facet_
)
1342 for i
in xrange(len(self
.facet_
)): n
+= self
.lengthString(self
.facet_
[i
].ByteSizePartial())
1347 self
.clear_language()
1349 self
.clear_order_id()
1350 self
.clear_storage()
1354 def OutputUnchecked(self
, out
):
1357 out
.putPrefixedString(self
.id_
)
1358 if (self
.has_language_
):
1360 out
.putPrefixedString(self
.language_
)
1361 for i
in xrange(len(self
.field_
)):
1363 out
.putVarInt32(self
.field_
[i
].ByteSize())
1364 self
.field_
[i
].OutputUnchecked(out
)
1365 if (self
.has_order_id_
):
1367 out
.putVarInt32(self
.order_id_
)
1368 if (self
.has_storage_
):
1370 out
.putVarInt32(self
.storage_
)
1373 out
.putVarInt32(self
.acl_
.ByteSize())
1374 self
.acl_
.OutputUnchecked(out
)
1375 for i
in xrange(len(self
.facet_
)):
1377 out
.putVarInt32(self
.facet_
[i
].ByteSize())
1378 self
.facet_
[i
].OutputUnchecked(out
)
1380 def OutputPartial(self
, out
):
1383 out
.putPrefixedString(self
.id_
)
1384 if (self
.has_language_
):
1386 out
.putPrefixedString(self
.language_
)
1387 for i
in xrange(len(self
.field_
)):
1389 out
.putVarInt32(self
.field_
[i
].ByteSizePartial())
1390 self
.field_
[i
].OutputPartial(out
)
1391 if (self
.has_order_id_
):
1393 out
.putVarInt32(self
.order_id_
)
1394 if (self
.has_storage_
):
1396 out
.putVarInt32(self
.storage_
)
1399 out
.putVarInt32(self
.acl_
.ByteSizePartial())
1400 self
.acl_
.OutputPartial(out
)
1401 for i
in xrange(len(self
.facet_
)):
1403 out
.putVarInt32(self
.facet_
[i
].ByteSizePartial())
1404 self
.facet_
[i
].OutputPartial(out
)
1406 def TryMerge(self
, d
):
1407 while d
.avail() > 0:
1408 tt
= d
.getVarInt32()
1410 self
.set_id(d
.getPrefixedString())
1413 self
.set_language(d
.getPrefixedString())
1416 length
= d
.getVarInt32()
1417 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1419 self
.add_field().TryMerge(tmp
)
1422 self
.set_order_id(d
.getVarInt32())
1425 self
.set_storage(d
.getVarInt32())
1428 length
= d
.getVarInt32()
1429 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1431 self
.mutable_acl().TryMerge(tmp
)
1434 length
= d
.getVarInt32()
1435 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1437 self
.add_facet().TryMerge(tmp
)
1441 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1445 def __str__(self
, prefix
="", printElemNumber
=0):
1447 if self
.has_id_
: res
+=prefix
+("id: %s\n" % self
.DebugFormatString(self
.id_
))
1448 if self
.has_language_
: res
+=prefix
+("language: %s\n" % self
.DebugFormatString(self
.language_
))
1450 for e
in self
.field_
:
1452 if printElemNumber
: elm
="(%d)" % cnt
1453 res
+=prefix
+("field%s <\n" % elm
)
1454 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
1457 if self
.has_order_id_
: res
+=prefix
+("order_id: %s\n" % self
.DebugFormatInt32(self
.order_id_
))
1458 if self
.has_storage_
: res
+=prefix
+("storage: %s\n" % self
.DebugFormatInt32(self
.storage_
))
1460 res
+=prefix
+"acl <\n"
1461 res
+=self
.acl_
.__str
__(prefix
+ " ", printElemNumber
)
1464 for e
in self
.facet_
:
1466 if printElemNumber
: elm
="(%d)" % cnt
1467 res
+=prefix
+("facet%s <\n" % elm
)
1468 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
1474 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
1475 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
1485 _TEXT
= _BuildTagLookupTable({
1496 _TYPES
= _BuildTagLookupTable({
1497 0: ProtocolBuffer
.Encoder
.NUMERIC
,
1498 1: ProtocolBuffer
.Encoder
.STRING
,
1499 2: ProtocolBuffer
.Encoder
.STRING
,
1500 3: ProtocolBuffer
.Encoder
.STRING
,
1501 4: ProtocolBuffer
.Encoder
.NUMERIC
,
1502 5: ProtocolBuffer
.Encoder
.NUMERIC
,
1503 6: ProtocolBuffer
.Encoder
.STRING
,
1504 8: ProtocolBuffer
.Encoder
.STRING
,
1505 }, 8, ProtocolBuffer
.Encoder
.MAX_TYPE
)
1509 _STYLE_CONTENT_TYPE
= """"""
1510 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.Document'
1511 if _extension_runtime
:
1514 __all__
= ['FieldValue','FieldValue_Geo','Field','FieldTypes','IndexMetadata','FacetValue','Facet','DocumentMetadata','Document']