diff options
-rw-r--r-- | examples/custom_contentviews.py | 24 | ||||
-rw-r--r-- | libmproxy/flow.py | 3 | ||||
-rw-r--r-- | libmproxy/script.py | 6 |
3 files changed, 16 insertions, 17 deletions
diff --git a/examples/custom_contentviews.py b/examples/custom_contentviews.py index 1a2bcb1e..17920e51 100644 --- a/examples/custom_contentviews.py +++ b/examples/custom_contentviews.py @@ -1,12 +1,10 @@ import string -from libmproxy import script, flow, utils -import libmproxy.contentviews as cv -from netlib.http import Headers import lxml.html import lxml.etree +from libmproxy import utils, contentviews -class ViewPigLatin(cv.View): +class ViewPigLatin(contentviews.View): name = "pig_latin_HTML" prompt = ("pig latin HTML", "l") content_types = ["text/html"] @@ -27,19 +25,23 @@ class ViewPigLatin(cv.View): idx = -1 while word[idx] in string.punctuation and (idx * -1) != len(word): idx -= 1 if word[0].lower() in 'aeiou': - if idx == -1: ret += word[0:] + "hay" - else: ret += word[0:len(word)+idx+1] + "hay" + word[idx+1:] + if idx == -1: + ret += word[0:] + "hay" + else: + ret += word[0:len(word) + idx + 1] + "hay" + word[idx + 1:] else: - if idx == -1: ret += word[1:] + word[0] + "ay" - else: ret += word[1:len(word)+idx+1] + word[0] + "ay" + word[idx+1:] + if idx == -1: + ret += word[1:] + word[0] + "ay" + else: + ret += word[1:len(word) + idx + 1] + word[0] + "ay" + word[idx + 1:] ret += ' ' return ret.strip() def recurse(root): if hasattr(root, 'text') and root.text: - root.text = piglify(root.text) + root.text = piglify(root.text) if hasattr(root, 'tail') and root.tail: - root.tail = piglify(root.tail) + root.tail = piglify(root.tail) if len(root): for child in root: @@ -52,7 +54,7 @@ class ViewPigLatin(cv.View): pretty_print=True, doctype=docinfo.doctype ) - return "HTML", cv.format_text(s) + return "HTML", contentviews.format_text(s) pig_view = ViewPigLatin() diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 3343e694..e7d7288d 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -9,19 +9,16 @@ import cookielib import os import re import urlparse -import inspect from netlib import wsgi from netlib.exceptions import HttpException from netlib.http import CONTENT_MISSING, Headers, http1 -import netlib.http from . import controller, tnetstring, filt, script, version from .onboarding import app from .proxy.config import HostMatcher from .protocol.http_replay import RequestReplayThread from .protocol import Kill from .models import ClientConnection, ServerConnection, HTTPResponse, HTTPFlow, HTTPRequest -from . import contentviews as cv class AppRegistry: diff --git a/libmproxy/script.py b/libmproxy/script.py index 4da40c52..1a2525b4 100644 --- a/libmproxy/script.py +++ b/libmproxy/script.py @@ -5,7 +5,7 @@ import threading import shlex import sys -from . import contentviews as cv +from . import contentviews class ScriptError(Exception): @@ -59,10 +59,10 @@ class ScriptContext: return self._master.apps def add_contentview(self, view_obj): - cv.add(view_obj) + contentviews.add(view_obj) def remove_contentview(self, view_obj): - cv.remove(view_obj) + contentviews.remove(view_obj) class Script: |