crawler: use less tertiary operator

Inherited from fork
master
pictuga 2017-03-18 22:23:39 -10:00
parent 65055290d4
commit e3ab3c6823
1 changed files with 5 additions and 1 deletions

View File

@ -79,7 +79,11 @@ class EncodingFixHandler(BaseHandler):
maintype = resp.info().get('Content-Type', '').split('/')[0] maintype = resp.info().get('Content-Type', '').split('/')[0]
if 200 <= resp.code < 300 and maintype == 'text': if 200 <= resp.code < 300 and maintype == 'text':
data = resp.read() 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: if enc:
data = data.decode(enc, 'replace') data = data.decode(enc, 'replace')