mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 08:16:06 -07:00
Bump mako from 1.2.4 to 1.3.2 (#2256)
* Bump mako from 1.2.4 to 1.3.2 Bumps [mako](https://github.com/sqlalchemy/mako) from 1.2.4 to 1.3.2. - [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.3.2 --------- Signed-off-by: dependabot[bot] <support@github.com> 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
52819f7da6
commit
4468c3e4af
29 changed files with 83 additions and 54 deletions
|
@ -1,8 +1,8 @@
|
||||||
# mako/__init__.py
|
# mako/__init__.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
||||||
|
|
||||||
__version__ = "1.2.4"
|
__version__ = "1.3.2"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/_ast_util.py
|
# mako/_ast_util.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/ast.py
|
# mako/ast.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/cache.py
|
# mako/cache.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/cmd.py
|
# mako/cmd.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
@ -25,7 +25,6 @@ def _exit():
|
||||||
|
|
||||||
|
|
||||||
def cmdline(argv=None):
|
def cmdline(argv=None):
|
||||||
|
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--var",
|
"--var",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/codegen.py
|
# mako/codegen.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
@ -816,7 +816,6 @@ class _GenerateRenderMethod:
|
||||||
)
|
)
|
||||||
or len(self.compiler.default_filters)
|
or len(self.compiler.default_filters)
|
||||||
):
|
):
|
||||||
|
|
||||||
s = self.create_filter_callable(
|
s = self.create_filter_callable(
|
||||||
node.escapes_code.args, "%s" % node.text, True
|
node.escapes_code.args, "%s" % node.text, True
|
||||||
)
|
)
|
||||||
|
@ -1181,7 +1180,6 @@ class _Identifiers:
|
||||||
|
|
||||||
def visitBlockTag(self, node):
|
def visitBlockTag(self, node):
|
||||||
if node is not self.node and not node.is_anonymous:
|
if node is not self.node and not node.is_anonymous:
|
||||||
|
|
||||||
if isinstance(self.node, parsetree.DefTag):
|
if isinstance(self.node, parsetree.DefTag):
|
||||||
raise exceptions.CompileException(
|
raise exceptions.CompileException(
|
||||||
"Named block '%s' not allowed inside of def '%s'"
|
"Named block '%s' not allowed inside of def '%s'"
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
# mako/compat.py
|
# mako/compat.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
from importlib import metadata as importlib_metadata
|
||||||
from importlib import util
|
from importlib import util
|
||||||
import inspect
|
import inspect
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
win32 = sys.platform.startswith("win")
|
win32 = sys.platform.startswith("win")
|
||||||
pypy = hasattr(sys, "pypy_version_info")
|
pypy = hasattr(sys, "pypy_version_info")
|
||||||
py38 = sys.version_info >= (3, 8)
|
|
||||||
|
|
||||||
ArgSpec = collections.namedtuple(
|
ArgSpec = collections.namedtuple(
|
||||||
"ArgSpec", ["args", "varargs", "keywords", "defaults"]
|
"ArgSpec", ["args", "varargs", "keywords", "defaults"]
|
||||||
|
@ -62,12 +62,6 @@ def exception_name(exc):
|
||||||
return exc.__class__.__name__
|
return exc.__class__.__name__
|
||||||
|
|
||||||
|
|
||||||
if py38:
|
|
||||||
from importlib import metadata as importlib_metadata
|
|
||||||
else:
|
|
||||||
import importlib_metadata # noqa
|
|
||||||
|
|
||||||
|
|
||||||
def importlib_metadata_get(group):
|
def importlib_metadata_get(group):
|
||||||
ep = importlib_metadata.entry_points()
|
ep = importlib_metadata.entry_points()
|
||||||
if hasattr(ep, "select"):
|
if hasattr(ep, "select"):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/exceptions.py
|
# mako/exceptions.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# ext/autohandler.py
|
# ext/autohandler.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# ext/babelplugin.py
|
# ext/babelplugin.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# ext/beaker_cache.py
|
# ext/beaker_cache.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# ext/extract.py
|
# ext/extract.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# ext/linguaplugin.py
|
# ext/linguaplugin.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# ext/preprocessors.py
|
# ext/preprocessors.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# ext/pygmentplugin.py
|
# ext/pygmentplugin.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# ext/turbogears.py
|
# ext/turbogears.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/filters.py
|
# mako/filters.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/lexer.py
|
# mako/lexer.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
@ -247,6 +247,8 @@ class Lexer:
|
||||||
continue
|
continue
|
||||||
if self.match_python_block():
|
if self.match_python_block():
|
||||||
continue
|
continue
|
||||||
|
if self.match_percent():
|
||||||
|
continue
|
||||||
if self.match_text():
|
if self.match_text():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -352,13 +354,23 @@ class Lexer:
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def match_percent(self):
|
||||||
|
match = self.match(r"(?<=^)(\s*)%%(%*)", re.M)
|
||||||
|
if match:
|
||||||
|
self.append_node(
|
||||||
|
parsetree.Text, match.group(1) + "%" + match.group(2)
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def match_text(self):
|
def match_text(self):
|
||||||
match = self.match(
|
match = self.match(
|
||||||
r"""
|
r"""
|
||||||
(.*?) # anything, followed by:
|
(.*?) # anything, followed by:
|
||||||
(
|
(
|
||||||
(?<=\n)(?=[ \t]*(?=%|\#\#)) # an eval or line-based
|
(?<=\n)(?=[ \t]*(?=%|\#\#)) # an eval or line-based
|
||||||
# comment preceded by a
|
# comment, preceded by a
|
||||||
# consumed newline and whitespace
|
# consumed newline and whitespace
|
||||||
|
|
|
|
||||||
(?=\${) # an expression
|
(?=\${) # an expression
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/lookup.py
|
# mako/lookup.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
@ -178,7 +178,6 @@ class TemplateLookup(TemplateCollection):
|
||||||
lexer_cls=None,
|
lexer_cls=None,
|
||||||
include_error_handler=None,
|
include_error_handler=None,
|
||||||
):
|
):
|
||||||
|
|
||||||
self.directories = [
|
self.directories = [
|
||||||
posixpath.normpath(d) for d in util.to_list(directories, ())
|
posixpath.normpath(d) for d in util.to_list(directories, ())
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/parsetree.py
|
# mako/parsetree.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/pygen.py
|
# mako/pygen.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/pyparser.py
|
# mako/pyparser.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
@ -64,7 +64,6 @@ class FindIdentifiers(_ast_util.NodeVisitor):
|
||||||
self._add_declared(node.name)
|
self._add_declared(node.name)
|
||||||
|
|
||||||
def visit_Assign(self, node):
|
def visit_Assign(self, node):
|
||||||
|
|
||||||
# flip around the visiting of Assign so the expression gets
|
# flip around the visiting of Assign so the expression gets
|
||||||
# evaluated first, in the case of a clause like "x=x+5" (x
|
# evaluated first, in the case of a clause like "x=x+5" (x
|
||||||
# is undeclared)
|
# is undeclared)
|
||||||
|
@ -99,7 +98,6 @@ class FindIdentifiers(_ast_util.NodeVisitor):
|
||||||
yield arg
|
yield arg
|
||||||
|
|
||||||
def _visit_function(self, node, islambda):
|
def _visit_function(self, node, islambda):
|
||||||
|
|
||||||
# push function state onto stack. dont log any more
|
# push function state onto stack. dont log any more
|
||||||
# identifiers as "declared" until outside of the function,
|
# identifiers as "declared" until outside of the function,
|
||||||
# but keep logging identifiers as "undeclared". track
|
# but keep logging identifiers as "undeclared". track
|
||||||
|
@ -122,7 +120,6 @@ class FindIdentifiers(_ast_util.NodeVisitor):
|
||||||
self.local_ident_stack = local_ident_stack
|
self.local_ident_stack = local_ident_stack
|
||||||
|
|
||||||
def visit_For(self, node):
|
def visit_For(self, node):
|
||||||
|
|
||||||
# flip around visit
|
# flip around visit
|
||||||
|
|
||||||
self.visit(node.iter)
|
self.visit(node.iter)
|
||||||
|
|
|
@ -530,7 +530,7 @@ class Namespace:
|
||||||
def _populate(self, d, l):
|
def _populate(self, d, l):
|
||||||
for ident in l:
|
for ident in l:
|
||||||
if ident == "*":
|
if ident == "*":
|
||||||
for (k, v) in self._get_star():
|
for k, v in self._get_star():
|
||||||
d[k] = v
|
d[k] = v
|
||||||
else:
|
else:
|
||||||
d[ident] = getattr(self, ident)
|
d[ident] = getattr(self, ident)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/template.py
|
# mako/template.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
@ -26,7 +26,6 @@ from mako.lexer import Lexer
|
||||||
|
|
||||||
|
|
||||||
class Template:
|
class Template:
|
||||||
|
|
||||||
r"""Represents a compiled template.
|
r"""Represents a compiled template.
|
||||||
|
|
||||||
:class:`.Template` includes a reference to the original
|
:class:`.Template` includes a reference to the original
|
||||||
|
|
|
@ -103,7 +103,6 @@ def _assert_raises(
|
||||||
check_context=False,
|
check_context=False,
|
||||||
cause_cls=None,
|
cause_cls=None,
|
||||||
):
|
):
|
||||||
|
|
||||||
with _expect_raises(except_cls, msg, check_context, cause_cls) as ec:
|
with _expect_raises(except_cls, msg, check_context, cause_cls) as ec:
|
||||||
callable_(*args, **kwargs)
|
callable_(*args, **kwargs)
|
||||||
return ec.error
|
return ec.error
|
||||||
|
|
|
@ -19,6 +19,10 @@ def result_lines(result):
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def result_raw_lines(result):
|
||||||
|
return [x for x in re.split(r"\r?\n", result) if x.strip() != ""]
|
||||||
|
|
||||||
|
|
||||||
def make_path(
|
def make_path(
|
||||||
filespec: Union[Path, str],
|
filespec: Union[Path, str],
|
||||||
make_absolute: bool = True,
|
make_absolute: bool = True,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# mako/util.py
|
# mako/util.py
|
||||||
# Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2024 the Mako authors and contributors <see AUTHORS file>
|
||||||
#
|
#
|
||||||
# This module is part of Mako and is released under
|
# This module is part of Mako and is released under
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import functools
|
import functools
|
||||||
import re
|
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
import typing as t
|
import typing as t
|
||||||
|
@ -14,10 +13,7 @@ if t.TYPE_CHECKING:
|
||||||
_P = te.ParamSpec("_P")
|
_P = te.ParamSpec("_P")
|
||||||
|
|
||||||
|
|
||||||
__version__ = "2.1.3"
|
__version__ = "2.1.5"
|
||||||
|
|
||||||
_strip_comments_re = re.compile(r"<!--.*?-->", re.DOTALL)
|
|
||||||
_strip_tags_re = re.compile(r"<.*?>", re.DOTALL)
|
|
||||||
|
|
||||||
|
|
||||||
def _simple_escaping_wrapper(func: "t.Callable[_P, str]") -> "t.Callable[_P, Markup]":
|
def _simple_escaping_wrapper(func: "t.Callable[_P, str]") -> "t.Callable[_P, Markup]":
|
||||||
|
@ -162,9 +158,41 @@ class Markup(str):
|
||||||
>>> Markup("Main »\t<em>About</em>").striptags()
|
>>> Markup("Main »\t<em>About</em>").striptags()
|
||||||
'Main » About'
|
'Main » About'
|
||||||
"""
|
"""
|
||||||
# Use two regexes to avoid ambiguous matches.
|
value = str(self)
|
||||||
value = _strip_comments_re.sub("", self)
|
|
||||||
value = _strip_tags_re.sub("", value)
|
# Look for comments then tags separately. Otherwise, a comment that
|
||||||
|
# contains a tag would end early, leaving some of the comment behind.
|
||||||
|
|
||||||
|
while True:
|
||||||
|
# keep finding comment start marks
|
||||||
|
start = value.find("<!--")
|
||||||
|
|
||||||
|
if start == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
# find a comment end mark beyond the start, otherwise stop
|
||||||
|
end = value.find("-->", start)
|
||||||
|
|
||||||
|
if end == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
value = f"{value[:start]}{value[end + 3:]}"
|
||||||
|
|
||||||
|
# remove tags using the same method
|
||||||
|
while True:
|
||||||
|
start = value.find("<")
|
||||||
|
|
||||||
|
if start == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
end = value.find(">", start)
|
||||||
|
|
||||||
|
if end == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
value = f"{value[:start]}{value[end + 1:]}"
|
||||||
|
|
||||||
|
# collapse spaces
|
||||||
value = " ".join(value.split())
|
value = " ".join(value.split())
|
||||||
return self.__class__(value).unescape()
|
return self.__class__(value).unescape()
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ importlib-metadata==6.8.0
|
||||||
importlib-resources==6.0.1
|
importlib-resources==6.0.1
|
||||||
git+https://github.com/Tautulli/ipwhois.git@master#egg=ipwhois
|
git+https://github.com/Tautulli/ipwhois.git@master#egg=ipwhois
|
||||||
IPy==1.01
|
IPy==1.01
|
||||||
Mako==1.2.4
|
Mako==1.3.2
|
||||||
MarkupSafe==2.1.3
|
MarkupSafe==2.1.3
|
||||||
musicbrainzngs==0.7.1
|
musicbrainzngs==0.7.1
|
||||||
packaging==23.1
|
packaging==23.1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue