Skip to content

Commit

Permalink
remove lxml-dependent code
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils committed Dec 10, 2016
1 parent a7ba2f7 commit 293b79a
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Expand Up @@ -27,7 +27,7 @@ test_script:
- ps: |
$Env:VERSION = $(python mitmproxy/version.py)
$Env:SKIP_MITMPROXY = "python -c `"print('skip mitmproxy')`""
tox -e wheel -- https://snapshots.mitmproxy.org/misc/lxml-3.6.0-cp35-cp35m-win32.whl
tox -e wheel
tox -e rtool -- bdist
deploy_script:
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/modify_body_inject_iframe.py
Expand Up @@ -11,7 +11,7 @@ def __init__(self, iframe_url):
def response(self, flow):
if flow.request.host in self.iframe_url:
return
html = BeautifulSoup(flow.response.content, "lxml")
html = BeautifulSoup(flow.response.content)
if html.body:
iframe = html.new_tag(
"iframe",
Expand Down
6 changes: 2 additions & 4 deletions mitmproxy/contentviews/__init__.py
Expand Up @@ -22,7 +22,7 @@
from mitmproxy.net import http
from mitmproxy.utils import strutils
from . import (
auto, raw, hex, json, xml, wbxml, html, javascript, css,
auto, raw, hex, json, html_outline, wbxml, javascript, css,
urlencoded, multipart, image, query, protobuf
)
from .base import View, VIEW_CUTOFF, KEY_MAX, format_text, format_dict
Expand Down Expand Up @@ -163,10 +163,8 @@ def get_content_view(viewmode: View, data: bytes, **metadata):
add(raw.ViewRaw())
add(hex.ViewHex())
add(json.ViewJSON())
add(xml.ViewXML())
add(wbxml.ViewWBXML())
add(html.ViewHTML())
add(html.ViewHTMLOutline())
add(html_outline.ViewHTMLOutline())
add(javascript.ViewJavaScript())
add(css.ViewCSS())
add(urlencoded.ViewURLEncoded())
Expand Down
42 changes: 0 additions & 42 deletions mitmproxy/contentviews/html.py

This file was deleted.

17 changes: 17 additions & 0 deletions mitmproxy/contentviews/html_outline.py
@@ -0,0 +1,17 @@
import html2text

from mitmproxy.contentviews import base


class ViewHTMLOutline(base.View):
name = "HTML Outline"
prompt = ("html outline", "o")
content_types = ["text/html"]

def __call__(self, data, **metadata):
data = data.decode("utf-8", "replace")
h = html2text.HTML2Text(baseurl="")
h.ignore_images = True
h.body_width = 0
outline = h.handle(data)
return "HTML Outline", base.format_text(outline)
45 changes: 0 additions & 45 deletions mitmproxy/contentviews/xml.py

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt
@@ -1,2 +1 @@
https://snapshots.mitmproxy.org/misc/lxml-3.6.0-cp35-cp35m-win32.whl; sys_platform == 'win32' and python_version == '3.5'
-e .[dev,examples,contentviews]
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -70,7 +70,6 @@
"html2text>=2016.1.8, <=2016.9.19",
"hyperframe>=4.0.1, <5",
"jsbeautifier>=1.6.3, <1.7",
"lxml>=3.5.0, <=3.6.0", # no wheels for 3.6.1 yet.
"Pillow>=3.2, <3.5",
"passlib>=1.6.5, <1.8",
"pyasn1>=0.1.9, <0.2",
Expand Down
18 changes: 0 additions & 18 deletions test/mitmproxy/contentviews/test_html.py

This file was deleted.

9 changes: 9 additions & 0 deletions test/mitmproxy/contentviews/test_html_outline.py
@@ -0,0 +1,9 @@
from mitmproxy.contentviews import html_outline
from test.mitmproxy.contentviews import full_eval


def test_view_html_outline():
v = full_eval(html_outline.ViewHTMLOutline())
s = b"<html><br><br></br><p>one</p></html>"
assert v(s)
assert v(b'\xfe')
17 changes: 0 additions & 17 deletions test/mitmproxy/contentviews/test_xml.py

This file was deleted.

0 comments on commit 293b79a

Please sign in to comment.