diff --git a/pelican/tests/support.py b/pelican/tests/support.py index 3c2a203f..d425395d 100644 --- a/pelican/tests/support.py +++ b/pelican/tests/support.py @@ -55,11 +55,11 @@ def isplit(s, sep=None): """ sep, hardsep = r'\s+' if sep is None else re.escape(sep), sep is not None - exp, pos, l = re.compile(sep), 0, len(s) + exp, pos, length = re.compile(sep), 0, len(s) while True: m = exp.search(s, pos) if not m: - if pos < l or hardsep: + if pos < length or hardsep: # ^ mimic "split()": ''.split() returns [] yield s[pos:] break diff --git a/pelican/tools/pelican_quickstart.py b/pelican/tools/pelican_quickstart.py index eb63ed1f..a03f52df 100755 --- a/pelican/tools/pelican_quickstart.py +++ b/pelican/tools/pelican_quickstart.py @@ -14,7 +14,7 @@ import pytz try: import tzlocal _DEFAULT_TIMEZONE = tzlocal.get_localzone().zone -except: +except ImportError: _DEFAULT_TIMEZONE = 'Europe/Paris' import six @@ -114,7 +114,7 @@ def get_template(name, as_encoding='utf-8'): @decoding_strings -def ask(question, answer=str_compat, default=None, l=None): +def ask(question, answer=str_compat, default=None, length=None): if answer == str_compat: r = '' while True: @@ -132,8 +132,8 @@ def ask(question, answer=str_compat, default=None, l=None): else: print('You must enter something') else: - if l and len(r) != l: - print('You must enter a {0} letters long string'.format(l)) + if length and len(r) != length: + print('Entry must be {0} characters long'.format(length)) else: break @@ -180,7 +180,7 @@ def ask(question, answer=str_compat, default=None, l=None): try: r = int(r) break - except: + except ValueError: print('You must enter an integer') return r else: diff --git a/pelican/tools/pelican_themes.py b/pelican/tools/pelican_themes.py index fd60c424..b99a7ba3 100755 --- a/pelican/tools/pelican_themes.py +++ b/pelican/tools/pelican_themes.py @@ -17,7 +17,7 @@ def err(msg, die=None): try: import pelican -except: +except ImportError: err('Cannot import pelican.\nYou must ' 'install Pelican in order to run this script.', -1) diff --git a/setup.py b/setup.py index 0f839bdc..c8ab9e30 100755 --- a/setup.py +++ b/setup.py @@ -1,8 +1,8 @@ #!/usr/bin/env python +import sys from io import open from os import walk from os.path import join, relpath -import sys from setuptools import setup