Skip to content
Myr

Merge pull request #867 from The-Compiler/collections

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Import abstract base classes from collections.abc

authored by David Lord · committed by GitHub · parents 0ece610, 31bf9b7 · Browse files · 6 files+19 added−26 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+19 added−26 removed

  • other:+19 added−26 removed

6 files+19 added−26 removed

modified:docs/jinjaext.py+2 added-2 removed
6 unmodified lines
78 :copyright: Copyright 2008 by Armin Ronacher.9 :license: BSD.10"""11import collections11import os12import re13import inspect14
9 unmodified lines
24from pygments.style import Style25from pygments.token import Keyword, Name, Comment, String, Error, \26 Number, Operator, Generic27from jinja2 import Environment, FileSystemLoader28from jinja2._compat import abc293031def parse_rst(state, content_offset, doc):32 node = nodes.section()
126 unmodified lines
159 if node.abstract:160 members = []161 for key, name in node.__dict__.items():162 if not key.startswith('_') and \163 not hasattr(node.__base__, key) and isinstance(name, collections.Callable):163 not hasattr(node.__base__, key) and isinstance(name, abc.Callable):164 members.append(key)165 if members:166 members.sort()167 doc.append('%s :members: %s' % (p, ', '.join(members)), '')
39 unmodified lines
modified:jinja2/_compat.py+6 added
95 unmodified lines
96try:97 from urllib.parse import quote_from_bytes as url_quote98except ImportError:99 from urllib import quote as url_quote100101102try:103 from collections import abc104except ImportError:105 import collections as abc
modified:jinja2/runtime.py+2 added-7 removed
18 unmodified lines
19from jinja2.exceptions import UndefinedError, TemplateRuntimeError, \20 TemplateNotFound21from jinja2._compat import imap, text_type, iteritems, \22 implements_iterator, implements_to_string, string_types, PY2, \23 with_metaclass23 with_metaclass, abc242526# these variables are exported to the template runtime27__all__ = ['LoopContext', 'TemplateReference', 'Macro', 'Markup',
284 unmodified lines
312 self.name313 )314315316# register the context as mapping if possible317try:318 from collections import Mapping319 Mapping.register(Context)316abc.Mapping.register(Context)320except ImportError:321 pass317318319class BlockReference(object):320 """One block on a template reference."""
488 unmodified lines
modified:jinja2/sandbox.py+5 added-7 removed
12 unmodified lines
13 :license: BSD.14"""15import types16import operator17from collections import Mapping17from jinja2.environment import Environment18from jinja2.exceptions import SecurityError20from jinja2._compat import string_types, PY219from jinja2._compat import string_types, PY2, abc20from jinja2.utils import Markup2122from markupsafe import EscapeFormatter23from string import Formatter
53 unmodified lines
77except ImportError:78 pass7980#: register Python 2.6 abstract base classes82from collections import MutableSet, MutableMapping, MutableSequence83_mutable_set_types += (MutableSet,)84_mutable_mapping_types += (MutableMapping,)85_mutable_sequence_types += (MutableSequence,)81_mutable_set_types += (abc.MutableSet,)82_mutable_mapping_types += (abc.MutableMapping,)83_mutable_sequence_types += (abc.MutableSequence,)848586_mutable_spec = (87 (_mutable_set_types, frozenset([
12 unmodified lines
100 ]))101)102103106class _MagicFormatMapping(Mapping):104class _MagicFormatMapping(abc.Mapping):105 """This class implements a dummy wrapper to fix a bug in the Python106 standard library for string formatting.107108 See https://bugs.python.org/issue13598 for information about why
365 unmodified lines
modified:jinja2/tests.py+2 added-3 removed
8 unmodified lines
9 :license: BSD, see LICENSE for more details.10"""11import operator12import re13from collections import Mapping13from jinja2.runtime import Undefined15from jinja2._compat import text_type, string_types, integer_types14from jinja2._compat import text_type, string_types, integer_types, abc15import decimal1617number_re = re.compile(r'^-?\d+(\.\d+)?$')18regex_type = type(number_re)
63 unmodified lines
82 """Return true if the object is a mapping (dict etc.).8384 .. versionadded:: 2.685 """87 return isinstance(value, Mapping)86 return isinstance(value, abc.Mapping)878889def test_number(value):90 """Return true if the variable is a number."""
84 unmodified lines
modified:jinja2/utils.py+2 added-7 removed
12 unmodified lines
13import errno14from collections import deque15from threading import Lock16from jinja2._compat import text_type, string_types, implements_iterator, \17 url_quote17 url_quote, abc181920_word_split_re = re.compile(r'(\s+)')21_punctuation_re = re.compile(
457 unmodified lines
479480 __copy__ = copy481482483# register the LRU cache as mutable mapping if possible484try:485 from collections import MutableMapping486 MutableMapping.register(LRUCache)483abc.MutableMapping.register(LRUCache)487except ImportError:488 pass484485486def select_autoescape(enabled_extensions=('html', 'htm', 'xml'),487 disabled_extensions=(),
155 unmodified lines