From 46ceecd1c01d19b3c824e07872fad8d6d5e182f7 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sat, 7 Nov 2015 11:39:49 +0100 Subject: [PATCH] Improve variable names (pylint) --- patacrep/encoding.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/patacrep/encoding.py b/patacrep/encoding.py index 20783111..9f0018da 100644 --- a/patacrep/encoding.py +++ b/patacrep/encoding.py @@ -29,18 +29,18 @@ def detect_encoding(filename): """Return the most likely encoding of the file """ encodings = ['utf-8', 'windows-1250', 'windows-1252'] - for e in encodings: + for encoding in encodings: try: - fh = codecs.open(filename, 'r', encoding=e) - fh.readlines() - fh.seek(0) + filehandler = codecs.open(filename, 'r', encoding=encoding) + filehandler.readlines() + filehandler.seek(0) except UnicodeDecodeError: pass else: - if e != 'utf-8': - print('Opening `%s` with `%s` encoding' % (filename, e)) - return e + if encoding != 'utf-8': + print('Opening `%s` with `%s` encoding' % (filename, encoding)) + return encoding finally: - fh.close() + filehandler.close() raise Exception('Not suitable encoding found for {}'.format(filename))