Greg Stein | db84a10 | 2009-01-31 07:40:26 +0000 | [diff] [blame^] | 1 | # |
| 2 | # Autogenerated by Thrift |
| 3 | # |
| 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING |
| 5 | # |
| 6 | |
| 7 | from thrift.Thrift import * |
| 8 | [# ### probably need some massaging to really locate this module |
| 9 | ][for includes]import [includes].ttypes |
| 10 | [end] |
| 11 | from thrift.transport import TTransport |
| 12 | from thrift.protocol import TBinaryProtocol |
| 13 | try: |
| 14 | from thrift.protocol import fastbinary |
| 15 | except: |
| 16 | fastbinary = None |
| 17 | |
| 18 | |
| 19 | [# ### need gen_newstyle flag |
| 20 | ][for enums]class [enums.ident](object):[for enums.values] |
| 21 | [enums.values.ident] = [enums.values.value][end] |
| 22 | [end] |
| 23 | |
| 24 | [for consts][consts.ident] = [consts.value.cvalue] |
| 25 | [end] |
| 26 | |
| 27 | [# ### need gen_newstyle flag |
| 28 | ][for structs]class [structs.ident](object): |
| 29 | |
| 30 | thrift_spec = ([# ### should sort fields. need None markers for gaps. |
| 31 | ][if-any structs.fields][for structs.sorted_fields] |
| 32 | [if-any structs.sorted_fields]([structs.sorted_fields.field_id], [structs.sorted_fields.type_enum], [# |
| 33 | ]'[structs.sorted_fields.ident]', [# |
| 34 | ]None, [# ### should have spec_args here |
| 35 | ][if-any structs.sorted_fields.value][structs.sorted_fields.value.cvalue][else]None[end], [# |
| 36 | ]),[else]None,[end] # ### list-index[# structs.sorted_fields.list-index][end] |
| 37 | ) |
| 38 | [else] thrift_spec = None |
| 39 | [end] |
| 40 | [if-any structs.fields] def __init__(self,[# |
| 41 | ][for structs.fields] [structs.fields.ident]=[# |
| 42 | ][if-any structs.fields.value]thrift_spec[[][structs.fields.field_id]][[]4][# |
| 43 | ][else]None[end],[end]): |
| 44 | [for structs.fields][if-any ""][# ### complex test here |
| 45 | ] if [structs.fields.ident] is self.thrift_spec[[]structs.fields.field_id][[]4]: |
| 46 | [structs.fields.ident] = [structs.fields.value.cvalue] |
| 47 | [end] self.[structs.fields.ident] = [structs.fields.ident] |
| 48 | [end] |
| 49 | [end][# close: if-any structs.fields] |
| 50 | |
| 51 | def read(self, iprot): |
| 52 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated [# |
| 53 | ]and isinstance(iprot.trans, TTransport.CReadableTransport) [# |
| 54 | ]and self.thrift_spec is not None and fastbinary is not None: |
| 55 | fastbinary.decode_binary(self, iprot.trans, [# |
| 56 | ](self.__class__, self.thrift_spec)) |
| 57 | return |
| 58 | iprot.readStructBegin() |
| 59 | while True: |
| 60 | (fname, ftype, fid) = iprot.readFieldBegin() |
| 61 | if ftype == TType.STOP: |
| 62 | break[for structs.fields] |
| 63 | [if-index structs.fields first]if[else]elif[end] fid == [# |
| 64 | ][structs.fields.field_id]: |
| 65 | if ftype == [structs.fields.type_enum]: |
| 66 | pass # deserialize |
| 67 | else: |
| 68 | iprot.skip(ftype)[end] |
| 69 | else: |
| 70 | iprot.skip(ftype) |
| 71 | iprot.readFieldEnd() |
| 72 | iprot.readStructEnd() |
| 73 | |
| 74 | def write(self, oprot): |
| 75 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated [# |
| 76 | ]and self.thrift_spec is not None and fastbinary is not None: |
| 77 | oprot.trans.write(fastbinary.encode_binary(self, [# |
| 78 | ](self.__class__, self.thrift_spec))) |
| 79 | return |
| 80 | oprot.writeStructBegin('[structs.ident]')[for structs.fields] |
| 81 | if self.[structs.fields.ident] != None: |
| 82 | oprot.writeFieldBegin('[structs.fields.ident]', [# |
| 83 | ][structs.fields.type_enum], [structs.fields.field_id]) |
| 84 | # serialize |
| 85 | oprot.writeFieldEnd()[end] |
| 86 | oprot.writeFieldStop() |
| 87 | oprot.writeStructEnd() |
| 88 | |
| 89 | def __repr__(self): |
| 90 | L = [[]'%s=%r' % (key, value) |
| 91 | for key, value in self.__dict__.iteritems()] |
| 92 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) |
| 93 | |
| 94 | def __eq__(self, other): |
| 95 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ |
| 96 | |
| 97 | def __ne__(self, other): |
| 98 | return not (self == other) |
| 99 | |
| 100 | [end][# for structs] |