From f45f4e677e8cddba8160d1e4e02ca8a4515e3456 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 20 Oct 2016 10:11:58 +1300 Subject: [PATCH] netlib.strutils -> mitmproxy.utils.strutils --- examples/custom_contentviews.py | 2 +- examples/har_dump.py | 2 +- examples/tcp_message.py | 2 +- mitmproxy/addons/dumper.py | 2 +- mitmproxy/addons/serverplayback.py | 2 +- mitmproxy/contentviews.py | 2 +- mitmproxy/flowfilter.py | 2 +- mitmproxy/io_compat.py | 2 +- mitmproxy/proxy/config.py | 2 +- mitmproxy/proxy/protocol/websockets.py | 2 +- mitmproxy/tools/console/grideditor/col_bytes.py | 2 +- mitmproxy/tools/console/master.py | 4 +++- {netlib => mitmproxy/utils}/strutils.py | 0 netlib/http/headers.py | 2 +- netlib/http/message.py | 4 +++- netlib/http/request.py | 2 +- netlib/tcp.py | 2 +- netlib/websockets/frame.py | 2 +- netlib/websockets/utils.py | 3 ++- netlib/wsgi.py | 4 +++- pathod/language/base.py | 2 +- pathod/language/message.py | 2 +- pathod/language/websockets.py | 2 +- pathod/log.py | 2 +- pathod/pathoc.py | 2 +- .../test_strutils.py => mitmproxy/test_utils_strutils.py} | 3 ++- 26 files changed, 33 insertions(+), 25 deletions(-) rename {netlib => mitmproxy/utils}/strutils.py (100%) rename test/{netlib/test_strutils.py => mitmproxy/test_utils_strutils.py} (98%) diff --git a/examples/custom_contentviews.py b/examples/custom_contentviews.py index 5a63e2a05..3558eacad 100644 --- a/examples/custom_contentviews.py +++ b/examples/custom_contentviews.py @@ -2,7 +2,7 @@ import string import lxml.html import lxml.etree from mitmproxy import contentviews -from netlib import strutils +from mitmproxy.utils import strutils class ViewPigLatin(contentviews.View): diff --git a/examples/har_dump.py b/examples/har_dump.py index deed2e70a..d01e6cddc 100644 --- a/examples/har_dump.py +++ b/examples/har_dump.py @@ -15,7 +15,7 @@ import pytz import mitmproxy from mitmproxy import version -from netlib import strutils +from mitmproxy.utils import strutils from netlib.http import cookies HAR = {} diff --git a/examples/tcp_message.py b/examples/tcp_message.py index b431c23f6..d7c9c42e5 100644 --- a/examples/tcp_message.py +++ b/examples/tcp_message.py @@ -8,7 +8,7 @@ tcp_message Inline Script Hook API Demonstration example cmdline invocation: mitmdump -T --host --tcp ".*" -q -s examples/tcp_message.py """ -from netlib import strutils +from mitmproxy.utils import strutils def tcp_message(tcp_msg): diff --git a/mitmproxy/addons/dumper.py b/mitmproxy/addons/dumper.py index 013fa3378..d690c0003 100644 --- a/mitmproxy/addons/dumper.py +++ b/mitmproxy/addons/dumper.py @@ -9,7 +9,7 @@ from mitmproxy import ctx from mitmproxy import exceptions from mitmproxy import flowfilter from mitmproxy.utils import human -from netlib import strutils +from mitmproxy.utils import strutils def indent(n, text): diff --git a/mitmproxy/addons/serverplayback.py b/mitmproxy/addons/serverplayback.py index 1161ce234..0b52918c6 100644 --- a/mitmproxy/addons/serverplayback.py +++ b/mitmproxy/addons/serverplayback.py @@ -1,7 +1,7 @@ import urllib import hashlib -from netlib import strutils +from mitmproxy.utils import strutils from mitmproxy import exceptions from mitmproxy import ctx from mitmproxy import io diff --git a/mitmproxy/contentviews.py b/mitmproxy/contentviews.py index 9a70b1042..07bf09f5a 100644 --- a/mitmproxy/contentviews.py +++ b/mitmproxy/contentviews.py @@ -35,7 +35,7 @@ from mitmproxy import exceptions from mitmproxy.contrib.wbxml import ASCommandResponse from netlib import http from netlib import multidict -from netlib import strutils +from mitmproxy.utils import strutils from netlib.http import url try: diff --git a/mitmproxy/flowfilter.py b/mitmproxy/flowfilter.py index f1454fd19..ee5224c6a 100644 --- a/mitmproxy/flowfilter.py +++ b/mitmproxy/flowfilter.py @@ -40,7 +40,7 @@ from mitmproxy import http from mitmproxy import tcp from mitmproxy import flow -from netlib import strutils +from mitmproxy.utils import strutils import pyparsing as pp from typing import Callable diff --git a/mitmproxy/io_compat.py b/mitmproxy/io_compat.py index 7f8f41b38..68c747ea3 100644 --- a/mitmproxy/io_compat.py +++ b/mitmproxy/io_compat.py @@ -5,7 +5,7 @@ This module handles the import of mitmproxy flows generated by old versions. from typing import Any from mitmproxy import version -from netlib import strutils +from mitmproxy.utils import strutils def convert_011_012(data): diff --git a/mitmproxy/proxy/config.py b/mitmproxy/proxy/config.py index 201dfdf7d..a6fc739be 100644 --- a/mitmproxy/proxy/config.py +++ b/mitmproxy/proxy/config.py @@ -4,7 +4,7 @@ import os import re from typing import Any -from netlib import strutils +from mitmproxy.utils import strutils from OpenSSL import SSL, crypto diff --git a/mitmproxy/proxy/protocol/websockets.py b/mitmproxy/proxy/protocol/websockets.py index 816ec92d9..636748a18 100644 --- a/mitmproxy/proxy/protocol/websockets.py +++ b/mitmproxy/proxy/protocol/websockets.py @@ -4,7 +4,7 @@ import struct from OpenSSL import SSL from mitmproxy import exceptions from mitmproxy.proxy.protocol import base -from netlib import strutils +from mitmproxy.utils import strutils from netlib import tcp from netlib import websockets diff --git a/mitmproxy/tools/console/grideditor/col_bytes.py b/mitmproxy/tools/console/grideditor/col_bytes.py index c951ce44f..f580e9476 100644 --- a/mitmproxy/tools/console/grideditor/col_bytes.py +++ b/mitmproxy/tools/console/grideditor/col_bytes.py @@ -4,7 +4,7 @@ from typing import Callable, Optional import urwid from mitmproxy.tools.console import signals from mitmproxy.tools.console.grideditor import base -from netlib import strutils +from mitmproxy.utils import strutils def read_file(filename: str, callback: Callable[..., None], escaped: bool) -> Optional[str]: diff --git a/mitmproxy/tools/console/master.py b/mitmproxy/tools/console/master.py index 3cc721b29..7ff0026eb 100644 --- a/mitmproxy/tools/console/master.py +++ b/mitmproxy/tools/console/master.py @@ -35,7 +35,9 @@ from mitmproxy.tools.console import signals from mitmproxy.tools.console import statusbar from mitmproxy.tools.console import window from mitmproxy.flowfilter import FMarked -from netlib import tcp, strutils +from mitmproxy.utils import strutils + +from netlib import tcp EVENTLOG_SIZE = 500 diff --git a/netlib/strutils.py b/mitmproxy/utils/strutils.py similarity index 100% rename from netlib/strutils.py rename to mitmproxy/utils/strutils.py diff --git a/netlib/http/headers.py b/netlib/http/headers.py index 39673f1a5..6c30d278b 100644 --- a/netlib/http/headers.py +++ b/netlib/http/headers.py @@ -2,7 +2,7 @@ import re import collections from netlib import multidict -from netlib import strutils +from mitmproxy.utils import strutils # See also: http://lucumr.pocoo.org/2013/7/2/the-updated-guide-to-unicode/ diff --git a/netlib/http/message.py b/netlib/http/message.py index 1980b0ab6..133a53ce3 100644 --- a/netlib/http/message.py +++ b/netlib/http/message.py @@ -2,7 +2,9 @@ import re import warnings from typing import Optional -from netlib import encoding, strutils, basetypes +from mitmproxy.utils import strutils +from netlib import encoding +from netlib import basetypes from netlib.http import headers diff --git a/netlib/http/request.py b/netlib/http/request.py index dd6f41649..3479fa4c1 100644 --- a/netlib/http/request.py +++ b/netlib/http/request.py @@ -2,7 +2,7 @@ import re import urllib from netlib import multidict -from netlib import strutils +from mitmproxy.utils import strutils from netlib.http import multipart from netlib.http import cookies from netlib.http import headers as nheaders diff --git a/netlib/tcp.py b/netlib/tcp.py index aeb1d4479..aed79388e 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -10,7 +10,7 @@ import binascii from typing import Optional # noqa -from netlib import strutils +from mitmproxy.utils import strutils import certifi from backports import ssl_match_hostname diff --git a/netlib/websockets/frame.py b/netlib/websockets/frame.py index 02d741125..e022a95c6 100644 --- a/netlib/websockets/frame.py +++ b/netlib/websockets/frame.py @@ -3,7 +3,7 @@ import struct import io from netlib import tcp -from netlib import strutils +from mitmproxy.utils import strutils from netlib import utils from mitmproxy.utils import human from .masker import Masker diff --git a/netlib/websockets/utils.py b/netlib/websockets/utils.py index fdec074ed..980436622 100644 --- a/netlib/websockets/utils.py +++ b/netlib/websockets/utils.py @@ -8,7 +8,8 @@ import base64 import hashlib import os -from netlib import http, strutils +from netlib import http +from mitmproxy.utils import strutils MAGIC = b'258EAFA5-E914-47DA-95CA-C5AB0DC85B11' VERSION = "13" diff --git a/netlib/wsgi.py b/netlib/wsgi.py index 11e4aba93..5a54cd706 100644 --- a/netlib/wsgi.py +++ b/netlib/wsgi.py @@ -3,7 +3,9 @@ import traceback import urllib import io -from netlib import http, tcp, strutils +from netlib import http +from netlib import tcp +from mitmproxy.utils import strutils class ClientConn: diff --git a/pathod/language/base.py b/pathod/language/base.py index 7410bbd4d..44a888c0d 100644 --- a/pathod/language/base.py +++ b/pathod/language/base.py @@ -4,7 +4,7 @@ import abc import functools import pyparsing as pp -from netlib import strutils +from mitmproxy.utils import strutils from mitmproxy.utils import human from . import generators, exceptions diff --git a/pathod/language/message.py b/pathod/language/message.py index 03b4a2cf6..6cdaaa0b4 100644 --- a/pathod/language/message.py +++ b/pathod/language/message.py @@ -1,6 +1,6 @@ import abc from . import actions, exceptions -from netlib import strutils +from mitmproxy.utils import strutils LOG_TRUNCATE = 1024 diff --git a/pathod/language/websockets.py b/pathod/language/websockets.py index 417944af2..d2291f822 100644 --- a/pathod/language/websockets.py +++ b/pathod/language/websockets.py @@ -1,7 +1,7 @@ import random import string import netlib.websockets -from netlib import strutils +from mitmproxy.utils import strutils import pyparsing as pp from . import base, generators, actions, message diff --git a/pathod/log.py b/pathod/log.py index 0d1bca414..4e5f355f6 100644 --- a/pathod/log.py +++ b/pathod/log.py @@ -1,6 +1,6 @@ import time -from netlib import strutils +from mitmproxy.utils import strutils from mitmproxy.utils import human diff --git a/pathod/pathoc.py b/pathod/pathoc.py index e9fa5c438..0cf08a602 100644 --- a/pathod/pathoc.py +++ b/pathod/pathoc.py @@ -12,7 +12,7 @@ import OpenSSL.crypto import logging from netlib.tutils import treq -from netlib import strutils +from mitmproxy.utils import strutils from netlib import tcp, certutils, websockets, socks from netlib import exceptions from netlib.http import http1 diff --git a/test/netlib/test_strutils.py b/test/mitmproxy/test_utils_strutils.py similarity index 98% rename from test/netlib/test_strutils.py rename to test/mitmproxy/test_utils_strutils.py index 36f709dae..2843688f8 100644 --- a/test/netlib/test_strutils.py +++ b/test/mitmproxy/test_utils_strutils.py @@ -1,4 +1,5 @@ -from netlib import strutils, tutils +from mitmproxy.utils import strutils +from netlib import tutils def test_always_bytes():