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 FacetValue(ProtocolBuffer
.ProtocolMessage
):
678 _ContentType_NAMES
= {
683 def ContentType_Name(cls
, x
): return cls
._ContentType
_NAMES
.get(x
, "")
684 ContentType_Name
= classmethod(ContentType_Name
)
688 has_string_value_
= 0
691 def __init__(self
, contents
=None):
692 if contents
is not None: self
.MergeFromString(contents
)
694 def type(self
): return self
.type_
696 def set_type(self
, x
):
700 def clear_type(self
):
705 def has_type(self
): return self
.has_type_
707 def string_value(self
): return self
.string_value_
709 def set_string_value(self
, x
):
710 self
.has_string_value_
= 1
711 self
.string_value_
= x
713 def clear_string_value(self
):
714 if self
.has_string_value_
:
715 self
.has_string_value_
= 0
716 self
.string_value_
= ""
718 def has_string_value(self
): return self
.has_string_value_
721 def MergeFrom(self
, x
):
723 if (x
.has_type()): self
.set_type(x
.type())
724 if (x
.has_string_value()): self
.set_string_value(x
.string_value())
727 if x
is self
: return 1
728 if self
.has_type_
!= x
.has_type_
: return 0
729 if self
.has_type_
and self
.type_
!= x
.type_
: return 0
730 if self
.has_string_value_
!= x
.has_string_value_
: return 0
731 if self
.has_string_value_
and self
.string_value_
!= x
.string_value_
: return 0
734 def IsInitialized(self
, debug_strs
=None):
740 if (self
.has_type_
): n
+= 1 + self
.lengthVarInt64(self
.type_
)
741 if (self
.has_string_value_
): n
+= 1 + self
.lengthString(len(self
.string_value_
))
744 def ByteSizePartial(self
):
746 if (self
.has_type_
): n
+= 1 + self
.lengthVarInt64(self
.type_
)
747 if (self
.has_string_value_
): n
+= 1 + self
.lengthString(len(self
.string_value_
))
752 self
.clear_string_value()
754 def OutputUnchecked(self
, out
):
757 out
.putVarInt32(self
.type_
)
758 if (self
.has_string_value_
):
760 out
.putPrefixedString(self
.string_value_
)
762 def OutputPartial(self
, out
):
765 out
.putVarInt32(self
.type_
)
766 if (self
.has_string_value_
):
768 out
.putPrefixedString(self
.string_value_
)
770 def TryMerge(self
, d
):
774 self
.set_type(d
.getVarInt32())
777 self
.set_string_value(d
.getPrefixedString())
781 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
785 def __str__(self
, prefix
="", printElemNumber
=0):
787 if self
.has_type_
: res
+=prefix
+("type: %s\n" % self
.DebugFormatInt32(self
.type_
))
788 if self
.has_string_value_
: res
+=prefix
+("string_value: %s\n" % self
.DebugFormatString(self
.string_value_
))
792 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
793 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
798 _TEXT
= _BuildTagLookupTable({
804 _TYPES
= _BuildTagLookupTable({
805 0: ProtocolBuffer
.Encoder
.NUMERIC
,
806 1: ProtocolBuffer
.Encoder
.NUMERIC
,
807 3: ProtocolBuffer
.Encoder
.STRING
,
808 }, 3, ProtocolBuffer
.Encoder
.MAX_TYPE
)
812 _STYLE_CONTENT_TYPE
= """"""
813 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.FacetValue'
814 class Facet(ProtocolBuffer
.ProtocolMessage
):
819 def __init__(self
, contents
=None):
820 self
.value_
= FacetValue()
821 if contents
is not None: self
.MergeFromString(contents
)
823 def name(self
): return self
.name_
825 def set_name(self
, x
):
829 def clear_name(self
):
834 def has_name(self
): return self
.has_name_
836 def value(self
): return self
.value_
838 def mutable_value(self
): self
.has_value_
= 1; return self
.value_
840 def clear_value(self
):self
.has_value_
= 0; self
.value_
.Clear()
842 def has_value(self
): return self
.has_value_
845 def MergeFrom(self
, x
):
847 if (x
.has_name()): self
.set_name(x
.name())
848 if (x
.has_value()): self
.mutable_value().MergeFrom(x
.value())
851 if x
is self
: return 1
852 if self
.has_name_
!= x
.has_name_
: return 0
853 if self
.has_name_
and self
.name_
!= x
.name_
: return 0
854 if self
.has_value_
!= x
.has_value_
: return 0
855 if self
.has_value_
and self
.value_
!= x
.value_
: return 0
858 def IsInitialized(self
, debug_strs
=None):
860 if (not self
.has_name_
):
862 if debug_strs
is not None:
863 debug_strs
.append('Required field: name not set.')
864 if (not self
.has_value_
):
866 if debug_strs
is not None:
867 debug_strs
.append('Required field: value not set.')
868 elif not self
.value_
.IsInitialized(debug_strs
): initialized
= 0
873 n
+= self
.lengthString(len(self
.name_
))
874 n
+= self
.lengthString(self
.value_
.ByteSize())
877 def ByteSizePartial(self
):
881 n
+= self
.lengthString(len(self
.name_
))
882 if (self
.has_value_
):
884 n
+= self
.lengthString(self
.value_
.ByteSizePartial())
891 def OutputUnchecked(self
, out
):
893 out
.putPrefixedString(self
.name_
)
895 out
.putVarInt32(self
.value_
.ByteSize())
896 self
.value_
.OutputUnchecked(out
)
898 def OutputPartial(self
, out
):
901 out
.putPrefixedString(self
.name_
)
902 if (self
.has_value_
):
904 out
.putVarInt32(self
.value_
.ByteSizePartial())
905 self
.value_
.OutputPartial(out
)
907 def TryMerge(self
, d
):
911 self
.set_name(d
.getPrefixedString())
914 length
= d
.getVarInt32()
915 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
917 self
.mutable_value().TryMerge(tmp
)
921 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
925 def __str__(self
, prefix
="", printElemNumber
=0):
927 if self
.has_name_
: res
+=prefix
+("name: %s\n" % self
.DebugFormatString(self
.name_
))
929 res
+=prefix
+"value <\n"
930 res
+=self
.value_
.__str
__(prefix
+ " ", printElemNumber
)
935 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
936 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
941 _TEXT
= _BuildTagLookupTable({
947 _TYPES
= _BuildTagLookupTable({
948 0: ProtocolBuffer
.Encoder
.NUMERIC
,
949 1: ProtocolBuffer
.Encoder
.STRING
,
950 2: ProtocolBuffer
.Encoder
.STRING
,
951 }, 2, ProtocolBuffer
.Encoder
.MAX_TYPE
)
955 _STYLE_CONTENT_TYPE
= """"""
956 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.Facet'
957 class DocumentMetadata(ProtocolBuffer
.ProtocolMessage
):
961 def __init__(self
, contents
=None):
962 if contents
is not None: self
.MergeFromString(contents
)
964 def version(self
): return self
.version_
966 def set_version(self
, x
):
967 self
.has_version_
= 1
970 def clear_version(self
):
971 if self
.has_version_
:
972 self
.has_version_
= 0
975 def has_version(self
): return self
.has_version_
978 def MergeFrom(self
, x
):
980 if (x
.has_version()): self
.set_version(x
.version())
983 if x
is self
: return 1
984 if self
.has_version_
!= x
.has_version_
: return 0
985 if self
.has_version_
and self
.version_
!= x
.version_
: return 0
988 def IsInitialized(self
, debug_strs
=None):
994 if (self
.has_version_
): n
+= 1 + self
.lengthVarInt64(self
.version_
)
997 def ByteSizePartial(self
):
999 if (self
.has_version_
): n
+= 1 + self
.lengthVarInt64(self
.version_
)
1003 self
.clear_version()
1005 def OutputUnchecked(self
, out
):
1006 if (self
.has_version_
):
1008 out
.putVarInt64(self
.version_
)
1010 def OutputPartial(self
, out
):
1011 if (self
.has_version_
):
1013 out
.putVarInt64(self
.version_
)
1015 def TryMerge(self
, d
):
1016 while d
.avail() > 0:
1017 tt
= d
.getVarInt32()
1019 self
.set_version(d
.getVarInt64())
1023 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1027 def __str__(self
, prefix
="", printElemNumber
=0):
1029 if self
.has_version_
: res
+=prefix
+("version: %s\n" % self
.DebugFormatInt64(self
.version_
))
1033 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
1034 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
1038 _TEXT
= _BuildTagLookupTable({
1043 _TYPES
= _BuildTagLookupTable({
1044 0: ProtocolBuffer
.Encoder
.NUMERIC
,
1045 1: ProtocolBuffer
.Encoder
.NUMERIC
,
1046 }, 1, ProtocolBuffer
.Encoder
.MAX_TYPE
)
1050 _STYLE_CONTENT_TYPE
= """"""
1051 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.DocumentMetadata'
1052 class Document(ProtocolBuffer
.ProtocolMessage
):
1061 def Storage_Name(cls
, x
): return cls
._Storage
_NAMES
.get(x
, "")
1062 Storage_Name
= classmethod(Storage_Name
)
1075 def __init__(self
, contents
=None):
1078 self
.lazy_init_lock_
= thread
.allocate_lock()
1079 if contents
is not None: self
.MergeFromString(contents
)
1081 def id(self
): return self
.id_
1083 def set_id(self
, x
):
1092 def has_id(self
): return self
.has_id_
1094 def language(self
): return self
.language_
1096 def set_language(self
, x
):
1097 self
.has_language_
= 1
1100 def clear_language(self
):
1101 if self
.has_language_
:
1102 self
.has_language_
= 0
1103 self
.language_
= "en"
1105 def has_language(self
): return self
.has_language_
1107 def field_size(self
): return len(self
.field_
)
1108 def field_list(self
): return self
.field_
1111 return self
.field_
[i
]
1113 def mutable_field(self
, i
):
1114 return self
.field_
[i
]
1116 def add_field(self
):
1118 self
.field_
.append(x
)
1121 def clear_field(self
):
1123 def order_id(self
): return self
.order_id_
1125 def set_order_id(self
, x
):
1126 self
.has_order_id_
= 1
1129 def clear_order_id(self
):
1130 if self
.has_order_id_
:
1131 self
.has_order_id_
= 0
1134 def has_order_id(self
): return self
.has_order_id_
1136 def storage(self
): return self
.storage_
1138 def set_storage(self
, x
):
1139 self
.has_storage_
= 1
1142 def clear_storage(self
):
1143 if self
.has_storage_
:
1144 self
.has_storage_
= 0
1147 def has_storage(self
): return self
.has_storage_
1150 if self
.acl_
is None:
1151 self
.lazy_init_lock_
.acquire()
1153 if self
.acl_
is None: self
.acl_
= AccessControlList()
1155 self
.lazy_init_lock_
.release()
1158 def mutable_acl(self
): self
.has_acl_
= 1; return self
.acl()
1160 def clear_acl(self
):
1164 if self
.acl_
is not None: self
.acl_
.Clear()
1166 def has_acl(self
): return self
.has_acl_
1168 def facet_size(self
): return len(self
.facet_
)
1169 def facet_list(self
): return self
.facet_
1172 return self
.facet_
[i
]
1174 def mutable_facet(self
, i
):
1175 return self
.facet_
[i
]
1177 def add_facet(self
):
1179 self
.facet_
.append(x
)
1182 def clear_facet(self
):
1185 def MergeFrom(self
, x
):
1186 assert x
is not self
1187 if (x
.has_id()): self
.set_id(x
.id())
1188 if (x
.has_language()): self
.set_language(x
.language())
1189 for i
in xrange(x
.field_size()): self
.add_field().CopyFrom(x
.field(i
))
1190 if (x
.has_order_id()): self
.set_order_id(x
.order_id())
1191 if (x
.has_storage()): self
.set_storage(x
.storage())
1192 if (x
.has_acl()): self
.mutable_acl().MergeFrom(x
.acl())
1193 for i
in xrange(x
.facet_size()): self
.add_facet().CopyFrom(x
.facet(i
))
1195 def Equals(self
, x
):
1196 if x
is self
: return 1
1197 if self
.has_id_
!= x
.has_id_
: return 0
1198 if self
.has_id_
and self
.id_
!= x
.id_
: return 0
1199 if self
.has_language_
!= x
.has_language_
: return 0
1200 if self
.has_language_
and self
.language_
!= x
.language_
: return 0
1201 if len(self
.field_
) != len(x
.field_
): return 0
1202 for e1
, e2
in zip(self
.field_
, x
.field_
):
1203 if e1
!= e2
: return 0
1204 if self
.has_order_id_
!= x
.has_order_id_
: return 0
1205 if self
.has_order_id_
and self
.order_id_
!= x
.order_id_
: return 0
1206 if self
.has_storage_
!= x
.has_storage_
: return 0
1207 if self
.has_storage_
and self
.storage_
!= x
.storage_
: return 0
1208 if self
.has_acl_
!= x
.has_acl_
: return 0
1209 if self
.has_acl_
and self
.acl_
!= x
.acl_
: return 0
1210 if len(self
.facet_
) != len(x
.facet_
): return 0
1211 for e1
, e2
in zip(self
.facet_
, x
.facet_
):
1212 if e1
!= e2
: return 0
1215 def IsInitialized(self
, debug_strs
=None):
1217 for p
in self
.field_
:
1218 if not p
.IsInitialized(debug_strs
): initialized
=0
1219 if (self
.has_acl_
and not self
.acl_
.IsInitialized(debug_strs
)): initialized
= 0
1220 for p
in self
.facet_
:
1221 if not p
.IsInitialized(debug_strs
): initialized
=0
1226 if (self
.has_id_
): n
+= 1 + self
.lengthString(len(self
.id_
))
1227 if (self
.has_language_
): n
+= 1 + self
.lengthString(len(self
.language_
))
1228 n
+= 1 * len(self
.field_
)
1229 for i
in xrange(len(self
.field_
)): n
+= self
.lengthString(self
.field_
[i
].ByteSize())
1230 if (self
.has_order_id_
): n
+= 1 + self
.lengthVarInt64(self
.order_id_
)
1231 if (self
.has_storage_
): n
+= 1 + self
.lengthVarInt64(self
.storage_
)
1232 if (self
.has_acl_
): n
+= 1 + self
.lengthString(self
.acl_
.ByteSize())
1233 n
+= 1 * len(self
.facet_
)
1234 for i
in xrange(len(self
.facet_
)): n
+= self
.lengthString(self
.facet_
[i
].ByteSize())
1237 def ByteSizePartial(self
):
1239 if (self
.has_id_
): n
+= 1 + self
.lengthString(len(self
.id_
))
1240 if (self
.has_language_
): n
+= 1 + self
.lengthString(len(self
.language_
))
1241 n
+= 1 * len(self
.field_
)
1242 for i
in xrange(len(self
.field_
)): n
+= self
.lengthString(self
.field_
[i
].ByteSizePartial())
1243 if (self
.has_order_id_
): n
+= 1 + self
.lengthVarInt64(self
.order_id_
)
1244 if (self
.has_storage_
): n
+= 1 + self
.lengthVarInt64(self
.storage_
)
1245 if (self
.has_acl_
): n
+= 1 + self
.lengthString(self
.acl_
.ByteSizePartial())
1246 n
+= 1 * len(self
.facet_
)
1247 for i
in xrange(len(self
.facet_
)): n
+= self
.lengthString(self
.facet_
[i
].ByteSizePartial())
1252 self
.clear_language()
1254 self
.clear_order_id()
1255 self
.clear_storage()
1259 def OutputUnchecked(self
, out
):
1262 out
.putPrefixedString(self
.id_
)
1263 if (self
.has_language_
):
1265 out
.putPrefixedString(self
.language_
)
1266 for i
in xrange(len(self
.field_
)):
1268 out
.putVarInt32(self
.field_
[i
].ByteSize())
1269 self
.field_
[i
].OutputUnchecked(out
)
1270 if (self
.has_order_id_
):
1272 out
.putVarInt32(self
.order_id_
)
1273 if (self
.has_storage_
):
1275 out
.putVarInt32(self
.storage_
)
1278 out
.putVarInt32(self
.acl_
.ByteSize())
1279 self
.acl_
.OutputUnchecked(out
)
1280 for i
in xrange(len(self
.facet_
)):
1282 out
.putVarInt32(self
.facet_
[i
].ByteSize())
1283 self
.facet_
[i
].OutputUnchecked(out
)
1285 def OutputPartial(self
, out
):
1288 out
.putPrefixedString(self
.id_
)
1289 if (self
.has_language_
):
1291 out
.putPrefixedString(self
.language_
)
1292 for i
in xrange(len(self
.field_
)):
1294 out
.putVarInt32(self
.field_
[i
].ByteSizePartial())
1295 self
.field_
[i
].OutputPartial(out
)
1296 if (self
.has_order_id_
):
1298 out
.putVarInt32(self
.order_id_
)
1299 if (self
.has_storage_
):
1301 out
.putVarInt32(self
.storage_
)
1304 out
.putVarInt32(self
.acl_
.ByteSizePartial())
1305 self
.acl_
.OutputPartial(out
)
1306 for i
in xrange(len(self
.facet_
)):
1308 out
.putVarInt32(self
.facet_
[i
].ByteSizePartial())
1309 self
.facet_
[i
].OutputPartial(out
)
1311 def TryMerge(self
, d
):
1312 while d
.avail() > 0:
1313 tt
= d
.getVarInt32()
1315 self
.set_id(d
.getPrefixedString())
1318 self
.set_language(d
.getPrefixedString())
1321 length
= d
.getVarInt32()
1322 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1324 self
.add_field().TryMerge(tmp
)
1327 self
.set_order_id(d
.getVarInt32())
1330 self
.set_storage(d
.getVarInt32())
1333 length
= d
.getVarInt32()
1334 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1336 self
.mutable_acl().TryMerge(tmp
)
1339 length
= d
.getVarInt32()
1340 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1342 self
.add_facet().TryMerge(tmp
)
1346 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1350 def __str__(self
, prefix
="", printElemNumber
=0):
1352 if self
.has_id_
: res
+=prefix
+("id: %s\n" % self
.DebugFormatString(self
.id_
))
1353 if self
.has_language_
: res
+=prefix
+("language: %s\n" % self
.DebugFormatString(self
.language_
))
1355 for e
in self
.field_
:
1357 if printElemNumber
: elm
="(%d)" % cnt
1358 res
+=prefix
+("field%s <\n" % elm
)
1359 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
1362 if self
.has_order_id_
: res
+=prefix
+("order_id: %s\n" % self
.DebugFormatInt32(self
.order_id_
))
1363 if self
.has_storage_
: res
+=prefix
+("storage: %s\n" % self
.DebugFormatInt32(self
.storage_
))
1365 res
+=prefix
+"acl <\n"
1366 res
+=self
.acl_
.__str
__(prefix
+ " ", printElemNumber
)
1369 for e
in self
.facet_
:
1371 if printElemNumber
: elm
="(%d)" % cnt
1372 res
+=prefix
+("facet%s <\n" % elm
)
1373 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
1379 def _BuildTagLookupTable(sparse
, maxtag
, default
=None):
1380 return tuple([sparse
.get(i
, default
) for i
in xrange(0, 1+maxtag
)])
1390 _TEXT
= _BuildTagLookupTable({
1401 _TYPES
= _BuildTagLookupTable({
1402 0: ProtocolBuffer
.Encoder
.NUMERIC
,
1403 1: ProtocolBuffer
.Encoder
.STRING
,
1404 2: ProtocolBuffer
.Encoder
.STRING
,
1405 3: ProtocolBuffer
.Encoder
.STRING
,
1406 4: ProtocolBuffer
.Encoder
.NUMERIC
,
1407 5: ProtocolBuffer
.Encoder
.NUMERIC
,
1408 6: ProtocolBuffer
.Encoder
.STRING
,
1409 8: ProtocolBuffer
.Encoder
.STRING
,
1410 }, 8, ProtocolBuffer
.Encoder
.MAX_TYPE
)
1414 _STYLE_CONTENT_TYPE
= """"""
1415 _PROTO_DESCRIPTOR_NAME
= 'storage_onestore_v3.Document'
1416 if _extension_runtime
:
1419 __all__
= ['FieldValue','FieldValue_Geo','Field','FieldTypes','FacetValue','Facet','DocumentMetadata','Document']