--- /dev/null
+Copyright (C) 2009 Tomer Filiba, 2010-2011 Corbin Simpson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
-'construct' is the actual library (version 2, downloaded on 15.09.2010)
-Taken from http://construct.wikispaces.com/
-The code for version 2.00 has been released by the author into the public domain
+'construct' is the actual library, with my modifications for Python 3
+compatibility and various bug fixes.
+
+Taken from my fork: https://github.com/eliben/construct
+
+Take a look at LICENSE for the original license
--- /dev/null
+#-------------------------------------------------------------------------------
+# py3compat.py
+#
+# Some Python2&3 compatibility code
+#-------------------------------------------------------------------------------
+import sys
+PY3 = sys.version_info[0] == 3
+
+
+if PY3:
+ import io
+ StringIO = io.StringIO
+ BytesIO = io.BytesIO
+
+ def bchr(i):
+ """ When iterating over b'...' in Python 2 you get single b'_' chars
+ and in Python 3 you get integers. Call bchr to always turn this
+ to single b'_' chars.
+ """
+ return bytes((i,))
+
+ def u(s):
+ return s
+
+ def int2byte(i):
+ return bytes((i,))
+
+ def byte2int(b):
+ return b
+
+ def str2bytes(s):
+ return s.encode("latin-1")
+
+ def str2unicode(s):
+ return s
+
+ def bytes2str(b):
+ return b.decode('latin-1')
+
+ def decodebytes(b, encoding):
+ return bytes(b, encoding)
+
+ advance_iterator = next
+
+else:
+ import cStringIO
+ StringIO = BytesIO = cStringIO.StringIO
+
+ int2byte = chr
+ byte2int = ord
+ bchr = lambda i: i
+
+ def u(s):
+ return unicode(s, "unicode_escape")
+
+ def str2bytes(s):
+ return s
+
+ def str2unicode(s):
+ return unicode(s, "unicode_escape")
+
+ def bytes2str(b):
+ return b
+
+ def decodebytes(b, encoding):
+ return b.decode(encoding)
+
+ def advance_iterator(it):
+ return it.next()
+