From e3ab3c6823a44a4eef5611f57120085fb1c2069d Mon Sep 17 00:00:00 2001 From: pictuga Date: Sat, 18 Mar 2017 22:23:39 -1000 Subject: [PATCH] crawler: use less tertiary operator Inherited from fork --- morss/crawler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/morss/crawler.py b/morss/crawler.py index 2d45031..3effee3 100644 --- a/morss/crawler.py +++ b/morss/crawler.py @@ -79,7 +79,11 @@ class EncodingFixHandler(BaseHandler): maintype = resp.info().get('Content-Type', '').split('/')[0] if 200 <= resp.code < 300 and maintype == 'text': data = resp.read() - enc = detect_encoding(data, resp) if not self.encoding else self.encoding + + if not self.encoding: + enc = detect_encoding(data, resp) + else: + enc = self.encoding if enc: data = data.decode(enc, 'replace')