mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -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,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,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue