mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 02:26:58 -07:00
Bump mako from 1.1.6 to 1.2.0 (#1684)
* Bump mako from 1.1.6 to 1.2.0 Bumps [mako](https://github.com/sqlalchemy/mako) from 1.1.6 to 1.2.0. - [Release notes](https://github.com/sqlalchemy/mako/releases) - [Changelog](https://github.com/sqlalchemy/mako/blob/main/CHANGES) - [Commits](https://github.com/sqlalchemy/mako/commits) --- updated-dependencies: - dependency-name: mako dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update mako==1.2.0 * Update MarkupSafe==2.1.1 * Add importlib-metadata==4.11.3 * Update requirements.txt Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
aa0c58ef0e
commit
238afb4794
45 changed files with 2948 additions and 848 deletions
|
@ -1,5 +1,5 @@
|
|||
# ext/autohandler.py
|
||||
# Copyright 2006-2020 the Mako authors and contributors <see AUTHORS file>
|
||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
||||
#
|
||||
# This module is part of Mako and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# ext/babelplugin.py
|
||||
# Copyright 2006-2020 the Mako authors and contributors <see AUTHORS file>
|
||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
||||
#
|
||||
# This module is part of Mako and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
"""gettext message extraction via Babel: http://babel.edgewall.org/"""
|
||||
"""gettext message extraction via Babel: https://pypi.org/project/Babel/"""
|
||||
from babel.messages.extract import extract_python
|
||||
|
||||
from mako.ext.extract import MessageExtractor
|
||||
|
@ -15,12 +15,12 @@ class BabelMakoExtractor(MessageExtractor):
|
|||
self.keywords = keywords
|
||||
self.options = options
|
||||
self.config = {
|
||||
"comment-tags": u" ".join(comment_tags),
|
||||
"comment-tags": " ".join(comment_tags),
|
||||
"encoding": options.get(
|
||||
"input_encoding", options.get("encoding", None)
|
||||
),
|
||||
}
|
||||
super(BabelMakoExtractor, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
def __call__(self, fileobj):
|
||||
return self.process_file(fileobj)
|
||||
|
@ -54,5 +54,4 @@ def extract(fileobj, keywords, comment_tags, options):
|
|||
:rtype: ``iterator``
|
||||
"""
|
||||
extractor = BabelMakoExtractor(keywords, comment_tags, options)
|
||||
for message in extractor(fileobj):
|
||||
yield message
|
||||
yield from extractor(fileobj)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# ext/beaker_cache.py
|
||||
# Copyright 2006-2020 the Mako authors and contributors <see AUTHORS file>
|
||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
||||
#
|
||||
# This module is part of Mako and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -40,7 +40,7 @@ class BeakerCacheImpl(CacheImpl):
|
|||
_beaker_cache = cache.template.cache_args["manager"]
|
||||
else:
|
||||
_beaker_cache = beaker_cache.CacheManager()
|
||||
super(BeakerCacheImpl, self).__init__(cache)
|
||||
super().__init__(cache)
|
||||
|
||||
def _get_cache(self, **kw):
|
||||
expiretime = kw.pop("timeout", None)
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
# ext/extract.py
|
||||
# Copyright 2006-2020 the Mako authors and contributors <see AUTHORS file>
|
||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
||||
#
|
||||
# This module is part of Mako and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
from io import BytesIO
|
||||
from io import StringIO
|
||||
import re
|
||||
|
||||
from mako import compat
|
||||
from mako import lexer
|
||||
from mako import parsetree
|
||||
|
||||
|
||||
class MessageExtractor(object):
|
||||
class MessageExtractor:
|
||||
use_bytes = True
|
||||
|
||||
def process_file(self, fileobj):
|
||||
template_node = lexer.Lexer(
|
||||
fileobj.read(), input_encoding=self.config["encoding"]
|
||||
).parse()
|
||||
for extracted in self.extract_nodes(template_node.get_children()):
|
||||
yield extracted
|
||||
yield from self.extract_nodes(template_node.get_children())
|
||||
|
||||
def extract_nodes(self, nodes):
|
||||
translator_comments = []
|
||||
|
@ -90,7 +92,7 @@ class MessageExtractor(object):
|
|||
comment[1] for comment in translator_comments
|
||||
]
|
||||
|
||||
if isinstance(code, compat.text_type):
|
||||
if isinstance(code, str) and self.use_bytes:
|
||||
code = code.encode(input_encoding, "backslashreplace")
|
||||
|
||||
used_translator_comments = False
|
||||
|
@ -99,7 +101,10 @@ class MessageExtractor(object):
|
|||
# input string of the input is non-ascii)
|
||||
# Also, because we added it, we have to subtract one from
|
||||
# node.lineno
|
||||
code = compat.byte_buffer(compat.b("\n") + code)
|
||||
if self.use_bytes:
|
||||
code = BytesIO(b"\n" + code)
|
||||
else:
|
||||
code = StringIO("\n" + code)
|
||||
|
||||
for message in self.process_python(
|
||||
code, node.lineno - 1, translator_strings
|
||||
|
@ -112,8 +117,7 @@ class MessageExtractor(object):
|
|||
in_translator_comments = False
|
||||
|
||||
if child_nodes:
|
||||
for extracted in self.extract_nodes(child_nodes):
|
||||
yield extracted
|
||||
yield from self.extract_nodes(child_nodes)
|
||||
|
||||
@staticmethod
|
||||
def _split_comment(lineno, comment):
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
# ext/linguaplugin.py
|
||||
# Copyright 2006-2020 the Mako authors and contributors <see AUTHORS file>
|
||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
||||
#
|
||||
# This module is part of Mako and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
|
||||
from lingua.extractors import Extractor
|
||||
from lingua.extractors import get_extractor
|
||||
from lingua.extractors import Message
|
||||
|
||||
from mako import compat
|
||||
from mako.ext.extract import MessageExtractor
|
||||
|
||||
|
||||
class LinguaMakoExtractor(Extractor, MessageExtractor):
|
||||
|
||||
"""Mako templates"""
|
||||
|
||||
use_bytes = False
|
||||
extensions = [".mako"]
|
||||
default_config = {"encoding": "utf-8", "comment-tags": ""}
|
||||
|
||||
|
@ -26,29 +26,21 @@ class LinguaMakoExtractor(Extractor, MessageExtractor):
|
|||
self.filename = filename
|
||||
self.python_extractor = get_extractor("x.py")
|
||||
if fileobj is None:
|
||||
fileobj = open(filename, "rb")
|
||||
must_close = True
|
||||
ctx = open(filename, "r")
|
||||
else:
|
||||
must_close = False
|
||||
try:
|
||||
for message in self.process_file(fileobj):
|
||||
yield message
|
||||
finally:
|
||||
if must_close:
|
||||
fileobj.close()
|
||||
ctx = contextlib.nullcontext(fileobj)
|
||||
with ctx as file_:
|
||||
yield from self.process_file(file_)
|
||||
|
||||
def process_python(self, code, code_lineno, translator_strings):
|
||||
source = code.getvalue().strip()
|
||||
if source.endswith(compat.b(":")):
|
||||
if source in (
|
||||
compat.b("try:"),
|
||||
compat.b("else:"),
|
||||
) or source.startswith(compat.b("except")):
|
||||
source = compat.b("") # Ignore try/except and else
|
||||
elif source.startswith(compat.b("elif")):
|
||||
if source.endswith(":"):
|
||||
if source in ("try:", "else:") or source.startswith("except"):
|
||||
source = "" # Ignore try/except and else
|
||||
elif source.startswith("elif"):
|
||||
source = source[2:] # Replace "elif" with "if"
|
||||
source += compat.b("pass")
|
||||
code = io.BytesIO(source)
|
||||
source += "pass"
|
||||
code = io.StringIO(source)
|
||||
for msg in self.python_extractor(
|
||||
self.filename, self.options, code, code_lineno - 1
|
||||
):
|
||||
|
@ -58,7 +50,7 @@ class LinguaMakoExtractor(Extractor, MessageExtractor):
|
|||
msg.msgid,
|
||||
msg.msgid_plural,
|
||||
msg.flags,
|
||||
compat.u(" ").join(translator_strings + [msg.comment]),
|
||||
" ".join(translator_strings + [msg.comment]),
|
||||
msg.tcomment,
|
||||
msg.location,
|
||||
)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# ext/preprocessors.py
|
||||
# Copyright 2006-2020 the Mako authors and contributors <see AUTHORS file>
|
||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
||||
#
|
||||
# This module is part of Mako and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# ext/pygmentplugin.py
|
||||
# Copyright 2006-2020 the Mako authors and contributors <see AUTHORS file>
|
||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
||||
#
|
||||
# This module is part of Mako and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -25,8 +25,6 @@ from pygments.token import Other
|
|||
from pygments.token import String
|
||||
from pygments.token import Text
|
||||
|
||||
from mako import compat
|
||||
|
||||
|
||||
class MakoLexer(RegexLexer):
|
||||
name = "Mako"
|
||||
|
@ -108,7 +106,7 @@ class MakoHtmlLexer(DelegatingLexer):
|
|||
aliases = ["html+mako"]
|
||||
|
||||
def __init__(self, **options):
|
||||
super(MakoHtmlLexer, self).__init__(HtmlLexer, MakoLexer, **options)
|
||||
super().__init__(HtmlLexer, MakoLexer, **options)
|
||||
|
||||
|
||||
class MakoXmlLexer(DelegatingLexer):
|
||||
|
@ -116,7 +114,7 @@ class MakoXmlLexer(DelegatingLexer):
|
|||
aliases = ["xml+mako"]
|
||||
|
||||
def __init__(self, **options):
|
||||
super(MakoXmlLexer, self).__init__(XmlLexer, MakoLexer, **options)
|
||||
super().__init__(XmlLexer, MakoLexer, **options)
|
||||
|
||||
|
||||
class MakoJavascriptLexer(DelegatingLexer):
|
||||
|
@ -124,9 +122,7 @@ class MakoJavascriptLexer(DelegatingLexer):
|
|||
aliases = ["js+mako", "javascript+mako"]
|
||||
|
||||
def __init__(self, **options):
|
||||
super(MakoJavascriptLexer, self).__init__(
|
||||
JavascriptLexer, MakoLexer, **options
|
||||
)
|
||||
super().__init__(JavascriptLexer, MakoLexer, **options)
|
||||
|
||||
|
||||
class MakoCssLexer(DelegatingLexer):
|
||||
|
@ -134,7 +130,7 @@ class MakoCssLexer(DelegatingLexer):
|
|||
aliases = ["css+mako"]
|
||||
|
||||
def __init__(self, **options):
|
||||
super(MakoCssLexer, self).__init__(CssLexer, MakoLexer, **options)
|
||||
super().__init__(CssLexer, MakoLexer, **options)
|
||||
|
||||
|
||||
pygments_html_formatter = HtmlFormatter(
|
||||
|
@ -144,10 +140,7 @@ pygments_html_formatter = HtmlFormatter(
|
|||
|
||||
def syntax_highlight(filename="", language=None):
|
||||
mako_lexer = MakoLexer()
|
||||
if compat.py3k:
|
||||
python_lexer = Python3Lexer()
|
||||
else:
|
||||
python_lexer = PythonLexer()
|
||||
python_lexer = Python3Lexer()
|
||||
if filename.startswith("memory:") or language == "mako":
|
||||
return lambda string: highlight(
|
||||
string, mako_lexer, pygments_html_formatter
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# ext/turbogears.py
|
||||
# Copyright 2006-2020 the Mako authors and contributors <see AUTHORS file>
|
||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
||||
#
|
||||
# This module is part of Mako and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -9,7 +9,7 @@ from mako.lookup import TemplateLookup
|
|||
from mako.template import Template
|
||||
|
||||
|
||||
class TGPlugin(object):
|
||||
class TGPlugin:
|
||||
|
||||
"""TurboGears compatible Template Plugin."""
|
||||
|
||||
|
@ -51,7 +51,7 @@ class TGPlugin(object):
|
|||
def render(
|
||||
self, info, format="html", fragment=False, template=None # noqa
|
||||
):
|
||||
if isinstance(template, compat.string_types):
|
||||
if isinstance(template, str):
|
||||
template = self.load_template(template)
|
||||
|
||||
# Load extra vars func if provided
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue