thirdparty/google_appengine/google/appengine/base/capabilities_pb.py
changeset 828 f5fd65cc3bf3
child 1278 a7766286a7be
equal deleted inserted replaced
827:88c186556a80 828:f5fd65cc3bf3
       
     1 #!/usr/bin/env python
       
     2 #
       
     3 # Copyright 2007 Google Inc.
       
     4 #
       
     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
       
     8 #
       
     9 #     http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    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.
       
    16 #
       
    17 
       
    18 from google.net.proto import ProtocolBuffer
       
    19 import array
       
    20 import dummy_thread as thread
       
    21 
       
    22 __pychecker__ = """maxreturns=0 maxbranches=0 no-callinit
       
    23                    unusednames=printElemNumber,debug_strs no-special"""
       
    24 
       
    25 class CapabilityConfigList(ProtocolBuffer.ProtocolMessage):
       
    26   has_default_config_ = 0
       
    27   default_config_ = None
       
    28 
       
    29   def __init__(self, contents=None):
       
    30     self.config_ = []
       
    31     self.lazy_init_lock_ = thread.allocate_lock()
       
    32     if contents is not None: self.MergeFromString(contents)
       
    33 
       
    34   def config_size(self): return len(self.config_)
       
    35   def config_list(self): return self.config_
       
    36 
       
    37   def config(self, i):
       
    38     return self.config_[i]
       
    39 
       
    40   def mutable_config(self, i):
       
    41     return self.config_[i]
       
    42 
       
    43   def add_config(self):
       
    44     x = CapabilityConfig()
       
    45     self.config_.append(x)
       
    46     return x
       
    47 
       
    48   def clear_config(self):
       
    49     self.config_ = []
       
    50   def default_config(self):
       
    51     if self.default_config_ is None:
       
    52       self.lazy_init_lock_.acquire()
       
    53       try:
       
    54         if self.default_config_ is None: self.default_config_ = CapabilityConfig()
       
    55       finally:
       
    56         self.lazy_init_lock_.release()
       
    57     return self.default_config_
       
    58 
       
    59   def mutable_default_config(self): self.has_default_config_ = 1; return self.default_config()
       
    60 
       
    61   def clear_default_config(self):
       
    62     self.has_default_config_ = 0;
       
    63     if self.default_config_ is not None: self.default_config_.Clear()
       
    64 
       
    65   def has_default_config(self): return self.has_default_config_
       
    66 
       
    67 
       
    68   def MergeFrom(self, x):
       
    69     assert x is not self
       
    70     for i in xrange(x.config_size()): self.add_config().CopyFrom(x.config(i))
       
    71     if (x.has_default_config()): self.mutable_default_config().MergeFrom(x.default_config())
       
    72 
       
    73   def Equals(self, x):
       
    74     if x is self: return 1
       
    75     if len(self.config_) != len(x.config_): return 0
       
    76     for e1, e2 in zip(self.config_, x.config_):
       
    77       if e1 != e2: return 0
       
    78     if self.has_default_config_ != x.has_default_config_: return 0
       
    79     if self.has_default_config_ and self.default_config_ != x.default_config_: return 0
       
    80     return 1
       
    81 
       
    82   def IsInitialized(self, debug_strs=None):
       
    83     initialized = 1
       
    84     for p in self.config_:
       
    85       if not p.IsInitialized(debug_strs): initialized=0
       
    86     if (self.has_default_config_ and not self.default_config_.IsInitialized(debug_strs)): initialized = 0
       
    87     return initialized
       
    88 
       
    89   def ByteSize(self):
       
    90     n = 0
       
    91     n += 1 * len(self.config_)
       
    92     for i in xrange(len(self.config_)): n += self.lengthString(self.config_[i].ByteSize())
       
    93     if (self.has_default_config_): n += 1 + self.lengthString(self.default_config_.ByteSize())
       
    94     return n + 0
       
    95 
       
    96   def Clear(self):
       
    97     self.clear_config()
       
    98     self.clear_default_config()
       
    99 
       
   100   def OutputUnchecked(self, out):
       
   101     for i in xrange(len(self.config_)):
       
   102       out.putVarInt32(10)
       
   103       out.putVarInt32(self.config_[i].ByteSize())
       
   104       self.config_[i].OutputUnchecked(out)
       
   105     if (self.has_default_config_):
       
   106       out.putVarInt32(18)
       
   107       out.putVarInt32(self.default_config_.ByteSize())
       
   108       self.default_config_.OutputUnchecked(out)
       
   109 
       
   110   def TryMerge(self, d):
       
   111     while d.avail() > 0:
       
   112       tt = d.getVarInt32()
       
   113       if tt == 10:
       
   114         length = d.getVarInt32()
       
   115         tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
       
   116         d.skip(length)
       
   117         self.add_config().TryMerge(tmp)
       
   118         continue
       
   119       if tt == 18:
       
   120         length = d.getVarInt32()
       
   121         tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
       
   122         d.skip(length)
       
   123         self.mutable_default_config().TryMerge(tmp)
       
   124         continue
       
   125       if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
       
   126       d.skipData(tt)
       
   127 
       
   128 
       
   129   def __str__(self, prefix="", printElemNumber=0):
       
   130     res=""
       
   131     cnt=0
       
   132     for e in self.config_:
       
   133       elm=""
       
   134       if printElemNumber: elm="(%d)" % cnt
       
   135       res+=prefix+("config%s <\n" % elm)
       
   136       res+=e.__str__(prefix + "  ", printElemNumber)
       
   137       res+=prefix+">\n"
       
   138       cnt+=1
       
   139     if self.has_default_config_:
       
   140       res+=prefix+"default_config <\n"
       
   141       res+=self.default_config_.__str__(prefix + "  ", printElemNumber)
       
   142       res+=prefix+">\n"
       
   143     return res
       
   144 
       
   145   kconfig = 1
       
   146   kdefault_config = 2
       
   147 
       
   148   _TEXT = (
       
   149    "ErrorCode",
       
   150    "config",
       
   151    "default_config",
       
   152   )
       
   153 
       
   154   _TYPES = (
       
   155    ProtocolBuffer.Encoder.NUMERIC,
       
   156    ProtocolBuffer.Encoder.STRING,
       
   157 
       
   158    ProtocolBuffer.Encoder.STRING,
       
   159 
       
   160   )
       
   161 
       
   162   _STYLE = """"""
       
   163   _STYLE_CONTENT_TYPE = """"""
       
   164 class CapabilityConfig(ProtocolBuffer.ProtocolMessage):
       
   165 
       
   166   ENABLED      =    1
       
   167   SCHEDULED    =    2
       
   168   DISABLED     =    3
       
   169   UNKNOWN      =    4
       
   170 
       
   171   _Status_NAMES = {
       
   172     1: "ENABLED",
       
   173     2: "SCHEDULED",
       
   174     3: "DISABLED",
       
   175     4: "UNKNOWN",
       
   176   }
       
   177 
       
   178   def Status_Name(cls, x): return cls._Status_NAMES.get(x, "")
       
   179   Status_Name = classmethod(Status_Name)
       
   180 
       
   181   has_package_ = 0
       
   182   package_ = ""
       
   183   has_capability_ = 0
       
   184   capability_ = ""
       
   185   has_status_ = 0
       
   186   status_ = 4
       
   187   has_scheduled_time_ = 0
       
   188   scheduled_time_ = ""
       
   189   has_internal_message_ = 0
       
   190   internal_message_ = ""
       
   191   has_admin_message_ = 0
       
   192   admin_message_ = ""
       
   193   has_error_message_ = 0
       
   194   error_message_ = ""
       
   195 
       
   196   def __init__(self, contents=None):
       
   197     if contents is not None: self.MergeFromString(contents)
       
   198 
       
   199   def package(self): return self.package_
       
   200 
       
   201   def set_package(self, x):
       
   202     self.has_package_ = 1
       
   203     self.package_ = x
       
   204 
       
   205   def clear_package(self):
       
   206     self.has_package_ = 0
       
   207     self.package_ = ""
       
   208 
       
   209   def has_package(self): return self.has_package_
       
   210 
       
   211   def capability(self): return self.capability_
       
   212 
       
   213   def set_capability(self, x):
       
   214     self.has_capability_ = 1
       
   215     self.capability_ = x
       
   216 
       
   217   def clear_capability(self):
       
   218     self.has_capability_ = 0
       
   219     self.capability_ = ""
       
   220 
       
   221   def has_capability(self): return self.has_capability_
       
   222 
       
   223   def status(self): return self.status_
       
   224 
       
   225   def set_status(self, x):
       
   226     self.has_status_ = 1
       
   227     self.status_ = x
       
   228 
       
   229   def clear_status(self):
       
   230     self.has_status_ = 0
       
   231     self.status_ = 4
       
   232 
       
   233   def has_status(self): return self.has_status_
       
   234 
       
   235   def scheduled_time(self): return self.scheduled_time_
       
   236 
       
   237   def set_scheduled_time(self, x):
       
   238     self.has_scheduled_time_ = 1
       
   239     self.scheduled_time_ = x
       
   240 
       
   241   def clear_scheduled_time(self):
       
   242     self.has_scheduled_time_ = 0
       
   243     self.scheduled_time_ = ""
       
   244 
       
   245   def has_scheduled_time(self): return self.has_scheduled_time_
       
   246 
       
   247   def internal_message(self): return self.internal_message_
       
   248 
       
   249   def set_internal_message(self, x):
       
   250     self.has_internal_message_ = 1
       
   251     self.internal_message_ = x
       
   252 
       
   253   def clear_internal_message(self):
       
   254     self.has_internal_message_ = 0
       
   255     self.internal_message_ = ""
       
   256 
       
   257   def has_internal_message(self): return self.has_internal_message_
       
   258 
       
   259   def admin_message(self): return self.admin_message_
       
   260 
       
   261   def set_admin_message(self, x):
       
   262     self.has_admin_message_ = 1
       
   263     self.admin_message_ = x
       
   264 
       
   265   def clear_admin_message(self):
       
   266     self.has_admin_message_ = 0
       
   267     self.admin_message_ = ""
       
   268 
       
   269   def has_admin_message(self): return self.has_admin_message_
       
   270 
       
   271   def error_message(self): return self.error_message_
       
   272 
       
   273   def set_error_message(self, x):
       
   274     self.has_error_message_ = 1
       
   275     self.error_message_ = x
       
   276 
       
   277   def clear_error_message(self):
       
   278     self.has_error_message_ = 0
       
   279     self.error_message_ = ""
       
   280 
       
   281   def has_error_message(self): return self.has_error_message_
       
   282 
       
   283 
       
   284   def MergeFrom(self, x):
       
   285     assert x is not self
       
   286     if (x.has_package()): self.set_package(x.package())
       
   287     if (x.has_capability()): self.set_capability(x.capability())
       
   288     if (x.has_status()): self.set_status(x.status())
       
   289     if (x.has_scheduled_time()): self.set_scheduled_time(x.scheduled_time())
       
   290     if (x.has_internal_message()): self.set_internal_message(x.internal_message())
       
   291     if (x.has_admin_message()): self.set_admin_message(x.admin_message())
       
   292     if (x.has_error_message()): self.set_error_message(x.error_message())
       
   293 
       
   294   def Equals(self, x):
       
   295     if x is self: return 1
       
   296     if self.has_package_ != x.has_package_: return 0
       
   297     if self.has_package_ and self.package_ != x.package_: return 0
       
   298     if self.has_capability_ != x.has_capability_: return 0
       
   299     if self.has_capability_ and self.capability_ != x.capability_: return 0
       
   300     if self.has_status_ != x.has_status_: return 0
       
   301     if self.has_status_ and self.status_ != x.status_: return 0
       
   302     if self.has_scheduled_time_ != x.has_scheduled_time_: return 0
       
   303     if self.has_scheduled_time_ and self.scheduled_time_ != x.scheduled_time_: return 0
       
   304     if self.has_internal_message_ != x.has_internal_message_: return 0
       
   305     if self.has_internal_message_ and self.internal_message_ != x.internal_message_: return 0
       
   306     if self.has_admin_message_ != x.has_admin_message_: return 0
       
   307     if self.has_admin_message_ and self.admin_message_ != x.admin_message_: return 0
       
   308     if self.has_error_message_ != x.has_error_message_: return 0
       
   309     if self.has_error_message_ and self.error_message_ != x.error_message_: return 0
       
   310     return 1
       
   311 
       
   312   def IsInitialized(self, debug_strs=None):
       
   313     initialized = 1
       
   314     if (not self.has_package_):
       
   315       initialized = 0
       
   316       if debug_strs is not None:
       
   317         debug_strs.append('Required field: package not set.')
       
   318     if (not self.has_capability_):
       
   319       initialized = 0
       
   320       if debug_strs is not None:
       
   321         debug_strs.append('Required field: capability not set.')
       
   322     return initialized
       
   323 
       
   324   def ByteSize(self):
       
   325     n = 0
       
   326     n += self.lengthString(len(self.package_))
       
   327     n += self.lengthString(len(self.capability_))
       
   328     if (self.has_status_): n += 1 + self.lengthVarInt64(self.status_)
       
   329     if (self.has_scheduled_time_): n += 1 + self.lengthString(len(self.scheduled_time_))
       
   330     if (self.has_internal_message_): n += 1 + self.lengthString(len(self.internal_message_))
       
   331     if (self.has_admin_message_): n += 1 + self.lengthString(len(self.admin_message_))
       
   332     if (self.has_error_message_): n += 1 + self.lengthString(len(self.error_message_))
       
   333     return n + 2
       
   334 
       
   335   def Clear(self):
       
   336     self.clear_package()
       
   337     self.clear_capability()
       
   338     self.clear_status()
       
   339     self.clear_scheduled_time()
       
   340     self.clear_internal_message()
       
   341     self.clear_admin_message()
       
   342     self.clear_error_message()
       
   343 
       
   344   def OutputUnchecked(self, out):
       
   345     out.putVarInt32(10)
       
   346     out.putPrefixedString(self.package_)
       
   347     out.putVarInt32(18)
       
   348     out.putPrefixedString(self.capability_)
       
   349     if (self.has_status_):
       
   350       out.putVarInt32(24)
       
   351       out.putVarInt32(self.status_)
       
   352     if (self.has_internal_message_):
       
   353       out.putVarInt32(34)
       
   354       out.putPrefixedString(self.internal_message_)
       
   355     if (self.has_admin_message_):
       
   356       out.putVarInt32(42)
       
   357       out.putPrefixedString(self.admin_message_)
       
   358     if (self.has_error_message_):
       
   359       out.putVarInt32(50)
       
   360       out.putPrefixedString(self.error_message_)
       
   361     if (self.has_scheduled_time_):
       
   362       out.putVarInt32(58)
       
   363       out.putPrefixedString(self.scheduled_time_)
       
   364 
       
   365   def TryMerge(self, d):
       
   366     while d.avail() > 0:
       
   367       tt = d.getVarInt32()
       
   368       if tt == 10:
       
   369         self.set_package(d.getPrefixedString())
       
   370         continue
       
   371       if tt == 18:
       
   372         self.set_capability(d.getPrefixedString())
       
   373         continue
       
   374       if tt == 24:
       
   375         self.set_status(d.getVarInt32())
       
   376         continue
       
   377       if tt == 34:
       
   378         self.set_internal_message(d.getPrefixedString())
       
   379         continue
       
   380       if tt == 42:
       
   381         self.set_admin_message(d.getPrefixedString())
       
   382         continue
       
   383       if tt == 50:
       
   384         self.set_error_message(d.getPrefixedString())
       
   385         continue
       
   386       if tt == 58:
       
   387         self.set_scheduled_time(d.getPrefixedString())
       
   388         continue
       
   389       if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
       
   390       d.skipData(tt)
       
   391 
       
   392 
       
   393   def __str__(self, prefix="", printElemNumber=0):
       
   394     res=""
       
   395     if self.has_package_: res+=prefix+("package: %s\n" % self.DebugFormatString(self.package_))
       
   396     if self.has_capability_: res+=prefix+("capability: %s\n" % self.DebugFormatString(self.capability_))
       
   397     if self.has_status_: res+=prefix+("status: %s\n" % self.DebugFormatInt32(self.status_))
       
   398     if self.has_scheduled_time_: res+=prefix+("scheduled_time: %s\n" % self.DebugFormatString(self.scheduled_time_))
       
   399     if self.has_internal_message_: res+=prefix+("internal_message: %s\n" % self.DebugFormatString(self.internal_message_))
       
   400     if self.has_admin_message_: res+=prefix+("admin_message: %s\n" % self.DebugFormatString(self.admin_message_))
       
   401     if self.has_error_message_: res+=prefix+("error_message: %s\n" % self.DebugFormatString(self.error_message_))
       
   402     return res
       
   403 
       
   404   kpackage = 1
       
   405   kcapability = 2
       
   406   kstatus = 3
       
   407   kscheduled_time = 7
       
   408   kinternal_message = 4
       
   409   kadmin_message = 5
       
   410   kerror_message = 6
       
   411 
       
   412   _TEXT = (
       
   413    "ErrorCode",
       
   414    "package",
       
   415    "capability",
       
   416    "status",
       
   417    "internal_message",
       
   418    "admin_message",
       
   419    "error_message",
       
   420    "scheduled_time",
       
   421   )
       
   422 
       
   423   _TYPES = (
       
   424    ProtocolBuffer.Encoder.NUMERIC,
       
   425    ProtocolBuffer.Encoder.STRING,
       
   426 
       
   427    ProtocolBuffer.Encoder.STRING,
       
   428 
       
   429    ProtocolBuffer.Encoder.NUMERIC,
       
   430 
       
   431    ProtocolBuffer.Encoder.STRING,
       
   432 
       
   433    ProtocolBuffer.Encoder.STRING,
       
   434 
       
   435    ProtocolBuffer.Encoder.STRING,
       
   436 
       
   437    ProtocolBuffer.Encoder.STRING,
       
   438 
       
   439   )
       
   440 
       
   441   _STYLE = """"""
       
   442   _STYLE_CONTENT_TYPE = """"""
       
   443 
       
   444 __all__ = ['CapabilityConfigList','CapabilityConfig']