Thrift: Pre-generate reflection_limited for Python.

Summary:
- Give reflection_limited a nice clean Python module.
- if/regen.sh now generates reflection_limited for Python and copies it to src.
- Added the generated Python for reflection_limited to version control.
- lib/py/setup.py installs reflection_limited.
- lib/py/cleanup.sh now removes build (make sure to run as root).
- The C++ version of reflection_limited was also updated by regen.sh.

Reviewed By: mcslee

Test Plan:
- Clean build and install.
- Look at the installed Python files.
- python -c 'from thrift.reflection.limited.ttypes import *'

Revert Plan: ok


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665235 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/py/src/reflection/__init__.py b/lib/py/src/reflection/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/py/src/reflection/__init__.py
diff --git a/lib/py/src/reflection/limited/__init__.py b/lib/py/src/reflection/limited/__init__.py
new file mode 100644
index 0000000..adefd8e
--- /dev/null
+++ b/lib/py/src/reflection/limited/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants']
diff --git a/lib/py/src/reflection/limited/constants.py b/lib/py/src/reflection/limited/constants.py
new file mode 100644
index 0000000..2f17ec3
--- /dev/null
+++ b/lib/py/src/reflection/limited/constants.py
@@ -0,0 +1,9 @@
+#
+# Autogenerated by Thrift
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+from thrift.Thrift import *
+from ttypes import *
+
diff --git a/lib/py/src/reflection/limited/ttypes.py b/lib/py/src/reflection/limited/ttypes.py
new file mode 100644
index 0000000..9ea8a9f
--- /dev/null
+++ b/lib/py/src/reflection/limited/ttypes.py
@@ -0,0 +1,532 @@
+#
+# Autogenerated by Thrift
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+from thrift.Thrift import *
+
+from thrift.transport import TTransport
+from thrift.protocol import fastbinary
+from thrift.protocol import TBinaryProtocol
+
+
+class TTypeTag:
+  T_VOID = 1
+  T_BOOL = 2
+  T_BYTE = 3
+  T_I16 = 6
+  T_I32 = 8
+  T_I64 = 10
+  T_DOUBLE = 4
+  T_STRING = 11
+  T_STRUCT = 12
+  T_MAP = 13
+  T_SET = 14
+  T_LIST = 15
+  T_ENUM = 101
+  T_NOT_REFLECTED = 102
+
+class SimpleType:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.I32, 'ttype', None, None, ), # 1
+    (2, TType.STRING, 'name', None, None, ), # 2
+  )
+
+  def __init__(self, d=None):
+    self.ttype = None
+    self.name = None
+    if isinstance(d, dict):
+      if 'ttype' in d:
+        self.ttype = d['ttype']
+      if 'name' in d:
+        self.name = d['name']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      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.I32:
+          self.ttype = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRING:
+          self.name = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('SimpleType')
+    if self.ttype != None:
+      oprot.writeFieldBegin('ttype', TType.I32, 1)
+      oprot.writeI32(self.ttype)
+      oprot.writeFieldEnd()
+    if self.name != None:
+      oprot.writeFieldBegin('name', TType.STRING, 2)
+      oprot.writeString(self.name)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class ContainerType:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.I32, 'ttype', None, None, ), # 1
+    (2, TType.STRUCT, 'subtype1', (SimpleType, SimpleType.thrift_spec), None, ), # 2
+    (3, TType.STRUCT, 'subtype2', (SimpleType, SimpleType.thrift_spec), None, ), # 3
+  )
+
+  def __init__(self, d=None):
+    self.ttype = None
+    self.subtype1 = None
+    self.subtype2 = None
+    if isinstance(d, dict):
+      if 'ttype' in d:
+        self.ttype = d['ttype']
+      if 'subtype1' in d:
+        self.subtype1 = d['subtype1']
+      if 'subtype2' in d:
+        self.subtype2 = d['subtype2']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      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.I32:
+          self.ttype = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.subtype1 = SimpleType()
+          self.subtype1.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.subtype2 = SimpleType()
+          self.subtype2.read(iprot)
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('ContainerType')
+    if self.ttype != None:
+      oprot.writeFieldBegin('ttype', TType.I32, 1)
+      oprot.writeI32(self.ttype)
+      oprot.writeFieldEnd()
+    if self.subtype1 != None:
+      oprot.writeFieldBegin('subtype1', TType.STRUCT, 2)
+      self.subtype1.write(oprot)
+      oprot.writeFieldEnd()
+    if self.subtype2 != None:
+      oprot.writeFieldBegin('subtype2', TType.STRUCT, 3)
+      self.subtype2.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class ThriftType:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.BOOL, 'is_container', None, None, ), # 1
+    (2, TType.STRUCT, 'simple_type', (SimpleType, SimpleType.thrift_spec), None, ), # 2
+    (3, TType.STRUCT, 'container_type', (ContainerType, ContainerType.thrift_spec), None, ), # 3
+  )
+
+  def __init__(self, d=None):
+    self.is_container = None
+    self.simple_type = None
+    self.container_type = None
+    if isinstance(d, dict):
+      if 'is_container' in d:
+        self.is_container = d['is_container']
+      if 'simple_type' in d:
+        self.simple_type = d['simple_type']
+      if 'container_type' in d:
+        self.container_type = d['container_type']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      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.BOOL:
+          self.is_container = iprot.readBool();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.simple_type = SimpleType()
+          self.simple_type.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.container_type = ContainerType()
+          self.container_type.read(iprot)
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('ThriftType')
+    if self.is_container != None:
+      oprot.writeFieldBegin('is_container', TType.BOOL, 1)
+      oprot.writeBool(self.is_container)
+      oprot.writeFieldEnd()
+    if self.simple_type != None:
+      oprot.writeFieldBegin('simple_type', TType.STRUCT, 2)
+      self.simple_type.write(oprot)
+      oprot.writeFieldEnd()
+    if self.container_type != None:
+      oprot.writeFieldBegin('container_type', TType.STRUCT, 3)
+      self.container_type.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class Argument:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.I16, 'key', None, None, ), # 1
+    (2, TType.STRING, 'name', None, None, ), # 2
+    (3, TType.STRUCT, 'type', (ThriftType, ThriftType.thrift_spec), None, ), # 3
+  )
+
+  def __init__(self, d=None):
+    self.key = None
+    self.name = None
+    self.type = None
+    if isinstance(d, dict):
+      if 'key' in d:
+        self.key = d['key']
+      if 'name' in d:
+        self.name = d['name']
+      if 'type' in d:
+        self.type = d['type']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      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.I16:
+          self.key = iprot.readI16();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRING:
+          self.name = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.type = ThriftType()
+          self.type.read(iprot)
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('Argument')
+    if self.key != None:
+      oprot.writeFieldBegin('key', TType.I16, 1)
+      oprot.writeI16(self.key)
+      oprot.writeFieldEnd()
+    if self.name != None:
+      oprot.writeFieldBegin('name', TType.STRING, 2)
+      oprot.writeString(self.name)
+      oprot.writeFieldEnd()
+    if self.type != None:
+      oprot.writeFieldBegin('type', TType.STRUCT, 3)
+      self.type.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class Method:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'name', None, None, ), # 1
+    (2, TType.STRUCT, 'return_type', (ThriftType, ThriftType.thrift_spec), None, ), # 2
+    (3, TType.LIST, 'arguments', (TType.STRUCT,(Argument, Argument.thrift_spec)), None, ), # 3
+  )
+
+  def __init__(self, d=None):
+    self.name = None
+    self.return_type = None
+    self.arguments = None
+    if isinstance(d, dict):
+      if 'name' in d:
+        self.name = d['name']
+      if 'return_type' in d:
+        self.return_type = d['return_type']
+      if 'arguments' in d:
+        self.arguments = d['arguments']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      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.name = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.return_type = ThriftType()
+          self.return_type.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.LIST:
+          self.arguments = []
+          (_etype3, _size0) = iprot.readListBegin()
+          for _i4 in xrange(_size0):
+            _elem5 = Argument()
+            _elem5.read(iprot)
+            self.arguments.append(_elem5)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('Method')
+    if self.name != None:
+      oprot.writeFieldBegin('name', TType.STRING, 1)
+      oprot.writeString(self.name)
+      oprot.writeFieldEnd()
+    if self.return_type != None:
+      oprot.writeFieldBegin('return_type', TType.STRUCT, 2)
+      self.return_type.write(oprot)
+      oprot.writeFieldEnd()
+    if self.arguments != None:
+      oprot.writeFieldBegin('arguments', TType.LIST, 3)
+      oprot.writeListBegin(TType.STRUCT, len(self.arguments))
+      for iter6 in self.arguments:
+        iter6.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class Service:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'name', None, None, ), # 1
+    (2, TType.LIST, 'methods', (TType.STRUCT,(Method, Method.thrift_spec)), None, ), # 2
+    (3, TType.BOOL, 'fully_reflected', None, None, ), # 3
+  )
+
+  def __init__(self, d=None):
+    self.name = None
+    self.methods = None
+    self.fully_reflected = None
+    if isinstance(d, dict):
+      if 'name' in d:
+        self.name = d['name']
+      if 'methods' in d:
+        self.methods = d['methods']
+      if 'fully_reflected' in d:
+        self.fully_reflected = d['fully_reflected']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      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.name = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.LIST:
+          self.methods = []
+          (_etype10, _size7) = iprot.readListBegin()
+          for _i11 in xrange(_size7):
+            _elem12 = Method()
+            _elem12.read(iprot)
+            self.methods.append(_elem12)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.BOOL:
+          self.fully_reflected = iprot.readBool();
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('Service')
+    if self.name != None:
+      oprot.writeFieldBegin('name', TType.STRING, 1)
+      oprot.writeString(self.name)
+      oprot.writeFieldEnd()
+    if self.methods != None:
+      oprot.writeFieldBegin('methods', TType.LIST, 2)
+      oprot.writeListBegin(TType.STRUCT, len(self.methods))
+      for iter13 in self.methods:
+        iter13.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.fully_reflected != None:
+      oprot.writeFieldBegin('fully_reflected', TType.BOOL, 3)
+      oprot.writeBool(self.fully_reflected)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+