[arch-commits] Commit in mitmproxy/repos/community-testing-any (8 files)

Eli Schwartz eschwartz at archlinux.org
Wed Aug 1 05:37:01 UTC 2018


    Date: Wednesday, August 1, 2018 @ 05:37:00
  Author: eschwartz
Revision: 366182

archrelease: copy trunk to community-testing-any

Added:
  mitmproxy/repos/community-testing-any/PKGBUILD
    (from rev 366181, mitmproxy/trunk/PKGBUILD)
  mitmproxy/repos/community-testing-any/fix-test.patch
    (from rev 366181, mitmproxy/trunk/fix-test.patch)
  mitmproxy/repos/community-testing-any/h2-3.0.patch
    (from rev 366181, mitmproxy/trunk/h2-3.0.patch)
  mitmproxy/repos/community-testing-any/kaitai-0.7.patch
    (from rev 366181, mitmproxy/trunk/kaitai-0.7.patch)
Deleted:
  mitmproxy/repos/community-testing-any/PKGBUILD
  mitmproxy/repos/community-testing-any/fix-test.patch
  mitmproxy/repos/community-testing-any/h2-3.0.patch
  mitmproxy/repos/community-testing-any/kaitai-0.7.patch

------------------+
 PKGBUILD         |  106 +++---
 fix-test.patch   |   46 +--
 h2-3.0.patch     |  162 +++++-----
 kaitai-0.7.patch |  812 ++++++++++++++++++++++++++---------------------------
 4 files changed, 570 insertions(+), 556 deletions(-)

Deleted: PKGBUILD
===================================================================
--- PKGBUILD	2018-08-01 05:36:37 UTC (rev 366181)
+++ PKGBUILD	2018-08-01 05:37:00 UTC (rev 366182)
@@ -1,46 +0,0 @@
-# $Id$
-# Maintainer: Felix Yan <felixonmars at archlinux.org>
-# Contributor: Simon 'ALSimon' Gilliot <simon at gilliot.fr>
-# Contributor: Olivier Biesmans <olivier at biesmans dot fr>
-
-pkgname=mitmproxy
-pkgver=3.0.4
-pkgrel=1
-pkgdesc="SSL-capable man-in-the-middle HTTP proxy"
-arch=('any')
-url="http://mitmproxy.org/"
-license=('GPL')
-depends=('python-blinker' 'python-brotlipy' 'python-click' 'python-cryptography' 'python-h11'
-         'python-h2' 'python-hyperframe' 'python-kaitaistruct' 'python-ldap3' 'python-passlib'
-         'python-pyasn1' 'python-pyopenssl' 'python-pyparsing' 'python-pyperclip' 'python-requests'
-         'python-ruamel-yaml' 'python-setuptools' 'python-sortedcontainers' 'python-tornado'
-         'python-urwid' 'python-wsproto')
-checkdepends=('python-beautifulsoup4' 'python-flask' 'python-pytest-runner')
-provides=('pathod')
-conflicts=('pathod')
-replaces=('pathod')
-source=("$pkgname-$pkgver.tar.gz::https://github.com/mitmproxy/mitmproxy/archive/v$pkgver.tar.gz")
-sha512sums=('a89b0bee6997ce51d23483101755dae9f5300339d65e4975679df5c6b60ff9af94e655651321cd8e831666a04ec5cc24c7af647f3aab913524b6755b47f1f57b')
-
-prepare() {
-  cd mitmproxy-$pkgver
-
-  # Let's remove all the upper bounds and use system certificate store
-  sed -e '/certifi/d' \
-      -e 's/, *<[0-9=.]*//' \
-      -i setup.py
-  sed -e '/import certifi/d' \
-      -e 's|certifi.where()|"/etc/ssl/certs/ca-certificates.crt"|' \
-      -i mitmproxy/net/tls.py
-}
-
-check() {
-  cd mitmproxy-$pkgver
-  # https://github.com/mitmproxy/mitmproxy/issues/2892
-  python setup.py pytest
-}
-
-package() {
-  cd mitmproxy-$pkgver
-  python setup.py install --root="$pkgdir" -O1
-}

Copied: mitmproxy/repos/community-testing-any/PKGBUILD (from rev 366181, mitmproxy/trunk/PKGBUILD)
===================================================================
--- PKGBUILD	                        (rev 0)
+++ PKGBUILD	2018-08-01 05:37:00 UTC (rev 366182)
@@ -0,0 +1,60 @@
+# $Id$
+# Maintainer: Felix Yan <felixonmars at archlinux.org>
+# Contributor: Simon 'ALSimon' Gilliot <simon at gilliot.fr>
+# Contributor: Olivier Biesmans <olivier at biesmans dot fr>
+
+pkgname=mitmproxy
+pkgver=3.0.4
+pkgrel=2
+pkgdesc="SSL-capable man-in-the-middle HTTP proxy"
+arch=('any')
+url="https://mitmproxy.org/"
+license=('GPL')
+depends=('python-blinker' 'python-brotlipy' 'python-click' 'python-cryptography' 'python-h11'
+         'python-h2' 'python-hyperframe' 'python-kaitaistruct' 'python-ldap3' 'python-passlib'
+         'python-pyasn1' 'python-pyopenssl' 'python-pyparsing' 'python-pyperclip' 'python-requests'
+         'python-ruamel-yaml' 'python-setuptools' 'python-sortedcontainers' 'python-tornado'
+         'python-urwid' 'python-wsproto')
+checkdepends=('python-beautifulsoup4' 'python-flask' 'python-pytest-runner')
+provides=('pathod')
+conflicts=('pathod')
+replaces=('pathod')
+source=("$pkgname-$pkgver.tar.gz::https://github.com/mitmproxy/mitmproxy/archive/v$pkgver.tar.gz"
+        "https://github.com/mitmproxy/mitmproxy/commit/19ceb6f49a791e51106d1605fb47ff0e3155b434.patch"
+        "https://github.com/mitmproxy/mitmproxy/commit/9979be648750b6983b233ec3a8c3c644d8c332a1.patch")
+sha512sums=('a89b0bee6997ce51d23483101755dae9f5300339d65e4975679df5c6b60ff9af94e655651321cd8e831666a04ec5cc24c7af647f3aab913524b6755b47f1f57b'
+            '0dff8b425134b6c7dfbe40db039dbeeb5e45785bae55ec08056fd1d700cd1e1166bc2ef86d1378ceef81b6e93f9e094050daa04ed253cc3e33e31c7198f3f00d'
+            'e40a8e29cfcb88adcdc6c84f7a4ccfc1e90a7576f62f9eaf87aeef4a8eda3d78023684742f2c4c85162509e49466393aa055b9a51c8049a5d9e48735a3410a94')
+
+prepare() {
+  cd mitmproxy-$pkgver
+
+  # invalid syntax in pytest
+  patch -p1 -i ../19ceb6f49a791e51106d1605fb47ff0e3155b434.patch
+  # https://github.com/mitmproxy/mitmproxy/issues/3122
+  patch -p1 -i ../9979be648750b6983b233ec3a8c3c644d8c332a1.patch
+
+  # Let's remove all the upper bounds and use system certificate store
+  sed -e '/certifi/d' \
+      -e 's/, *<[0-9=.]*//' \
+      -i setup.py
+  sed -e '/import certifi/d' \
+      -e 's|certifi.where()|"/etc/ssl/certs/ca-certificates.crt"|' \
+      -i mitmproxy/net/tls.py
+}
+
+build() {
+  cd mitmproxy-$pkgver
+  python setup.py build
+}
+
+check() {
+  cd mitmproxy-$pkgver
+  # https://github.com/mitmproxy/mitmproxy/issues/2892
+  python setup.py pytest
+}
+
+package() {
+  cd mitmproxy-$pkgver
+  python setup.py install --root="$pkgdir" -O1
+}

Deleted: fix-test.patch
===================================================================
--- fix-test.patch	2018-08-01 05:36:37 UTC (rev 366181)
+++ fix-test.patch	2018-08-01 05:37:00 UTC (rev 366182)
@@ -1,23 +0,0 @@
-From b3525570929ba47c10d9d08696876c39487f7000 Mon Sep 17 00:00:00 2001
-From: Felix Yan <felixonmars at archlinux.org>
-Date: Thu, 16 Mar 2017 16:48:21 +0800
-Subject: [PATCH] Fix test_format_xml with dot in path
-
-When the path contains dot ".", replacing all dots will generate a non-exist result and raises a FileNotFoundError. Replacing only the last dot fixes this.
----
- test/mitmproxy/contentviews/test_xml_html.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/mitmproxy/contentviews/test_xml_html.py b/test/mitmproxy/contentviews/test_xml_html.py
-index 899ecfd..2b0aee4 100644
---- a/test/mitmproxy/contentviews/test_xml_html.py
-+++ b/test/mitmproxy/contentviews/test_xml_html.py
-@@ -23,7 +23,7 @@ def test_format_xml(filename):
-     path = data.path(filename)
-     with open(path) as f:
-         input = f.read()
--    with open(path.replace(".", "-formatted.")) as f:
-+    with open("-formatted.".join(path.rsplit(".", 1))) as f:
-         expected = f.read()
-     tokens = xml_html.tokenize(input)
-     assert xml_html.format_xml(tokens) == expected

Copied: mitmproxy/repos/community-testing-any/fix-test.patch (from rev 366181, mitmproxy/trunk/fix-test.patch)
===================================================================
--- fix-test.patch	                        (rev 0)
+++ fix-test.patch	2018-08-01 05:37:00 UTC (rev 366182)
@@ -0,0 +1,23 @@
+From b3525570929ba47c10d9d08696876c39487f7000 Mon Sep 17 00:00:00 2001
+From: Felix Yan <felixonmars at archlinux.org>
+Date: Thu, 16 Mar 2017 16:48:21 +0800
+Subject: [PATCH] Fix test_format_xml with dot in path
+
+When the path contains dot ".", replacing all dots will generate a non-exist result and raises a FileNotFoundError. Replacing only the last dot fixes this.
+---
+ test/mitmproxy/contentviews/test_xml_html.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/test/mitmproxy/contentviews/test_xml_html.py b/test/mitmproxy/contentviews/test_xml_html.py
+index 899ecfd..2b0aee4 100644
+--- a/test/mitmproxy/contentviews/test_xml_html.py
++++ b/test/mitmproxy/contentviews/test_xml_html.py
+@@ -23,7 +23,7 @@ def test_format_xml(filename):
+     path = data.path(filename)
+     with open(path) as f:
+         input = f.read()
+-    with open(path.replace(".", "-formatted.")) as f:
++    with open("-formatted.".join(path.rsplit(".", 1))) as f:
+         expected = f.read()
+     tokens = xml_html.tokenize(input)
+     assert xml_html.format_xml(tokens) == expected

Deleted: h2-3.0.patch
===================================================================
--- h2-3.0.patch	2018-08-01 05:36:37 UTC (rev 366181)
+++ h2-3.0.patch	2018-08-01 05:37:00 UTC (rev 366182)
@@ -1,81 +0,0 @@
-From ef9f0e22ea31745a91a131c193051d8df7a9eccf Mon Sep 17 00:00:00 2001
-From: Thomas Kriechbaumer <thomas at kriechbaumer.name>
-Date: Fri, 24 Mar 2017 19:24:28 +0100
-Subject: [PATCH] bump h2
-
----
- mitmproxy/proxy/protocol/http2.py           |  6 +++---
- setup.py                                    |  4 ++--
- test/mitmproxy/proxy/protocol/test_http2.py | 14 +++++++++++---
- 3 files changed, 16 insertions(+), 8 deletions(-)
-
-diff --git a/mitmproxy/proxy/protocol/http2.py b/mitmproxy/proxy/protocol/http2.py
-index a6e8a4dd9..c1812b3da 100644
---- a/mitmproxy/proxy/protocol/http2.py
-+++ b/mitmproxy/proxy/protocol/http2.py
-@@ -188,7 +188,7 @@ def _handle_data_received(self, eid, event, source_conn):
-             self.streams[eid].kill()
-             self.connections[source_conn].safe_reset_stream(
-                 event.stream_id,
--                h2.errors.REFUSED_STREAM
-+                h2.errors.ErrorCodes.REFUSED_STREAM
-             )
-             self.log("HTTP body too large. Limit is {}.".format(bsl), "info")
-         else:
-@@ -207,7 +207,7 @@ def _handle_stream_ended(self, eid):
- 
-     def _handle_stream_reset(self, eid, event, is_server, other_conn):
-         self.streams[eid].kill()
--        if eid in self.streams and event.error_code == h2.errors.CANCEL:
-+        if eid in self.streams and event.error_code == h2.errors.ErrorCodes.CANCEL:
-             if is_server:
-                 other_stream_id = self.streams[eid].client_stream_id
-             else:
-@@ -228,7 +228,7 @@ def _handle_connection_terminated(self, event, is_server):
-             event.last_stream_id,
-             event.additional_data), "info")
- 
--        if event.error_code != h2.errors.NO_ERROR:
-+        if event.error_code != h2.errors.ErrorCodes.NO_ERROR:
-             # Something terrible has happened - kill everything!
-             self.connections[self.client_conn].close_connection(
-                 error_code=event.error_code,
-diff --git a/test/mitmproxy/proxy/protocol/test_http2.py b/test/mitmproxy/proxy/protocol/test_http2.py
-index 1f695cc5f..23027c242 100644
---- a/test/mitmproxy/proxy/protocol/test_http2.py
-+++ b/test/mitmproxy/proxy/protocol/test_http2.py
-@@ -36,7 +36,11 @@ class _Http2ServerBase(net_tservers.ServerTestBase):
-     class handler(mitmproxy.net.tcp.BaseHandler):
- 
-         def handle(self):
--            h2_conn = h2.connection.H2Connection(client_side=False, header_encoding=False)
-+            config = h2.config.H2Configuration(
-+                client_side=False,
-+                validate_outbound_headers=False,
-+                validate_inbound_headers=False)
-+            h2_conn = h2.connection.H2Connection(config)
- 
-             preamble = self.rfile.read(24)
-             h2_conn.initiate_connection()
-@@ -138,7 +142,11 @@ def _setup_connection(self):
- 
-         client.convert_to_ssl(alpn_protos=[b'h2'])
- 
--        h2_conn = h2.connection.H2Connection(client_side=True, header_encoding=False)
-+        config = h2.config.H2Configuration(
-+            client_side=True,
-+            validate_outbound_headers=False,
-+            validate_inbound_headers=False)
-+        h2_conn = h2.connection.H2Connection(config)
-         h2_conn.initiate_connection()
-         client.wfile.write(h2_conn.data_to_send())
-         client.wfile.flush()
-@@ -756,7 +764,7 @@ class TestMaxConcurrentStreams(_Http2Test):
-     @classmethod
-     def setup_class(cls):
-         _Http2TestBase.setup_class()
--        _Http2ServerBase.setup_class(h2_server_settings={h2.settings.MAX_CONCURRENT_STREAMS: 2})
-+        _Http2ServerBase.setup_class(h2_server_settings={h2.settings.SettingCodes.MAX_CONCURRENT_STREAMS: 2})
- 
-     @classmethod
-     def handle_server_event(cls, event, h2_conn, rfile, wfile):

Copied: mitmproxy/repos/community-testing-any/h2-3.0.patch (from rev 366181, mitmproxy/trunk/h2-3.0.patch)
===================================================================
--- h2-3.0.patch	                        (rev 0)
+++ h2-3.0.patch	2018-08-01 05:37:00 UTC (rev 366182)
@@ -0,0 +1,81 @@
+From ef9f0e22ea31745a91a131c193051d8df7a9eccf Mon Sep 17 00:00:00 2001
+From: Thomas Kriechbaumer <thomas at kriechbaumer.name>
+Date: Fri, 24 Mar 2017 19:24:28 +0100
+Subject: [PATCH] bump h2
+
+---
+ mitmproxy/proxy/protocol/http2.py           |  6 +++---
+ setup.py                                    |  4 ++--
+ test/mitmproxy/proxy/protocol/test_http2.py | 14 +++++++++++---
+ 3 files changed, 16 insertions(+), 8 deletions(-)
+
+diff --git a/mitmproxy/proxy/protocol/http2.py b/mitmproxy/proxy/protocol/http2.py
+index a6e8a4dd9..c1812b3da 100644
+--- a/mitmproxy/proxy/protocol/http2.py
++++ b/mitmproxy/proxy/protocol/http2.py
+@@ -188,7 +188,7 @@ def _handle_data_received(self, eid, event, source_conn):
+             self.streams[eid].kill()
+             self.connections[source_conn].safe_reset_stream(
+                 event.stream_id,
+-                h2.errors.REFUSED_STREAM
++                h2.errors.ErrorCodes.REFUSED_STREAM
+             )
+             self.log("HTTP body too large. Limit is {}.".format(bsl), "info")
+         else:
+@@ -207,7 +207,7 @@ def _handle_stream_ended(self, eid):
+ 
+     def _handle_stream_reset(self, eid, event, is_server, other_conn):
+         self.streams[eid].kill()
+-        if eid in self.streams and event.error_code == h2.errors.CANCEL:
++        if eid in self.streams and event.error_code == h2.errors.ErrorCodes.CANCEL:
+             if is_server:
+                 other_stream_id = self.streams[eid].client_stream_id
+             else:
+@@ -228,7 +228,7 @@ def _handle_connection_terminated(self, event, is_server):
+             event.last_stream_id,
+             event.additional_data), "info")
+ 
+-        if event.error_code != h2.errors.NO_ERROR:
++        if event.error_code != h2.errors.ErrorCodes.NO_ERROR:
+             # Something terrible has happened - kill everything!
+             self.connections[self.client_conn].close_connection(
+                 error_code=event.error_code,
+diff --git a/test/mitmproxy/proxy/protocol/test_http2.py b/test/mitmproxy/proxy/protocol/test_http2.py
+index 1f695cc5f..23027c242 100644
+--- a/test/mitmproxy/proxy/protocol/test_http2.py
++++ b/test/mitmproxy/proxy/protocol/test_http2.py
+@@ -36,7 +36,11 @@ class _Http2ServerBase(net_tservers.ServerTestBase):
+     class handler(mitmproxy.net.tcp.BaseHandler):
+ 
+         def handle(self):
+-            h2_conn = h2.connection.H2Connection(client_side=False, header_encoding=False)
++            config = h2.config.H2Configuration(
++                client_side=False,
++                validate_outbound_headers=False,
++                validate_inbound_headers=False)
++            h2_conn = h2.connection.H2Connection(config)
+ 
+             preamble = self.rfile.read(24)
+             h2_conn.initiate_connection()
+@@ -138,7 +142,11 @@ def _setup_connection(self):
+ 
+         client.convert_to_ssl(alpn_protos=[b'h2'])
+ 
+-        h2_conn = h2.connection.H2Connection(client_side=True, header_encoding=False)
++        config = h2.config.H2Configuration(
++            client_side=True,
++            validate_outbound_headers=False,
++            validate_inbound_headers=False)
++        h2_conn = h2.connection.H2Connection(config)
+         h2_conn.initiate_connection()
+         client.wfile.write(h2_conn.data_to_send())
+         client.wfile.flush()
+@@ -756,7 +764,7 @@ class TestMaxConcurrentStreams(_Http2Test):
+     @classmethod
+     def setup_class(cls):
+         _Http2TestBase.setup_class()
+-        _Http2ServerBase.setup_class(h2_server_settings={h2.settings.MAX_CONCURRENT_STREAMS: 2})
++        _Http2ServerBase.setup_class(h2_server_settings={h2.settings.SettingCodes.MAX_CONCURRENT_STREAMS: 2})
+ 
+     @classmethod
+     def handle_server_event(cls, event, h2_conn, rfile, wfile):

Deleted: kaitai-0.7.patch
===================================================================
--- kaitai-0.7.patch	2018-08-01 05:36:37 UTC (rev 366181)
+++ kaitai-0.7.patch	2018-08-01 05:37:00 UTC (rev 366182)
@@ -1,406 +0,0 @@
-From dadb50946e3ac489451bda079730e09f84e54d5a Mon Sep 17 00:00:00 2001
-From: Thomas Kriechbaumer <thomas at kriechbaumer.name>
-Date: Sun, 16 Apr 2017 15:05:58 +0200
-Subject: [PATCH] update kaitai and recompile formats
-
----
- .gitignore                                   |  1 +
- mitmproxy/contentviews/image/image_parser.py |  2 +-
- mitmproxy/contrib/kaitaistruct/exif.py       | 12 ++++++++----
- mitmproxy/contrib/kaitaistruct/exif_be.py    |  9 +++++++--
- mitmproxy/contrib/kaitaistruct/exif_le.py    |  9 +++++++--
- mitmproxy/contrib/kaitaistruct/gif.py        | 18 ++++++++++++------
- mitmproxy/contrib/kaitaistruct/jpeg.py       | 16 +++++++++++-----
- mitmproxy/contrib/kaitaistruct/make.sh       | 10 ++++++++++
- mitmproxy/contrib/kaitaistruct/png.py        | 26 ++++++++++++++++----------
- setup.py                                     |  2 +-
- 10 files changed, 74 insertions(+), 31 deletions(-)
- create mode 100755 mitmproxy/contrib/kaitaistruct/make.sh
-
-diff --git a/.gitignore b/.gitignore
-index c289ed5..915a81b 100644
---- a/.gitignore
-+++ b/.gitignore
-@@ -11,6 +11,7 @@ MANIFEST
- .cache/
- .tox*/
- build/
-+mitmproxy/contrib/kaitaistruct/*.ksy
- 
- # UI
- 
-diff --git a/mitmproxy/contentviews/image/image_parser.py b/mitmproxy/contentviews/image/image_parser.py
-index 062fb38..7c74669 100644
---- a/mitmproxy/contentviews/image/image_parser.py
-+++ b/mitmproxy/contentviews/image/image_parser.py
-@@ -37,7 +37,7 @@ def parse_gif(data: bytes) -> Metadata:
-     descriptor = img.logical_screen_descriptor
-     parts = [
-         ('Format', 'Compuserve GIF'),
--        ('Version', "GIF{}".format(img.header.version.decode('ASCII'))),
-+        ('Version', "GIF{}".format(img.hdr.version)),
-         ('Size', "{} x {} px".format(descriptor.screen_width, descriptor.screen_height)),
-         ('background', str(descriptor.bg_color_index))
-     ]
-diff --git a/mitmproxy/contrib/kaitaistruct/exif.py b/mitmproxy/contrib/kaitaistruct/exif.py
-index 6236a70..2e8f1f9 100644
---- a/mitmproxy/contrib/kaitaistruct/exif.py
-+++ b/mitmproxy/contrib/kaitaistruct/exif.py
-@@ -1,16 +1,18 @@
- # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
--# The source was exif.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/24e2d00048b8084ceec30a187a79cb87a79a48ba/image/exif.ksy
- 
- import array
- import struct
- import zlib
- from enum import Enum
-+from pkg_resources import parse_version
- 
--from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
-+from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
- 
- 
--from .exif_le import ExifLe
--from .exif_be import ExifBe
-+if parse_version(ks_version) < parse_version('0.7'):
-+    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
-+
-+from exif_le import ExifLe
- class Exif(KaitaiStruct):
-     def __init__(self, _io, _parent=None, _root=None):
-         self._io = _io
-@@ -22,3 +24,5 @@ def __init__(self, _io, _parent=None, _root=None):
-             self.body = ExifLe(self._io)
-         elif _on == 19789:
-             self.body = ExifBe(self._io)
-+
-+
-diff --git a/mitmproxy/contrib/kaitaistruct/exif_be.py b/mitmproxy/contrib/kaitaistruct/exif_be.py
-index 7980a9e..8a6e7a2 100644
---- a/mitmproxy/contrib/kaitaistruct/exif_be.py
-+++ b/mitmproxy/contrib/kaitaistruct/exif_be.py
-@@ -1,14 +1,17 @@
- # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
--# The source was exif_be.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/24e2d00048b8084ceec30a187a79cb87a79a48ba/image/exif_be.ksy
- 
- import array
- import struct
- import zlib
- from enum import Enum
-+from pkg_resources import parse_version
- 
--from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
-+from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
- 
- 
-+if parse_version(ks_version) < parse_version('0.7'):
-+    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
-+
- class ExifBe(KaitaiStruct):
-     def __init__(self, _io, _parent=None, _root=None):
-         self._io = _io
-@@ -569,3 +572,5 @@ def ifd0(self):
-         self._m_ifd0 = self._root.Ifd(self._io, self, self._root)
-         self._io.seek(_pos)
-         return self._m_ifd0 if hasattr(self, '_m_ifd0') else None
-+
-+
-diff --git a/mitmproxy/contrib/kaitaistruct/exif_le.py b/mitmproxy/contrib/kaitaistruct/exif_le.py
-index 207b3be..84e53a3 100644
---- a/mitmproxy/contrib/kaitaistruct/exif_le.py
-+++ b/mitmproxy/contrib/kaitaistruct/exif_le.py
-@@ -1,14 +1,17 @@
- # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
--# The source was exif_le.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/24e2d00048b8084ceec30a187a79cb87a79a48ba/image/exif_le.ksy
- 
- import array
- import struct
- import zlib
- from enum import Enum
-+from pkg_resources import parse_version
- 
--from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
-+from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
- 
- 
-+if parse_version(ks_version) < parse_version('0.7'):
-+    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
-+
- class ExifLe(KaitaiStruct):
-     def __init__(self, _io, _parent=None, _root=None):
-         self._io = _io
-@@ -569,3 +572,5 @@ def ifd0(self):
-         self._m_ifd0 = self._root.Ifd(self._io, self, self._root)
-         self._io.seek(_pos)
-         return self._m_ifd0 if hasattr(self, '_m_ifd0') else None
-+
-+
-diff --git a/mitmproxy/contrib/kaitaistruct/gif.py b/mitmproxy/contrib/kaitaistruct/gif.py
-index 61499cc..820df56 100644
---- a/mitmproxy/contrib/kaitaistruct/gif.py
-+++ b/mitmproxy/contrib/kaitaistruct/gif.py
-@@ -1,14 +1,17 @@
- # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
--# The source was png.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/562154250bea0081fed4e232751b934bc270a0c7/image/gif.ksy
- 
- import array
- import struct
- import zlib
- from enum import Enum
-+from pkg_resources import parse_version
- 
--from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
-+from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
- 
- 
-+if parse_version(ks_version) < parse_version('0.7'):
-+    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
-+
- class Gif(KaitaiStruct):
- 
-     class BlockType(Enum):
-@@ -24,8 +27,8 @@ def __init__(self, _io, _parent=None, _root=None):
-         self._io = _io
-         self._parent = _parent
-         self._root = _root if _root else self
--        self.header = self._root.Header(self._io, self, self._root)
--        self.logical_screen_descriptor = self._root.LogicalScreenDescriptor(self._io, self, self._root)
-+        self.hdr = self._root.Header(self._io, self, self._root)
-+        self.logical_screen_descriptor = self._root.LogicalScreenDescriptorStruct(self._io, self, self._root)
-         if self.logical_screen_descriptor.has_color_table:
-             self._raw_global_color_table = self._io.read_bytes((self.logical_screen_descriptor.color_table_size * 3))
-             io = KaitaiStream(BytesIO(self._raw_global_color_table))
-@@ -55,7 +58,7 @@ def __init__(self, _io, _parent=None, _root=None):
-             self.blue = self._io.read_u1()
- 
- 
--    class LogicalScreenDescriptor(KaitaiStruct):
-+    class LogicalScreenDescriptorStruct(KaitaiStruct):
-         def __init__(self, _io, _parent=None, _root=None):
-             self._io = _io
-             self._parent = _parent
-@@ -163,7 +166,7 @@ def __init__(self, _io, _parent=None, _root=None):
-             self._parent = _parent
-             self._root = _root if _root else self
-             self.magic = self._io.ensure_fixed_contents(struct.pack('3b', 71, 73, 70))
--            self.version = self._io.read_bytes(3)
-+            self.version = (self._io.read_bytes(3)).decode(u"ASCII")
- 
- 
-     class ExtGraphicControl(KaitaiStruct):
-@@ -245,3 +248,6 @@ def __init__(self, _io, _parent=None, _root=None):
-                 self.body = self._root.ExtGraphicControl(self._io, self, self._root)
-             else:
-                 self.body = self._root.Subblocks(self._io, self, self._root)
-+
-+
-+
-diff --git a/mitmproxy/contrib/kaitaistruct/jpeg.py b/mitmproxy/contrib/kaitaistruct/jpeg.py
-index 08e382a..a49c83b 100644
---- a/mitmproxy/contrib/kaitaistruct/jpeg.py
-+++ b/mitmproxy/contrib/kaitaistruct/jpeg.py
-@@ -1,15 +1,18 @@
- # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
--# The source was jpeg.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/24e2d00048b8084ceec30a187a79cb87a79a48ba/image/jpeg.ksy
- 
- import array
- import struct
- import zlib
- from enum import Enum
-+from pkg_resources import parse_version
- 
--from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
-+from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
- 
- 
--from .exif import Exif
-+if parse_version(ks_version) < parse_version('0.7'):
-+    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
-+
-+from exif import Exif
- class Jpeg(KaitaiStruct):
- 
-     class ComponentId(Enum):
-@@ -127,7 +130,7 @@ def __init__(self, _io, _parent=None, _root=None):
-             self._io = _io
-             self._parent = _parent
-             self._root = _root if _root else self
--            self.magic = self._io.read_strz("ASCII", 0, False, True, True)
-+            self.magic = (self._io.read_bytes_term(0, False, True, True)).decode(u"ASCII")
-             _on = self.magic
-             if _on == u"Exif":
-                 self.body = self._root.ExifInJpeg(self._io, self, self._root)
-@@ -195,7 +198,7 @@ def __init__(self, _io, _parent=None, _root=None):
-             self._io = _io
-             self._parent = _parent
-             self._root = _root if _root else self
--            self.magic = self._io.read_str_byte_limit(5, "ASCII")
-+            self.magic = (self._io.read_bytes(5)).decode(u"ASCII")
-             self.version_major = self._io.read_u1()
-             self.version_minor = self._io.read_u1()
-             self.density_units = self._root.SegmentApp0.DensityUnit(self._io.read_u1())
-@@ -204,3 +207,6 @@ def __init__(self, _io, _parent=None, _root=None):
-             self.thumbnail_x = self._io.read_u1()
-             self.thumbnail_y = self._io.read_u1()
-             self.thumbnail = self._io.read_bytes(((self.thumbnail_x * self.thumbnail_y) * 3))
-+
-+
-+
-diff --git a/mitmproxy/contrib/kaitaistruct/make.sh b/mitmproxy/contrib/kaitaistruct/make.sh
-new file mode 100755
-index 0000000..218d519
---- /dev/null
-+++ b/mitmproxy/contrib/kaitaistruct/make.sh
-@@ -0,0 +1,10 @@
-+#!/usr/bin/env bash
-+
-+wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/exif_be.ksy
-+wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/exif_le.ksy
-+wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/exif.ksy
-+wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/gif.ksy
-+wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/jpeg.ksy
-+wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/png.ksy
-+
-+kaitai-struct-compiler --target python --opaque-types=true *.ksy
-diff --git a/mitmproxy/contrib/kaitaistruct/png.py b/mitmproxy/contrib/kaitaistruct/png.py
-index 2f3c1a5..98a7069 100644
---- a/mitmproxy/contrib/kaitaistruct/png.py
-+++ b/mitmproxy/contrib/kaitaistruct/png.py
-@@ -1,14 +1,17 @@
- # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
--# The source was png.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/9370c720b7d2ad329102d89bdc880ba6a706ef26/image/png.ksy
- 
- import array
- import struct
- import zlib
- from enum import Enum
-+from pkg_resources import parse_version
- 
--from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
-+from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
- 
- 
-+if parse_version(ks_version) < parse_version('0.7'):
-+    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
-+
- class Png(KaitaiStruct):
- 
-     class ColorType(Enum):
-@@ -51,7 +54,7 @@ def __init__(self, _io, _parent=None, _root=None):
-             self._parent = _parent
-             self._root = _root if _root else self
-             self.len = self._io.read_u4be()
--            self.type = self._io.read_str_byte_limit(4, "UTF-8")
-+            self.type = (self._io.read_bytes(4)).decode(u"UTF-8")
-             _on = self.type
-             if _on == u"iTXt":
-                 self._raw_body = self._io.read_bytes(self.len)
-@@ -194,7 +197,7 @@ def __init__(self, _io, _parent=None, _root=None):
-             self._io = _io
-             self._parent = _parent
-             self._root = _root if _root else self
--            self.keyword = self._io.read_strz("UTF-8", 0, False, True, True)
-+            self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"UTF-8")
-             self.compression_method = self._io.read_u1()
-             self._raw_text_datastream = self._io.read_bytes_full()
-             self.text_datastream = zlib.decompress(self._raw_text_datastream)
-@@ -259,12 +262,12 @@ def __init__(self, _io, _parent=None, _root=None):
-             self._io = _io
-             self._parent = _parent
-             self._root = _root if _root else self
--            self.keyword = self._io.read_strz("UTF-8", 0, False, True, True)
-+            self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"UTF-8")
-             self.compression_flag = self._io.read_u1()
-             self.compression_method = self._io.read_u1()
--            self.language_tag = self._io.read_strz("ASCII", 0, False, True, True)
--            self.translated_keyword = self._io.read_strz("UTF-8", 0, False, True, True)
--            self.text = self._io.read_str_eos("UTF-8")
-+            self.language_tag = (self._io.read_bytes_term(0, False, True, True)).decode(u"ASCII")
-+            self.translated_keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"UTF-8")
-+            self.text = (self._io.read_bytes_full()).decode(u"UTF-8")
- 
- 
-     class TextChunk(KaitaiStruct):
-@@ -272,8 +275,8 @@ def __init__(self, _io, _parent=None, _root=None):
-             self._io = _io
-             self._parent = _parent
-             self._root = _root if _root else self
--            self.keyword = self._io.read_strz("iso8859-1", 0, False, True, True)
--            self.text = self._io.read_str_eos("iso8859-1")
-+            self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"iso8859-1")
-+            self.text = (self._io.read_bytes_full()).decode(u"iso8859-1")
- 
- 
-     class TimeChunk(KaitaiStruct):
-@@ -287,3 +290,6 @@ def __init__(self, _io, _parent=None, _root=None):
-             self.hour = self._io.read_u1()
-             self.minute = self._io.read_u1()
-             self.second = self._io.read_u1()
-+
-+
-+
-diff --git a/setup.py b/setup.py
-index a758a31..cb25454 100644
---- a/setup.py
-+++ b/setup.py
-@@ -70,7 +70,7 @@
-         "html2text>=2016.1.8, <=2016.9.19",
-         "hyperframe>=5.0, <6",
-         "jsbeautifier>=1.6.3, <1.7",
--        "kaitaistruct>=0.6, <0.7",
-+        "kaitaistruct>=0.7, <0.8",
-         "passlib>=1.6.5, <1.8",
-         "pyasn1>=0.1.9, <0.3",
-         "pyOpenSSL>=16.0, <17.0",
-From 83a428e0b712a5283525db911acb68d393c64fcb Mon Sep 17 00:00:00 2001
-From: Thomas Kriechbaumer <thomas at kriechbaumer.name>
-Date: Sun, 16 Apr 2017 15:17:29 +0200
-Subject: [PATCH] manually fix imports
-
----
- mitmproxy/contrib/kaitaistruct/exif.py | 6 +++---
- mitmproxy/contrib/kaitaistruct/jpeg.py | 6 ++----
- 2 files changed, 5 insertions(+), 7 deletions(-)
-
-diff --git a/mitmproxy/contrib/kaitaistruct/exif.py b/mitmproxy/contrib/kaitaistruct/exif.py
-index 2e8f1f9..d99ccee 100644
---- a/mitmproxy/contrib/kaitaistruct/exif.py
-+++ b/mitmproxy/contrib/kaitaistruct/exif.py
-@@ -12,7 +12,9 @@
- if parse_version(ks_version) < parse_version('0.7'):
-     raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
- 
--from exif_le import ExifLe
-+from .exif_le import ExifLe
-+from .exif_be import ExifBe
-+
- class Exif(KaitaiStruct):
-     def __init__(self, _io, _parent=None, _root=None):
-         self._io = _io
-@@ -24,5 +26,3 @@ def __init__(self, _io, _parent=None, _root=None):
-             self.body = ExifLe(self._io)
-         elif _on == 19789:
-             self.body = ExifBe(self._io)
--
--
-diff --git a/mitmproxy/contrib/kaitaistruct/jpeg.py b/mitmproxy/contrib/kaitaistruct/jpeg.py
-index a49c83b..33fc012 100644
---- a/mitmproxy/contrib/kaitaistruct/jpeg.py
-+++ b/mitmproxy/contrib/kaitaistruct/jpeg.py
-@@ -12,7 +12,8 @@
- if parse_version(ks_version) < parse_version('0.7'):
-     raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
- 
--from exif import Exif
-+from .exif import Exif
-+
- class Jpeg(KaitaiStruct):
- 
-     class ComponentId(Enum):
-@@ -207,6 +208,3 @@ def __init__(self, _io, _parent=None, _root=None):
-             self.thumbnail_x = self._io.read_u1()
-             self.thumbnail_y = self._io.read_u1()
-             self.thumbnail = self._io.read_bytes(((self.thumbnail_x * self.thumbnail_y) * 3))
--
--
--

Copied: mitmproxy/repos/community-testing-any/kaitai-0.7.patch (from rev 366181, mitmproxy/trunk/kaitai-0.7.patch)
===================================================================
--- kaitai-0.7.patch	                        (rev 0)
+++ kaitai-0.7.patch	2018-08-01 05:37:00 UTC (rev 366182)
@@ -0,0 +1,406 @@
+From dadb50946e3ac489451bda079730e09f84e54d5a Mon Sep 17 00:00:00 2001
+From: Thomas Kriechbaumer <thomas at kriechbaumer.name>
+Date: Sun, 16 Apr 2017 15:05:58 +0200
+Subject: [PATCH] update kaitai and recompile formats
+
+---
+ .gitignore                                   |  1 +
+ mitmproxy/contentviews/image/image_parser.py |  2 +-
+ mitmproxy/contrib/kaitaistruct/exif.py       | 12 ++++++++----
+ mitmproxy/contrib/kaitaistruct/exif_be.py    |  9 +++++++--
+ mitmproxy/contrib/kaitaistruct/exif_le.py    |  9 +++++++--
+ mitmproxy/contrib/kaitaistruct/gif.py        | 18 ++++++++++++------
+ mitmproxy/contrib/kaitaistruct/jpeg.py       | 16 +++++++++++-----
+ mitmproxy/contrib/kaitaistruct/make.sh       | 10 ++++++++++
+ mitmproxy/contrib/kaitaistruct/png.py        | 26 ++++++++++++++++----------
+ setup.py                                     |  2 +-
+ 10 files changed, 74 insertions(+), 31 deletions(-)
+ create mode 100755 mitmproxy/contrib/kaitaistruct/make.sh
+
+diff --git a/.gitignore b/.gitignore
+index c289ed5..915a81b 100644
+--- a/.gitignore
++++ b/.gitignore
+@@ -11,6 +11,7 @@ MANIFEST
+ .cache/
+ .tox*/
+ build/
++mitmproxy/contrib/kaitaistruct/*.ksy
+ 
+ # UI
+ 
+diff --git a/mitmproxy/contentviews/image/image_parser.py b/mitmproxy/contentviews/image/image_parser.py
+index 062fb38..7c74669 100644
+--- a/mitmproxy/contentviews/image/image_parser.py
++++ b/mitmproxy/contentviews/image/image_parser.py
+@@ -37,7 +37,7 @@ def parse_gif(data: bytes) -> Metadata:
+     descriptor = img.logical_screen_descriptor
+     parts = [
+         ('Format', 'Compuserve GIF'),
+-        ('Version', "GIF{}".format(img.header.version.decode('ASCII'))),
++        ('Version', "GIF{}".format(img.hdr.version)),
+         ('Size', "{} x {} px".format(descriptor.screen_width, descriptor.screen_height)),
+         ('background', str(descriptor.bg_color_index))
+     ]
+diff --git a/mitmproxy/contrib/kaitaistruct/exif.py b/mitmproxy/contrib/kaitaistruct/exif.py
+index 6236a70..2e8f1f9 100644
+--- a/mitmproxy/contrib/kaitaistruct/exif.py
++++ b/mitmproxy/contrib/kaitaistruct/exif.py
+@@ -1,16 +1,18 @@
+ # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
+-# The source was exif.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/24e2d00048b8084ceec30a187a79cb87a79a48ba/image/exif.ksy
+ 
+ import array
+ import struct
+ import zlib
+ from enum import Enum
++from pkg_resources import parse_version
+ 
+-from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
++from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
+ 
+ 
+-from .exif_le import ExifLe
+-from .exif_be import ExifBe
++if parse_version(ks_version) < parse_version('0.7'):
++    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
++
++from exif_le import ExifLe
+ class Exif(KaitaiStruct):
+     def __init__(self, _io, _parent=None, _root=None):
+         self._io = _io
+@@ -22,3 +24,5 @@ def __init__(self, _io, _parent=None, _root=None):
+             self.body = ExifLe(self._io)
+         elif _on == 19789:
+             self.body = ExifBe(self._io)
++
++
+diff --git a/mitmproxy/contrib/kaitaistruct/exif_be.py b/mitmproxy/contrib/kaitaistruct/exif_be.py
+index 7980a9e..8a6e7a2 100644
+--- a/mitmproxy/contrib/kaitaistruct/exif_be.py
++++ b/mitmproxy/contrib/kaitaistruct/exif_be.py
+@@ -1,14 +1,17 @@
+ # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
+-# The source was exif_be.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/24e2d00048b8084ceec30a187a79cb87a79a48ba/image/exif_be.ksy
+ 
+ import array
+ import struct
+ import zlib
+ from enum import Enum
++from pkg_resources import parse_version
+ 
+-from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
++from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
+ 
+ 
++if parse_version(ks_version) < parse_version('0.7'):
++    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
++
+ class ExifBe(KaitaiStruct):
+     def __init__(self, _io, _parent=None, _root=None):
+         self._io = _io
+@@ -569,3 +572,5 @@ def ifd0(self):
+         self._m_ifd0 = self._root.Ifd(self._io, self, self._root)
+         self._io.seek(_pos)
+         return self._m_ifd0 if hasattr(self, '_m_ifd0') else None
++
++
+diff --git a/mitmproxy/contrib/kaitaistruct/exif_le.py b/mitmproxy/contrib/kaitaistruct/exif_le.py
+index 207b3be..84e53a3 100644
+--- a/mitmproxy/contrib/kaitaistruct/exif_le.py
++++ b/mitmproxy/contrib/kaitaistruct/exif_le.py
+@@ -1,14 +1,17 @@
+ # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
+-# The source was exif_le.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/24e2d00048b8084ceec30a187a79cb87a79a48ba/image/exif_le.ksy
+ 
+ import array
+ import struct
+ import zlib
+ from enum import Enum
++from pkg_resources import parse_version
+ 
+-from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
++from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
+ 
+ 
++if parse_version(ks_version) < parse_version('0.7'):
++    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
++
+ class ExifLe(KaitaiStruct):
+     def __init__(self, _io, _parent=None, _root=None):
+         self._io = _io
+@@ -569,3 +572,5 @@ def ifd0(self):
+         self._m_ifd0 = self._root.Ifd(self._io, self, self._root)
+         self._io.seek(_pos)
+         return self._m_ifd0 if hasattr(self, '_m_ifd0') else None
++
++
+diff --git a/mitmproxy/contrib/kaitaistruct/gif.py b/mitmproxy/contrib/kaitaistruct/gif.py
+index 61499cc..820df56 100644
+--- a/mitmproxy/contrib/kaitaistruct/gif.py
++++ b/mitmproxy/contrib/kaitaistruct/gif.py
+@@ -1,14 +1,17 @@
+ # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
+-# The source was png.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/562154250bea0081fed4e232751b934bc270a0c7/image/gif.ksy
+ 
+ import array
+ import struct
+ import zlib
+ from enum import Enum
++from pkg_resources import parse_version
+ 
+-from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
++from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
+ 
+ 
++if parse_version(ks_version) < parse_version('0.7'):
++    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
++
+ class Gif(KaitaiStruct):
+ 
+     class BlockType(Enum):
+@@ -24,8 +27,8 @@ def __init__(self, _io, _parent=None, _root=None):
+         self._io = _io
+         self._parent = _parent
+         self._root = _root if _root else self
+-        self.header = self._root.Header(self._io, self, self._root)
+-        self.logical_screen_descriptor = self._root.LogicalScreenDescriptor(self._io, self, self._root)
++        self.hdr = self._root.Header(self._io, self, self._root)
++        self.logical_screen_descriptor = self._root.LogicalScreenDescriptorStruct(self._io, self, self._root)
+         if self.logical_screen_descriptor.has_color_table:
+             self._raw_global_color_table = self._io.read_bytes((self.logical_screen_descriptor.color_table_size * 3))
+             io = KaitaiStream(BytesIO(self._raw_global_color_table))
+@@ -55,7 +58,7 @@ def __init__(self, _io, _parent=None, _root=None):
+             self.blue = self._io.read_u1()
+ 
+ 
+-    class LogicalScreenDescriptor(KaitaiStruct):
++    class LogicalScreenDescriptorStruct(KaitaiStruct):
+         def __init__(self, _io, _parent=None, _root=None):
+             self._io = _io
+             self._parent = _parent
+@@ -163,7 +166,7 @@ def __init__(self, _io, _parent=None, _root=None):
+             self._parent = _parent
+             self._root = _root if _root else self
+             self.magic = self._io.ensure_fixed_contents(struct.pack('3b', 71, 73, 70))
+-            self.version = self._io.read_bytes(3)
++            self.version = (self._io.read_bytes(3)).decode(u"ASCII")
+ 
+ 
+     class ExtGraphicControl(KaitaiStruct):
+@@ -245,3 +248,6 @@ def __init__(self, _io, _parent=None, _root=None):
+                 self.body = self._root.ExtGraphicControl(self._io, self, self._root)
+             else:
+                 self.body = self._root.Subblocks(self._io, self, self._root)
++
++
++
+diff --git a/mitmproxy/contrib/kaitaistruct/jpeg.py b/mitmproxy/contrib/kaitaistruct/jpeg.py
+index 08e382a..a49c83b 100644
+--- a/mitmproxy/contrib/kaitaistruct/jpeg.py
++++ b/mitmproxy/contrib/kaitaistruct/jpeg.py
+@@ -1,15 +1,18 @@
+ # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
+-# The source was jpeg.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/24e2d00048b8084ceec30a187a79cb87a79a48ba/image/jpeg.ksy
+ 
+ import array
+ import struct
+ import zlib
+ from enum import Enum
++from pkg_resources import parse_version
+ 
+-from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
++from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
+ 
+ 
+-from .exif import Exif
++if parse_version(ks_version) < parse_version('0.7'):
++    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
++
++from exif import Exif
+ class Jpeg(KaitaiStruct):
+ 
+     class ComponentId(Enum):
+@@ -127,7 +130,7 @@ def __init__(self, _io, _parent=None, _root=None):
+             self._io = _io
+             self._parent = _parent
+             self._root = _root if _root else self
+-            self.magic = self._io.read_strz("ASCII", 0, False, True, True)
++            self.magic = (self._io.read_bytes_term(0, False, True, True)).decode(u"ASCII")
+             _on = self.magic
+             if _on == u"Exif":
+                 self.body = self._root.ExifInJpeg(self._io, self, self._root)
+@@ -195,7 +198,7 @@ def __init__(self, _io, _parent=None, _root=None):
+             self._io = _io
+             self._parent = _parent
+             self._root = _root if _root else self
+-            self.magic = self._io.read_str_byte_limit(5, "ASCII")
++            self.magic = (self._io.read_bytes(5)).decode(u"ASCII")
+             self.version_major = self._io.read_u1()
+             self.version_minor = self._io.read_u1()
+             self.density_units = self._root.SegmentApp0.DensityUnit(self._io.read_u1())
+@@ -204,3 +207,6 @@ def __init__(self, _io, _parent=None, _root=None):
+             self.thumbnail_x = self._io.read_u1()
+             self.thumbnail_y = self._io.read_u1()
+             self.thumbnail = self._io.read_bytes(((self.thumbnail_x * self.thumbnail_y) * 3))
++
++
++
+diff --git a/mitmproxy/contrib/kaitaistruct/make.sh b/mitmproxy/contrib/kaitaistruct/make.sh
+new file mode 100755
+index 0000000..218d519
+--- /dev/null
++++ b/mitmproxy/contrib/kaitaistruct/make.sh
+@@ -0,0 +1,10 @@
++#!/usr/bin/env bash
++
++wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/exif_be.ksy
++wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/exif_le.ksy
++wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/exif.ksy
++wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/gif.ksy
++wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/jpeg.ksy
++wget -N https://raw.githubusercontent.com/kaitai-io/kaitai_struct_formats/master/image/png.ksy
++
++kaitai-struct-compiler --target python --opaque-types=true *.ksy
+diff --git a/mitmproxy/contrib/kaitaistruct/png.py b/mitmproxy/contrib/kaitaistruct/png.py
+index 2f3c1a5..98a7069 100644
+--- a/mitmproxy/contrib/kaitaistruct/png.py
++++ b/mitmproxy/contrib/kaitaistruct/png.py
+@@ -1,14 +1,17 @@
+ # This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
+-# The source was png.ksy from here - https://github.com/kaitai-io/kaitai_struct_formats/blob/9370c720b7d2ad329102d89bdc880ba6a706ef26/image/png.ksy
+ 
+ import array
+ import struct
+ import zlib
+ from enum import Enum
++from pkg_resources import parse_version
+ 
+-from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
++from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
+ 
+ 
++if parse_version(ks_version) < parse_version('0.7'):
++    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
++
+ class Png(KaitaiStruct):
+ 
+     class ColorType(Enum):
+@@ -51,7 +54,7 @@ def __init__(self, _io, _parent=None, _root=None):
+             self._parent = _parent
+             self._root = _root if _root else self
+             self.len = self._io.read_u4be()
+-            self.type = self._io.read_str_byte_limit(4, "UTF-8")
++            self.type = (self._io.read_bytes(4)).decode(u"UTF-8")
+             _on = self.type
+             if _on == u"iTXt":
+                 self._raw_body = self._io.read_bytes(self.len)
+@@ -194,7 +197,7 @@ def __init__(self, _io, _parent=None, _root=None):
+             self._io = _io
+             self._parent = _parent
+             self._root = _root if _root else self
+-            self.keyword = self._io.read_strz("UTF-8", 0, False, True, True)
++            self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"UTF-8")
+             self.compression_method = self._io.read_u1()
+             self._raw_text_datastream = self._io.read_bytes_full()
+             self.text_datastream = zlib.decompress(self._raw_text_datastream)
+@@ -259,12 +262,12 @@ def __init__(self, _io, _parent=None, _root=None):
+             self._io = _io
+             self._parent = _parent
+             self._root = _root if _root else self
+-            self.keyword = self._io.read_strz("UTF-8", 0, False, True, True)
++            self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"UTF-8")
+             self.compression_flag = self._io.read_u1()
+             self.compression_method = self._io.read_u1()
+-            self.language_tag = self._io.read_strz("ASCII", 0, False, True, True)
+-            self.translated_keyword = self._io.read_strz("UTF-8", 0, False, True, True)
+-            self.text = self._io.read_str_eos("UTF-8")
++            self.language_tag = (self._io.read_bytes_term(0, False, True, True)).decode(u"ASCII")
++            self.translated_keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"UTF-8")
++            self.text = (self._io.read_bytes_full()).decode(u"UTF-8")
+ 
+ 
+     class TextChunk(KaitaiStruct):
+@@ -272,8 +275,8 @@ def __init__(self, _io, _parent=None, _root=None):
+             self._io = _io
+             self._parent = _parent
+             self._root = _root if _root else self
+-            self.keyword = self._io.read_strz("iso8859-1", 0, False, True, True)
+-            self.text = self._io.read_str_eos("iso8859-1")
++            self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"iso8859-1")
++            self.text = (self._io.read_bytes_full()).decode(u"iso8859-1")
+ 
+ 
+     class TimeChunk(KaitaiStruct):
+@@ -287,3 +290,6 @@ def __init__(self, _io, _parent=None, _root=None):
+             self.hour = self._io.read_u1()
+             self.minute = self._io.read_u1()
+             self.second = self._io.read_u1()
++
++
++
+diff --git a/setup.py b/setup.py
+index a758a31..cb25454 100644
+--- a/setup.py
++++ b/setup.py
+@@ -70,7 +70,7 @@
+         "html2text>=2016.1.8, <=2016.9.19",
+         "hyperframe>=5.0, <6",
+         "jsbeautifier>=1.6.3, <1.7",
+-        "kaitaistruct>=0.6, <0.7",
++        "kaitaistruct>=0.7, <0.8",
+         "passlib>=1.6.5, <1.8",
+         "pyasn1>=0.1.9, <0.3",
+         "pyOpenSSL>=16.0, <17.0",
+From 83a428e0b712a5283525db911acb68d393c64fcb Mon Sep 17 00:00:00 2001
+From: Thomas Kriechbaumer <thomas at kriechbaumer.name>
+Date: Sun, 16 Apr 2017 15:17:29 +0200
+Subject: [PATCH] manually fix imports
+
+---
+ mitmproxy/contrib/kaitaistruct/exif.py | 6 +++---
+ mitmproxy/contrib/kaitaistruct/jpeg.py | 6 ++----
+ 2 files changed, 5 insertions(+), 7 deletions(-)
+
+diff --git a/mitmproxy/contrib/kaitaistruct/exif.py b/mitmproxy/contrib/kaitaistruct/exif.py
+index 2e8f1f9..d99ccee 100644
+--- a/mitmproxy/contrib/kaitaistruct/exif.py
++++ b/mitmproxy/contrib/kaitaistruct/exif.py
+@@ -12,7 +12,9 @@
+ if parse_version(ks_version) < parse_version('0.7'):
+     raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
+ 
+-from exif_le import ExifLe
++from .exif_le import ExifLe
++from .exif_be import ExifBe
++
+ class Exif(KaitaiStruct):
+     def __init__(self, _io, _parent=None, _root=None):
+         self._io = _io
+@@ -24,5 +26,3 @@ def __init__(self, _io, _parent=None, _root=None):
+             self.body = ExifLe(self._io)
+         elif _on == 19789:
+             self.body = ExifBe(self._io)
+-
+-
+diff --git a/mitmproxy/contrib/kaitaistruct/jpeg.py b/mitmproxy/contrib/kaitaistruct/jpeg.py
+index a49c83b..33fc012 100644
+--- a/mitmproxy/contrib/kaitaistruct/jpeg.py
++++ b/mitmproxy/contrib/kaitaistruct/jpeg.py
+@@ -12,7 +12,8 @@
+ if parse_version(ks_version) < parse_version('0.7'):
+     raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
+ 
+-from exif import Exif
++from .exif import Exif
++
+ class Jpeg(KaitaiStruct):
+ 
+     class ComponentId(Enum):
+@@ -207,6 +208,3 @@ def __init__(self, _io, _parent=None, _root=None):
+             self.thumbnail_x = self._io.read_u1()
+             self.thumbnail_y = self._io.read_u1()
+             self.thumbnail = self._io.read_bytes(((self.thumbnail_x * self.thumbnail_y) * 3))
+-
+-
+-



More information about the arch-commits mailing list