This commit is contained in:
ndparker 2015-10-18 12:51:03 +02:00
parent 4cbaa1c438
commit 7cc5616a6d
2 changed files with 82 additions and 24 deletions

View File

@ -1,4 +1,4 @@
# pylint-version: 1.2.1
# pylint-version: 1.4.4
[MASTER]
# Specify a configuration file.
@ -24,9 +24,34 @@ persistent=no
# usually to register additional checkers.
load-plugins=
# Use multiple processes to speed up Pylint.
jobs=1
# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=
_rjsmin
# Allow optimization of some AST trees. This will activate a peephole AST
# optimizer, which will apply various small optimizations. For instance, it can
# be used to obtain the result of joining multiple strings with the addition
# operator. Joining a lot of strings can lead to a maximum recursion error in
# Pylint and this flag can prevent that. It has one side effect, the resulting
# AST will be different than the one from reality.
optimize-ast=no
[MESSAGES CONTROL]
# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
confidence=
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time. See also the "--disable" option for examples.
@ -49,6 +74,11 @@ disable=
[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs
# (visual studio) and html. You can also give a reporter class, eg
# mypackage.mymodule.MyReporterClass.
output-format=text
# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]".
@ -73,6 +103,23 @@ comment=no
#msg-template=
[SPELLING]
# Spelling dictionary name. Available dictionaries: none. To make it working
# install python-enchant package.
spelling-dict=
# List of comma separated words that should not be checked.
spelling-ignore-words=
# A path to a file that contains private dictionary; one word per line.
spelling-private-dict-file=
# Tells whether to store unknown words to indicated private dictionary in
# --spelling-private-dict-file option instead of raising a message.
spelling-store-unknown-words=no
[SIMILARITIES]
# Minimum lines number of a similarity.
@ -96,7 +143,7 @@ ignore-mixin-members=yes
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus extisting member attributes cannot be deduced by static analysis
# and thus existing member attributes cannot be deduced by static analysis
ignored-modules=
# List of classes names for which member attributes should not be checked
@ -220,7 +267,6 @@ single-line-if-stmt=no
# List of optional constructs for which whitespace checking is disabled
no-space-check=
trailing-comma,
# Maximum number of lines in a module
max-module-lines=1500
@ -232,6 +278,9 @@ indent-string=' '
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
expected-line-ending-format=
[VARIABLES]
@ -247,6 +296,10 @@ dummy-variables-rgx=(?x)
# you should avoid to define new builtins when possible.
additional-builtins=
# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,_cb
[MISCELLANEOUS]
@ -328,6 +381,10 @@ valid-classmethod-first-arg=cls
# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=mcs
# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,_fields,_replace,_source,_make
[EXCEPTIONS]

View File

@ -62,7 +62,7 @@ Both python 2 and python 3 are supported.
http://www.crockford.com/javascript/jsmin.c
"""
if __doc__:
# pylint: disable = W0622
# pylint: disable = redefined-builtin
__doc__ = __doc__.encode('ascii').decode('unicode_escape')
__author__ = r"Andr\xe9 Malo".encode('ascii').decode('unicode_escape')
__docformat__ = "restructuredtext en"
@ -88,11 +88,12 @@ def _make_jsmin(python_only=False):
:Return: Minifier
:Rtype: ``callable``
"""
# pylint: disable = R0912, R0914, W0612
# pylint: disable = unused-variable
# pylint: disable = too-many-locals
if not python_only:
try:
import _rjsmin # pylint: disable = F0401
import _rjsmin
except ImportError:
pass
else:
@ -100,7 +101,7 @@ def _make_jsmin(python_only=False):
try:
xrange
except NameError:
xrange = range # pylint: disable = W0622
xrange = range # pylint: disable = redefined-builtin
space_chars = r'[\000-\011\013\014\016-\040]'
@ -189,7 +190,7 @@ def _make_jsmin(python_only=False):
dull = r'[^\047"/\000-\040]'
space_sub_simple = _re.compile((
# noqa pylint: disable = C0330
# noqa pylint: disable = bad-continuation
r'(%(dull)s+)' # 0
r'|(%(strings)s%(dull)s*)' # 1
@ -217,7 +218,7 @@ def _make_jsmin(python_only=False):
def space_subber_simple(match):
""" Substitution callback """
# pylint: disable = R0911
# pylint: disable = too-many-return-statements
groups = match.groups()
if groups[0]:
@ -240,7 +241,7 @@ def _make_jsmin(python_only=False):
return ''
space_sub_banged = _re.compile((
# noqa pylint: disable = C0330
# noqa pylint: disable = bad-continuation
r'(%(dull)s+)' # 0
r'|(%(strings)s%(dull)s*)' # 1
@ -267,8 +268,6 @@ def _make_jsmin(python_only=False):
# print space_sub_banged.__self__.pattern
keep = _re.compile((
# noqa pylint: disable = C0330
r'%(space_chars)s+|%(space_comment_nobang)s+|%(newline)s+'
r'|(%(bang_comment)s+)'
) % locals()).sub
@ -278,7 +277,7 @@ def _make_jsmin(python_only=False):
def space_subber_banged(match):
""" Substitution callback """
# pylint: disable = R0911
# pylint: disable = too-many-return-statements
groups = match.groups()
if groups[0]:
@ -306,7 +305,7 @@ def _make_jsmin(python_only=False):
else:
return keep(keeper, groups[12] or groups[13])
def jsmin(script, keep_bang_comments=False): # pylint: disable = W0621
def jsmin(script, keep_bang_comments=False):
r"""
Minify javascript based on `jsmin.c by Douglas Crockford`_\.
@ -327,6 +326,8 @@ def _make_jsmin(python_only=False):
:Return: Minified script
:Rtype: ``str``
"""
# pylint: disable = redefined-outer-name
if keep_bang_comments:
return space_sub_banged(
space_subber_banged, '\n%s\n' % script
@ -489,16 +490,16 @@ if __name__ == '__main__':
def main():
""" Main """
import sys as _sys
keep_bang_comments = (
'-b' in _sys.argv[1:]
or '-bp' in _sys.argv[1:]
or '-pb' in _sys.argv[1:]
)
if '-p' in _sys.argv[1:] or '-bp' in _sys.argv[1:] \
or '-pb' in _sys.argv[1:]:
global jsmin # pylint: disable = W0603
jsmin = _make_jsmin(python_only=True)
_sys.stdout.write(jsmin(
argv = _sys.argv[1:]
keep_bang_comments = '-b' in argv or '-bp' in argv or '-pb' in argv
if '-p' in argv or '-bp' in argv or '-pb' in argv:
xjsmin = _make_jsmin(python_only=True)
else:
xjsmin = jsmin
_sys.stdout.write(xjsmin(
_sys.stdin.read(), keep_bang_comments=keep_bang_comments
))
main()