diff options
author | dufferzafar <dufferzafar0@gmail.com> | 2016-07-27 04:25:14 -0700 |
---|---|---|
committer | dufferzafar <dufferzafar0@gmail.com> | 2016-07-27 04:34:51 -0700 |
commit | 821413349ebf6c2330d8abfd23e8d03894e77e47 (patch) | |
tree | a7c85372f6bf2a6ee4db3d5be7e6f89707c56410 | |
parent | 21e6ecb47deb9b372c8b102b92d79fa49a7e38ab (diff) | |
download | mitmproxy-821413349ebf6c2330d8abfd23e8d03894e77e47.tar.gz mitmproxy-821413349ebf6c2330d8abfd23e8d03894e77e47.tar.bz2 mitmproxy-821413349ebf6c2330d8abfd23e8d03894e77e47.zip |
Re-order imports etc.
-rw-r--r-- | mitmproxy/contentviews.py | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/mitmproxy/contentviews.py b/mitmproxy/contentviews.py index 3aedf08a..68d3d959 100644 --- a/mitmproxy/contentviews.py +++ b/mitmproxy/contentviews.py @@ -30,8 +30,10 @@ from PIL import ExifTags from PIL import Image from six import BytesIO -from mitmproxy import exceptions +import cssutils import jsbeautifier + +from mitmproxy import exceptions from mitmproxy.contrib.wbxml import ASCommandResponse from netlib import http from netlib import multidict @@ -44,17 +46,6 @@ try: except ImportError: # pragma no cover pyamf = None -try: - import cssutils -except ImportError: # pragma no cover - cssutils = None -else: - cssutils.log.setLevel(logging.CRITICAL) - - cssutils.ser.prefs.keepComments = True - cssutils.ser.prefs.omitLastSemicolon = False - cssutils.ser.prefs.indentClosingBrace = False - cssutils.ser.prefs.validOnly = False # Default view cutoff *in lines* VIEW_CUTOFF = 512 @@ -410,11 +401,14 @@ class ViewCSS(View): ] def __call__(self, data, **metadata): - if cssutils: - sheet = cssutils.parseString(data) - beautified = sheet.cssText - else: - beautified = data + cssutils.log.setLevel(logging.CRITICAL) + cssutils.ser.prefs.keepComments = True + cssutils.ser.prefs.omitLastSemicolon = False + cssutils.ser.prefs.indentClosingBrace = False + cssutils.ser.prefs.validOnly = False + + sheet = cssutils.parseString(data) + beautified = sheet.cssText return "CSS", format_text(beautified) |