relint, maintain changelog

This commit is contained in:
ndparker 2014-11-02 23:02:13 +01:00
parent 6df0078b4d
commit 15f3a55e45
2 changed files with 60 additions and 26 deletions

View File

@ -1,3 +1,11 @@
Changes with version
*) Relint with newer pylint
*) Fix locale problem with the setup script on python3.
Submitted by https://github.com/svenstaro
Changes with version 1.0.9
*) Documentation and benchmark updates
@ -15,8 +23,8 @@ Changes with version 1.0.8
*) Added support for python 3.4
*) Added support for keeping comments starting with an exclamation mark. This
feature can be enabled by passing keep_bang_comments=True to the jsmin
function.
feature can be enabled by passing keep_bang_comments=True to the jsmin
function.
Changes with version 1.0.7

View File

@ -88,9 +88,10 @@ def _make_jsmin(python_only=False):
:Rtype: ``callable``
"""
# pylint: disable = R0912, R0914, W0612
if not python_only:
try:
import _rjsmin
import _rjsmin # pylint: disable = F0401
except ImportError:
pass
else:
@ -98,7 +99,7 @@ def _make_jsmin(python_only=False):
try:
xrange
except NameError:
xrange = range # pylint: disable = W0622
xrange = range # pylint: disable = W0622
space_chars = r'[\000-\011\013\014\016-\040]'
@ -150,8 +151,10 @@ def _make_jsmin(python_only=False):
last != first and chr(last) or ''
) for first, last in result])
return _re.sub(r'([\000-\040\047])', # for better portability
lambda m: '\\%03o' % ord(m.group(1)), (sequentize(result)
return _re.sub(
r'([\000-\040\047])', # \047 for better portability
lambda m: '\\%03o' % ord(m.group(1)), (
sequentize(result)
.replace('\\', '\\\\')
.replace('[', '\\[')
.replace(']', '\\]')
@ -185,6 +188,8 @@ def _make_jsmin(python_only=False):
dull = r'[^\047"/\000-\040]'
space_sub_simple = _re.compile((
# noqa pylint: disable = C0330
r'(%(dull)s+)'
r'|(%(strings)s%(dull)s*)'
r'|(?<=%(preregex1)s)'
@ -206,17 +211,27 @@ def _make_jsmin(python_only=False):
def space_subber_simple(match):
""" Substitution callback """
# pylint: disable = C0321, R0911
# pylint: disable = R0911
groups = match.groups()
if groups[0]: return groups[0]
elif groups[1]: return groups[1]
elif groups[2]: return groups[2]
elif groups[3]: return groups[3]
elif groups[4]: return '\n'
elif groups[5] or groups[6] or groups[7]: return ' '
else: return ''
if groups[0]:
return groups[0]
elif groups[1]:
return groups[1]
elif groups[2]:
return groups[2]
elif groups[3]:
return groups[3]
elif groups[4]:
return '\n'
elif groups[5] or groups[6] or groups[7]:
return ' '
else:
return ''
space_sub_banged = _re.compile((
# noqa pylint: disable = C0330
r'(%(dull)s+)'
r'|(%(strings)s%(dull)s*)'
r'|(%(bang_comment)s%(dull)s*)'
@ -239,18 +254,27 @@ def _make_jsmin(python_only=False):
def space_subber_banged(match):
""" Substitution callback """
# pylint: disable = C0321, R0911
groups = match.groups()
if groups[0]: return groups[0]
elif groups[1]: return groups[1]
elif groups[2]: return groups[2]
elif groups[3]: return groups[3]
elif groups[4]: return groups[4]
elif groups[5]: return '\n'
elif groups[6] or groups[7] or groups[8]: return ' '
else: return ''
# pylint: disable = R0911
def jsmin(script, keep_bang_comments=False): # pylint: disable = W0621
groups = match.groups()
if groups[0]:
return groups[0]
elif groups[1]:
return groups[1]
elif groups[2]:
return groups[2]
elif groups[3]:
return groups[3]
elif groups[4]:
return groups[4]
elif groups[5]:
return '\n'
elif groups[6] or groups[7] or groups[8]:
return ' '
else:
return ''
def jsmin(script, keep_bang_comments=False): # pylint: disable = W0621
r"""
Minify javascript based on `jsmin.c by Douglas Crockford`_\.
@ -338,6 +362,7 @@ def jsmin_for_posers(script, keep_bang_comments=False):
r'*\*+)*/))+|(?:(?:(?://[^\r\n]*)?[\r\n])(?:[\000-\011\013\014\0'
r'16-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+'
)
def subber(match):
""" Substitution callback """
groups = match.groups()
@ -382,6 +407,7 @@ def jsmin_for_posers(script, keep_bang_comments=False):
r':(?://[^\r\n]*)?[\r\n])(?:[\000-\011\013\014\016-\040]|(?:/\*('
r'?!!)[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+'
)
def subber(match):
""" Substitution callback """
groups = match.groups()
@ -412,7 +438,7 @@ if __name__ == '__main__':
)
if '-p' in _sys.argv[1:] or '-bp' in _sys.argv[1:] \
or '-pb' in _sys.argv[1:]:
global jsmin # pylint: disable = W0603
global jsmin # pylint: disable = W0603
jsmin = _make_jsmin(python_only=True)
_sys.stdout.write(jsmin(
_sys.stdin.read(), keep_bang_comments=keep_bang_comments