Skip to content

Commit

Permalink
relint
Browse files Browse the repository at this point in the history
  • Loading branch information
ndparker committed Nov 1, 2014
1 parent 04d99fe commit c290364
Show file tree
Hide file tree
Showing 37 changed files with 513 additions and 362 deletions.
2 changes: 2 additions & 0 deletions pylintrc
Expand Up @@ -18,6 +18,8 @@ ignore=
_tdi_impl.so,
_tdi_rjsmin.so,
_tdi_rcssmin.so,
rjsmin.py,
rcssmin.py,


# Pickle collected data for later comparisons.
Expand Down
4 changes: 2 additions & 2 deletions tdi/__init__.py
Expand Up @@ -31,7 +31,7 @@
__version__ = ('0.9.9.8', False, 4809)

from tdi import util as _util
from tdi._exceptions import * # pylint: disable = W0401, W0614, W0622
from tdi._exceptions import * # noqa pylint: disable = W0622, W0401, W0614
from tdi.markup import factory as _factory

#: Version of the TDI package
Expand All @@ -57,4 +57,4 @@
__all__ = _util.find_public(globals())
del _util, _factory

from tdi import _deprecations # pylint: disable = W0611
from tdi import _deprecations # noqa pylint: disable = W0611
11 changes: 7 additions & 4 deletions tdi/_deprecations.py
Expand Up @@ -2,7 +2,7 @@
u"""
:Copyright:
Copyright 2010 - 2012
Copyright 2010 - 2014
Andr\xe9 Malo or his licensors, as applicable
:License:
Expand Down Expand Up @@ -35,14 +35,17 @@
from tdi.tools import javascript as _javascript


_escape.decode_html = _util.Deprecator(_html.decode,
_escape.decode_html = _util.Deprecator(
_html.decode,
"tdi.tools.escape.decode_html has been moved to tdi.tools.html.decode."
)
_escape.multiline_to_html = _util.Deprecator(_html.multiline,
_escape.multiline_to_html = _util.Deprecator(
_html.multiline,
"tdi.tools.escape.multiline_to_html has been moved to "
"tdi.tools.html.multiline."
)
_escape.escape_js = _util.Deprecator(_javascript.escape_string,
_escape.escape_js = _util.Deprecator(
_javascript.escape_string,
"tdi.tools.escape.escape_js is deprecated. "
"Use tdi.tools.javascript.escape_string instead."
)
Expand Down
21 changes: 18 additions & 3 deletions tdi/_exceptions.py
Expand Up @@ -2,7 +2,7 @@
u"""
:Copyright:
Copyright 2007 - 2013
Copyright 2007 - 2014
Andr\xe9 Malo or his licensors, as applicable
:License:
Expand Down Expand Up @@ -39,58 +39,71 @@ class Error(Exception):
class TemplateError(Error):
""" Error in a template """


class TemplateEncodingError(TemplateError):
""" Template encoding error """


class TemplateAttributeError(TemplateError):
""" A tdi attribute could not be parsed """


class TemplateAttributeEmptyError(TemplateAttributeError):
""" A tdi attribute was empty """


class TemplateReloadError(TemplateError):
""" Error during template reload """


class TemplateFactoryError(TemplateError):
""" Template factory misuse """


class OverlayError(TemplateError):
""" Error in overlay work """


class NodeError(Error):
""" Error in node processing """


class NodeTreeError(NodeError):
""" The node tree was tried to be modified after it was finalized """


class NodeNotFoundError(NodeError):
""" node was not found """


class ModelError(Error):
""" Base error for model errors """


class ModelMissingError(ModelError):
""" A required model method was missing """


class LexerError(Error):
""" Lexer Error """


class LexerEOFError(LexerError):
""" Unexpected EOF """


class LexerStateError(LexerError):
""" Invalid state change """


class LexerFinalizedError(LexerStateError):
""" Lexer was already finalized """


class DependencyError(Error):
""" A dependency error occured """


class DependencyCycle(DependencyError):
"""
Dependencies created a cycle
Expand All @@ -99,7 +112,7 @@ class DependencyCycle(DependencyError):
"""


class Warning(Warning): # pylint: disable = W0622
class Warning(Warning): # pylint: disable = W0622
""" Base warning for this package """

def emit(cls, message, stacklevel=1):
Expand All @@ -108,11 +121,13 @@ def emit(cls, message, stacklevel=1):
emit = classmethod(emit)


class DeprecationWarning(Warning): # pylint: disable = W0622
class DeprecationWarning(Warning): # pylint: disable = W0622
""" TDI specific deprecation warning """


class NodeWarning(Warning):
""" A (non-fatal) inconsistency in the nodetree occured """


class AutoUpdateWarning(Warning):
""" An auto update error occured after the template was first loaded """
13 changes: 7 additions & 6 deletions tdi/_finalize.py
Expand Up @@ -2,7 +2,7 @@
u"""
:Copyright:
Copyright 2006 - 2013
Copyright 2006 - 2014
Andr\xe9 Malo or his licensors, as applicable
:License:
Expand All @@ -28,7 +28,7 @@
__author__ = u"Andr\xe9 Malo"
__docformat__ = "restructuredtext en"

# pylint: disable = W0212
# pylint: disable = W0212
# Access to a protected member _udict of a client class

import itertools as _it
Expand Down Expand Up @@ -77,6 +77,7 @@ def finalize(udict, encoder, decoder):
else:
overlay = dispatch(stack, kind, node)
if overlay is not None:
# pylint: disable = W0633
oname, onode, otarget, osource = overlay
if not otarget:
if oname in sources:
Expand Down Expand Up @@ -142,7 +143,7 @@ def _dispatch(stack, kind, node):
# ignored and warned about.
overlay, (_, otarget, osource, oname) = None, udict['overlay']
if oname is not None:
if not otarget and stack[-1][4] is not None: # inside separator?
if not otarget and stack[-1][4] is not None: # inside separator?
NodeWarning.emit(
"Ignoring source overlay %r in separator node %r" % (
oname, stack[-1][4],
Expand Down Expand Up @@ -206,9 +207,9 @@ def check_seps(seps):
udict['decoder'] = decoder
udict['modelscope'] = scope
if 'attr_' in udict:
udict['attr'] = dict((decoder.normalize(key), (key, value))
for key, value in udict['attr_']
)
udict['attr'] = dict((
decoder.normalize(key), (key, value)
) for key, value in udict['attr_'])
del udict['attr_']

# Fast exit: Optimize for text-only content
Expand Down
8 changes: 4 additions & 4 deletions tdi/_htmldecode.py
@@ -1,7 +1,7 @@
# -*- coding: ascii -*-
u"""
Copyright 2006 - 2013
Copyright 2006 - 2014
Andr\xe9 Malo or his licensors, as applicable
:License:
Expand Down Expand Up @@ -46,7 +46,6 @@ def _make_decode():
isinstance_ = isinstance
default_entities = dict(_htmlentities.htmlentities)

# pylint: disable = W0621
def decode(value, encoding='latin-1', errors='strict', entities=None):
"""
Decode HTML encoded text
Expand Down Expand Up @@ -86,12 +85,13 @@ def decode(value, encoding='latin-1', errors='strict', entities=None):
:Return: The decoded content
:Rtype: ``unicode``
"""
# pylint: disable = E1101
# pylint: disable = R0912
# pylint: disable = W0621

if not isinstance_(value, unicode_):
value = str_(value).decode(encoding, errors)
if entities is None:
entities = default_entities

def subber(match):
""" Substituter """
name = match.group(1)
Expand Down
2 changes: 1 addition & 1 deletion tdi/_htmlentities.py
@@ -1,4 +1,4 @@
# -*- coding: ascii -*- pylint: disable = C0302
# -*- coding: ascii -*- pylint: disable = C0302
u"""
:Copyright:
Expand Down
34 changes: 19 additions & 15 deletions tdi/_nodetree.py
Expand Up @@ -2,7 +2,7 @@
u"""
:Copyright:
Copyright 2006 - 2013
Copyright 2006 - 2014
Andr\xe9 Malo or his licensors, as applicable
:License:
Expand Down Expand Up @@ -48,7 +48,7 @@
__author__ = u"Andr\xe9 Malo"
__docformat__ = "restructuredtext en"

# pylint: disable = W0212
# pylint: disable = W0212
# Access to a protected member _udict of a client class

import itertools as _it
Expand Down Expand Up @@ -163,7 +163,7 @@ def _repeat(node, user_node, model, callback, itemlist, fixed, separate):
idx, item = itemlist.next()
udict, CB = node._udict, CB_NODE
try:
del udict['callback'] # just make sure
del udict['callback'] # just make sure
except KeyError:
pass
udict['repeated'] = None
Expand Down Expand Up @@ -244,9 +244,12 @@ def copydeep(node, model, ctx, user_node):
udict = nodecopy._udict
if udict['content'][0] is None:
TEXT, deep = TEXT_NODE, copydeep
udict['nodes'] = [(kind, (kind != TEXT and node._usernode) and
deep(node, model, ctx, user_node) or node
) for kind, node in udict['nodes']]
udict['nodes'] = [(
# pylint: disable = C0330
kind,
(kind != TEXT and node._usernode) and
deep(node, model, ctx, user_node) or node
) for kind, node in udict['nodes']] # noqa

return nodecopy

Expand All @@ -266,6 +269,7 @@ def represent(udict, verbose):
:Rtype: ``list``
"""
# pylint: disable = R0912

_len, _iter, exhausted = len, iter, StopIteration
TEXT, SEP = TEXT_NODE, SEP_NODE
stack = []
Expand Down Expand Up @@ -297,7 +301,7 @@ def repr_node(kind, udict):
content = ":" + content
if not verbose and udict['sep'] is not None:
content += " (:)"
if verbose and udict['overlay'][3]: # [3] == oname
if verbose and udict['overlay'][3]: # [3] == oname
oresult = udict['overlay'][3]
if udict['overlay'][0]:
oresult = '-%s' % oresult
Expand Down Expand Up @@ -426,6 +430,7 @@ def findnode(current, nodestring):
- `NodeNotFoundError` : Node not found
"""
# pylint: disable = R0912

if nodestring is None:
return current
names = nodestring.split('.')
Expand Down Expand Up @@ -592,7 +597,7 @@ def render(startnode, model, user_node):
tnode, user_node, model, *udict['repeated']
)).next, None))
depth_done = False
next_node = True # Ignore original node.
next_node = True # Ignore original node.
break

elif user_control and 'callback' in udict:
Expand Down Expand Up @@ -626,13 +631,12 @@ def render(startnode, model, user_node):
continue

ctx = tnode.ctx
nodes = [
(subkind, subkind != TEXT
and user_node(subnode, model, ctx,
subnode._usernode)
nodes = [(
# noqa pylint: disable = C0330
subkind,
subkind != TEXT
and user_node(subnode, model, ctx, subnode._usernode)
or subnode
)
for subkind, subnode in udict['nodes']
]
) for subkind, subnode in udict['nodes']]
push((depth_done, _iter(nodes).next, endtag))
depth_done = done or depth_done

0 comments on commit c290364

Please sign in to comment.