aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-11-14 03:46:34 +0100
committerMaximilian Hils <git@maximilianhils.com>2015-11-14 03:46:34 +0100
commit247f27d8219bb63ef64dd33935e222fdad507631 (patch)
tree9090e054bf168dca0b091fa4fffab48a9f3e730b /examples
parentdce469d4c18b027292b84b91951d189a95f8067f (diff)
downloadmitmproxy-247f27d8219bb63ef64dd33935e222fdad507631.tar.gz
mitmproxy-247f27d8219bb63ef64dd33935e222fdad507631.tar.bz2
mitmproxy-247f27d8219bb63ef64dd33935e222fdad507631.zip
minor stylistic fixes
Diffstat (limited to 'examples')
-rw-r--r--examples/custom_contentviews.py24
1 files changed, 13 insertions, 11 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()