#
# Autogenerated by Thrift Compiler (1.0.0-dev)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
#  options string: py:new_style
#

from thrift.Thrift import TType, TMessageType, TException, TApplicationException
import fb303.ttypes


from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol, TProtocol
try:
  from thrift.protocol import fastbinary
except:
  fastbinary = None



class ServiceDefinition(object):
  """
  Attributes:
   - idl: The contents of the .thrift file used to generate this service
   - serviceName: A .thrift file can contain multiple services.  This field disambiguates
  between services returned in `idl`.
   - dependencies: Any additional (name).thrift => (contents) map of dependencies required
  to communicate with this service
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRING, 'idl', None, None, ), # 1
    (2, TType.STRING, 'serviceName', None, None, ), # 2
    (3, TType.MAP, 'dependencies', (TType.STRING,None,TType.STRING,None), None, ), # 3
  )

  def __init__(self, idl=None, serviceName=None, dependencies=None,):
    self.idl = idl
    self.serviceName = serviceName
    self.dependencies = dependencies

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRING:
          self.idl = iprot.readString();
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRING:
          self.serviceName = iprot.readString();
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.MAP:
          self.dependencies = {}
          (_ktype1, _vtype2, _size0 ) = iprot.readMapBegin()
          for _i4 in xrange(_size0):
            _key5 = iprot.readString();
            _val6 = iprot.readString();
            self.dependencies[_key5] = _val6
          iprot.readMapEnd()
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('ServiceDefinition')
    if self.idl is not None:
      oprot.writeFieldBegin('idl', TType.STRING, 1)
      oprot.writeString(self.idl)
      oprot.writeFieldEnd()
    if self.serviceName is not None:
      oprot.writeFieldBegin('serviceName', TType.STRING, 2)
      oprot.writeString(self.serviceName)
      oprot.writeFieldEnd()
    if self.dependencies is not None:
      oprot.writeFieldBegin('dependencies', TType.MAP, 3)
      oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.dependencies))
      for kiter7,viter8 in self.dependencies.items():
        oprot.writeString(kiter7)
        oprot.writeString(viter8)
      oprot.writeMapEnd()
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)
