minor stylistic fixes

This commit is contained in:
Maximilian Hils 2015-11-14 03:46:34 +01:00
parent dce469d4c1
commit 247f27d821
3 changed files with 16 additions and 17 deletions

View File

@ -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()

View File

@ -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:

View File

@ -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: