Factor out an io module

Include tnetstring - we've made enough changes that this no longer belongs in
contrib.
This commit is contained in:
Aldo Cortesi 2017-03-20 12:50:09 +13:00
parent 3a8da31835
commit 4ca78604af
9 changed files with 13 additions and 6 deletions

7
mitmproxy/io/__init__.py Normal file
View File

@ -0,0 +1,7 @@
from .io import FlowWriter, FlowReader, FilteredFlowWriter, read_flows_from_paths
__all__ = [
"FlowWriter", "FlowReader", "FilteredFlowWriter", "read_flows_from_paths"
]

View File

@ -7,9 +7,9 @@ from mitmproxy import flowfilter
from mitmproxy import http
from mitmproxy import tcp
from mitmproxy import websocket
from mitmproxy.contrib import tnetstring
from mitmproxy import io_compat
from mitmproxy.io import compat
from mitmproxy.io import tnetstring
FLOW_TYPES = dict(
http=http.HTTPFlow,
@ -43,7 +43,7 @@ class FlowReader:
tnetstring.load(self.fo),
)
try:
mdata = io_compat.migrate_flow(loaded)
mdata = compat.migrate_flow(loaded)
except ValueError as e:
raise exceptions.FlowReadException(str(e))
if mdata["type"] not in FLOW_TYPES:

View File

@ -4,7 +4,7 @@ import math
import io
import struct
from mitmproxy.contrib import tnetstring
from mitmproxy.io import tnetstring
MAXINT = 2 ** (struct.Struct('i').size * 8 - 1) - 1

View File

@ -6,7 +6,7 @@ import mitmproxy.io
from mitmproxy import flowfilter
from mitmproxy import options
from mitmproxy.proxy import config
from mitmproxy.contrib import tnetstring
from mitmproxy.io import tnetstring
from mitmproxy.exceptions import FlowReadException
from mitmproxy import flow
from mitmproxy import http

View File

@ -1,7 +1,7 @@
import io
import pytest
from mitmproxy.contrib import tnetstring
from mitmproxy.io import tnetstring
from mitmproxy import flowfilter
from mitmproxy.test import tflow