mako: update version to 1.2.1 from 1.2.0
This is to import https://github.com/sqlalchemy/mako/pull/361. This update shows 14% improvement in walltime and uses only 80% of cpu time compared to current HEAD. ``` $ hyperfine --parameter-list branch origin/main,mako_optimize --setup 'git checkout {branch}' 'python3 ../../third_party/blink/renderer/bindings/scripts/generate_bindings.py --web_idl_database gen/third_party/blink/renderer/bindings/web_idl_database.pickle --root_src_dir ../../ --root_gen_dir gen --output_reldir core=third_party/blink/renderer/bindings/core/v8/ --output_reldir modules=third_party/blink/renderer/bindings/modules/v8/ enumeration callback_function callback_interface dictionary interface namespace observable_array typedef union' Benchmark 1: python3 ../../third_party/blink/renderer/bindings/scripts/generate_bindings.py --web_idl_database gen/third_party/blink/renderer/bindings/web_idl_database.pickle --root_src_dir ../../ --root_gen_dir gen --output_reldir core=third_party/blink/renderer/bindings/core/v8/ --output_reldir modules=third_party/blink/renderer/bindings/modules/v8/ enumeration callback_function callback_interface dictionary interface namespace observable_array typedef union Time (mean ± σ): 33.499 s ± 0.289 s [User: 930.572 s, System: 20.354 s] Range (min … max): 32.971 s … 33.915 s 10 runs Benchmark 2: python3 ../../third_party/blink/renderer/bindings/scripts/generate_bindings.py --web_idl_database gen/third_party/blink/renderer/bindings/web_idl_database.pickle --root_src_dir ../../ --root_gen_dir gen --output_reldir core=third_party/blink/renderer/bindings/core/v8/ --output_reldir modules=third_party/blink/renderer/bindings/modules/v8/ enumeration callback_function callback_interface dictionary interface namespace observable_array typedef union Time (mean ± σ): 29.261 s ± 0.298 s [User: 737.851 s, System: 20.448 s] Range (min … max): 28.737 s … 29.835 s 10 runs Summary 'python3 ../../third_party/blink/renderer/bindings/scripts/generate_bindings.py --web_idl_database gen/third_party/blink/renderer/bindings/web_idl_database.pickle --root_src_dir ../../ --root_gen_dir gen --output_reldir core=third_party/blink/renderer/bindings/core/v8/ --output_reldir modules=third_party/blink/renderer/bindings/modules/v8/ enumeration callback_function callback_interface dictionary interface namespace observable_array typedef union' ran 1.14 ± 0.02 times faster than 'python3 ../../third_party/blink/renderer/bindings/scripts/generate_bindings.py --web_idl_database gen/third_party/blink/renderer/bindings/web_idl_database.pickle --root_src_dir ../../ --root_gen_dir gen --output_reldir core=third_party/blink/renderer/bindings/core/v8/ --output_reldir modules=third_party/blink/renderer/bindings/modules/v8/ enumeration callback_function callback_interface dictionary interface namespace observable_array typedef union' ``` Bug: 1214033 Change-Id: I54eab0e27872d40256d3ecb04c47c876652b5596 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3685551 Reviewed-by: Kentaro Hara <haraken@chromium.org> Commit-Queue: Takuto Ikuta <tikuta@chromium.org> Reviewed-by: Yuki Shiino <yukishiino@chromium.org> Cr-Commit-Position: refs/heads/main@{#1019918}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d0a8c00a16
commit
c4edcb406f
third_party/mako
README.chromium
mako
LICENSE
mako
__init__.py_ast_util.pyast.pycache.pycmd.pycodegen.pycompat.pyexceptions.py
setup.cfgext
autohandler.pybabelplugin.pybeaker_cache.pyextract.pylinguaplugin.pypreprocessors.pypygmentplugin.pyturbogears.py
filters.pylexer.pylookup.pyparsetree.pypygen.pypyparser.pytemplate.pytesting
util.pytest
tox.ini
10
third_party/mako/README.chromium
vendored
10
third_party/mako/README.chromium
vendored
@@ -1,8 +1,8 @@
|
|||||||
Name: Mako Templates for Python
|
Name: Mako Templates for Python
|
||||||
Short Name: python-mako
|
Short Name: python-mako
|
||||||
URL: https://www.makotemplates.org
|
URL: https://www.makotemplates.org
|
||||||
Version: 1.2.0
|
Version: 1.2.1
|
||||||
Date: March 11, 2022
|
Date: July 1, 2022
|
||||||
License: MIT
|
License: MIT
|
||||||
License File: NOT_SHIPPED
|
License File: NOT_SHIPPED
|
||||||
Security Critical: no
|
Security Critical: no
|
||||||
@@ -10,11 +10,11 @@ Security Critical: no
|
|||||||
Description:
|
Description:
|
||||||
Template engine in Python, used for code generation in Blink.
|
Template engine in Python, used for code generation in Blink.
|
||||||
|
|
||||||
Source: https://files.pythonhosted.org/packages/50/ec/1d687348f0954bda388bfd1330c158ba8d7dea4044fc160e74e080babdb9/Mako-1.2.0.tar.gz
|
Source: https://files.pythonhosted.org/packages/ad/dd/34201dae727bb183ca14fd8417e61f936fa068d6f503991f09ee3cac6697/Mako-1.2.1.tar.gz
|
||||||
SHA-256: 9a7c7e922b87db3686210cf49d5d767033a41d4010b284e747682c92bddd8b39
|
SHA-256: f054a5ff4743492f1aa9ecc47172cb33b42b9d993cffcc146c9de17e717b0307
|
||||||
|
|
||||||
Local Modifications:
|
Local Modifications:
|
||||||
* add DIR_METADATA, OWNERS, README.chromium, and .gitattributes files in this directory.
|
* add DIR_METADATA, OWNERS, README.chromium, and .gitattributes files in this directory.
|
||||||
* run following commands to pass PRESUBMIT.
|
* run following commands to pass PRESUBMIT.
|
||||||
$ rm -rf mako/doc/ mako/example/ mako/Mako.egg-info mako/PKG-INFO
|
$ rm -rf mako/doc/ mako/examples/ mako/Mako.egg-info mako/PKG-INFO
|
||||||
$ chmod -x mako/mako/cmd.py
|
$ chmod -x mako/mako/cmd.py
|
||||||
|
4
third_party/mako/mako/LICENSE
vendored
4
third_party/mako/mako/LICENSE
vendored
@@ -1,4 +1,4 @@
|
|||||||
Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>.
|
Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
4
third_party/mako/mako/mako/__init__.py
vendored
4
third_party/mako/mako/mako/__init__.py
vendored
@@ -1,8 +1,8 @@
|
|||||||
# mako/__init__.py
|
# mako/__init__.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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.0"
|
__version__ = "1.2.1"
|
||||||
|
2
third_party/mako/mako/mako/_ast_util.py
vendored
2
third_party/mako/mako/mako/_ast_util.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/_ast_util.py
|
# mako/_ast_util.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
2
third_party/mako/mako/mako/ast.py
vendored
2
third_party/mako/mako/mako/ast.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/ast.py
|
# mako/ast.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
2
third_party/mako/mako/mako/cache.py
vendored
2
third_party/mako/mako/mako/cache.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/cache.py
|
# mako/cache.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
2
third_party/mako/mako/mako/cmd.py
vendored
2
third_party/mako/mako/mako/cmd.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/cmd.py
|
# mako/cmd.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
2
third_party/mako/mako/mako/codegen.py
vendored
2
third_party/mako/mako/mako/codegen.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/codegen.py
|
# mako/codegen.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
2
third_party/mako/mako/mako/compat.py
vendored
2
third_party/mako/mako/mako/compat.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/compat.py
|
# mako/compat.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
2
third_party/mako/mako/mako/exceptions.py
vendored
2
third_party/mako/mako/mako/exceptions.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/exceptions.py
|
# mako/exceptions.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
2
third_party/mako/mako/mako/ext/extract.py
vendored
2
third_party/mako/mako/mako/ext/extract.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# ext/extract.py
|
# ext/extract.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
2
third_party/mako/mako/mako/ext/turbogears.py
vendored
2
third_party/mako/mako/mako/ext/turbogears.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# ext/turbogears.py
|
# ext/turbogears.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
2
third_party/mako/mako/mako/filters.py
vendored
2
third_party/mako/mako/mako/filters.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/filters.py
|
# mako/filters.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
9
third_party/mako/mako/mako/lexer.py
vendored
9
third_party/mako/mako/mako/lexer.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/lexer.py
|
# mako/lexer.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
@@ -74,12 +74,11 @@ class Lexer:
|
|||||||
(start, end) = match.span()
|
(start, end) = match.span()
|
||||||
self.match_position = end + 1 if end == start else end
|
self.match_position = end + 1 if end == start else end
|
||||||
self.matched_lineno = self.lineno
|
self.matched_lineno = self.lineno
|
||||||
lines = re.findall(r"\n", self.text[mp : self.match_position])
|
|
||||||
cp = mp - 1
|
cp = mp - 1
|
||||||
while cp >= 0 and cp < self.textlength and self.text[cp] != "\n":
|
if cp >= 0 and cp < self.textlength:
|
||||||
cp -= 1
|
cp = self.text[: cp + 1].rfind("\n")
|
||||||
self.matched_charpos = mp - cp
|
self.matched_charpos = mp - cp
|
||||||
self.lineno += len(lines)
|
self.lineno += self.text[mp : self.match_position].count("\n")
|
||||||
return match
|
return match
|
||||||
|
|
||||||
def parse_until_text(self, watch_nesting, *text):
|
def parse_until_text(self, watch_nesting, *text):
|
||||||
|
2
third_party/mako/mako/mako/lookup.py
vendored
2
third_party/mako/mako/mako/lookup.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/lookup.py
|
# mako/lookup.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
2
third_party/mako/mako/mako/parsetree.py
vendored
2
third_party/mako/mako/mako/parsetree.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/parsetree.py
|
# mako/parsetree.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
28
third_party/mako/mako/mako/pygen.py
vendored
28
third_party/mako/mako/mako/pygen.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/pygen.py
|
# mako/pygen.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
@@ -43,6 +43,15 @@ class PythonPrinter:
|
|||||||
# source lines
|
# source lines
|
||||||
self.source_map = {}
|
self.source_map = {}
|
||||||
|
|
||||||
|
self._re_space_comment = re.compile(r"^\s*#")
|
||||||
|
self._re_space = re.compile(r"^\s*$")
|
||||||
|
self._re_indent = re.compile(r":[ \t]*(?:#.*)?$")
|
||||||
|
self._re_compound = re.compile(r"^\s*(if|try|elif|while|for|with)")
|
||||||
|
self._re_indent_keyword = re.compile(
|
||||||
|
r"^\s*(def|class|else|elif|except|finally)"
|
||||||
|
)
|
||||||
|
self._re_unindentor = re.compile(r"^\s*(else|elif|except|finally).*\:")
|
||||||
|
|
||||||
def _update_lineno(self, num):
|
def _update_lineno(self, num):
|
||||||
self.lineno += num
|
self.lineno += num
|
||||||
|
|
||||||
@@ -86,8 +95,8 @@ class PythonPrinter:
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
line is None
|
line is None
|
||||||
or re.match(r"^\s*#", line)
|
or self._re_space_comment.match(line)
|
||||||
or re.match(r"^\s*$", line)
|
or self._re_space.match(line)
|
||||||
):
|
):
|
||||||
hastext = False
|
hastext = False
|
||||||
else:
|
else:
|
||||||
@@ -121,12 +130,12 @@ class PythonPrinter:
|
|||||||
# note that a line can both decrase (before printing) and
|
# note that a line can both decrase (before printing) and
|
||||||
# then increase (after printing) the indentation level.
|
# then increase (after printing) the indentation level.
|
||||||
|
|
||||||
if re.search(r":[ \t]*(?:#.*)?$", line):
|
if self._re_indent.search(line):
|
||||||
# increment indentation count, and also
|
# increment indentation count, and also
|
||||||
# keep track of what the keyword was that indented us,
|
# keep track of what the keyword was that indented us,
|
||||||
# if it is a python compound statement keyword
|
# if it is a python compound statement keyword
|
||||||
# where we might have to look for an "unindent" keyword
|
# where we might have to look for an "unindent" keyword
|
||||||
match = re.match(r"^\s*(if|try|elif|while|for|with)", line)
|
match = self._re_compound.match(line)
|
||||||
if match:
|
if match:
|
||||||
# its a "compound" keyword, so we will check for "unindentors"
|
# its a "compound" keyword, so we will check for "unindentors"
|
||||||
indentor = match.group(1)
|
indentor = match.group(1)
|
||||||
@@ -137,9 +146,7 @@ class PythonPrinter:
|
|||||||
# its not a "compound" keyword. but lets also
|
# its not a "compound" keyword. but lets also
|
||||||
# test for valid Python keywords that might be indenting us,
|
# test for valid Python keywords that might be indenting us,
|
||||||
# else assume its a non-indenting line
|
# else assume its a non-indenting line
|
||||||
m2 = re.match(
|
m2 = self._re_indent_keyword.match(line)
|
||||||
r"^\s*(def|class|else|elif|except|finally)", line
|
|
||||||
)
|
|
||||||
if m2:
|
if m2:
|
||||||
self.indent += 1
|
self.indent += 1
|
||||||
self.indent_detail.append(indentor)
|
self.indent_detail.append(indentor)
|
||||||
@@ -167,7 +174,7 @@ class PythonPrinter:
|
|||||||
|
|
||||||
# if the current line doesnt have one of the "unindentor" keywords,
|
# if the current line doesnt have one of the "unindentor" keywords,
|
||||||
# return False
|
# return False
|
||||||
match = re.match(r"^\s*(else|elif|except|finally).*\:", line)
|
match = self._re_unindentor.match(line)
|
||||||
# if True, whitespace matches up, we have a compound indentor,
|
# if True, whitespace matches up, we have a compound indentor,
|
||||||
# and this line has an unindentor, this
|
# and this line has an unindentor, this
|
||||||
# is probably good enough
|
# is probably good enough
|
||||||
@@ -193,6 +200,9 @@ class PythonPrinter:
|
|||||||
|
|
||||||
stripspace is a string of space that will be truncated from the
|
stripspace is a string of space that will be truncated from the
|
||||||
start of the line before indenting."""
|
start of the line before indenting."""
|
||||||
|
if stripspace == "":
|
||||||
|
# Fast path optimization.
|
||||||
|
return self.indentstring * self.indent + line
|
||||||
|
|
||||||
return re.sub(
|
return re.sub(
|
||||||
r"^%s" % stripspace, self.indentstring * self.indent, line
|
r"^%s" % stripspace, self.indentstring * self.indent, line
|
||||||
|
2
third_party/mako/mako/mako/pyparser.py
vendored
2
third_party/mako/mako/mako/pyparser.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/pyparser.py
|
# mako/pyparser.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
2
third_party/mako/mako/mako/template.py
vendored
2
third_party/mako/mako/mako/template.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/template.py
|
# mako/template.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
10
third_party/mako/mako/mako/testing/fixtures.py
vendored
10
third_party/mako/mako/mako/testing/fixtures.py
vendored
@@ -80,6 +80,16 @@ class TemplateTest:
|
|||||||
output = filters(output)
|
output = filters(output)
|
||||||
eq_(output, expected)
|
eq_(output, expected)
|
||||||
|
|
||||||
|
def indicates_unbound_local_error(self, rendered_output, unbound_var):
|
||||||
|
var = f"'{unbound_var}'"
|
||||||
|
error_msgs = (
|
||||||
|
# < 3.11
|
||||||
|
f"local variable {var} referenced before assignment",
|
||||||
|
# >= 3.11
|
||||||
|
f"cannot access local variable {var} where it is not associated",
|
||||||
|
)
|
||||||
|
return any((msg in rendered_output) for msg in error_msgs)
|
||||||
|
|
||||||
|
|
||||||
class PlainCacheImpl(CacheImpl):
|
class PlainCacheImpl(CacheImpl):
|
||||||
"""Simple memory cache impl so that tests which
|
"""Simple memory cache impl so that tests which
|
||||||
|
2
third_party/mako/mako/mako/util.py
vendored
2
third_party/mako/mako/mako/util.py
vendored
@@ -1,5 +1,5 @@
|
|||||||
# mako/util.py
|
# mako/util.py
|
||||||
# Copyright 2006-2021 the Mako authors and contributors <see AUTHORS file>
|
# Copyright 2006-2022 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
|
||||||
|
7
third_party/mako/mako/setup.cfg
vendored
7
third_party/mako/mako/setup.cfg
vendored
@@ -8,7 +8,7 @@ url = https://www.makotemplates.org/
|
|||||||
author = Mike Bayer
|
author = Mike Bayer
|
||||||
author_email = mike@zzzcomputing.com
|
author_email = mike@zzzcomputing.com
|
||||||
license = MIT
|
license = MIT
|
||||||
license_file = LICENSE
|
license_files = LICENSE
|
||||||
classifiers =
|
classifiers =
|
||||||
Development Status :: 5 - Production/Stable
|
Development Status :: 5 - Production/Stable
|
||||||
License :: OSI Approved :: MIT License
|
License :: OSI Approved :: MIT License
|
||||||
@@ -69,9 +69,12 @@ tag_build =
|
|||||||
tag_date = 0
|
tag_date = 0
|
||||||
|
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
addopts = --tb native -v -r fxX -W error
|
addopts = --tb native -v -r fxX -p warnings
|
||||||
python_files = test/*test_*.py
|
python_files = test/*test_*.py
|
||||||
python_classes = *Test
|
python_classes = *Test
|
||||||
|
filterwarnings =
|
||||||
|
error::DeprecationWarning:test
|
||||||
|
error::DeprecationWarning:mako
|
||||||
|
|
||||||
[upload]
|
[upload]
|
||||||
sign = 1
|
sign = 1
|
||||||
|
@@ -1,26 +1,35 @@
|
|||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from mako.ext.babelplugin import extract
|
import pytest
|
||||||
|
|
||||||
from mako.testing.assertions import eq_
|
from mako.testing.assertions import eq_
|
||||||
from mako.testing.config import config
|
from mako.testing.config import config
|
||||||
from mako.testing.exclusions import requires_babel
|
from mako.testing.exclusions import requires_babel
|
||||||
from mako.testing.fixtures import TemplateTest
|
from mako.testing.fixtures import TemplateTest
|
||||||
|
|
||||||
|
|
||||||
|
class UsesExtract:
|
||||||
|
@pytest.fixture(scope="class")
|
||||||
|
def extract(self):
|
||||||
|
from mako.ext.babelplugin import extract
|
||||||
|
|
||||||
|
return extract
|
||||||
|
|
||||||
|
|
||||||
@requires_babel
|
@requires_babel
|
||||||
class PluginExtractTest:
|
class PluginExtractTest(UsesExtract):
|
||||||
def test_parse_python_expression(self):
|
def test_parse_python_expression(self, extract):
|
||||||
input_ = io.BytesIO(b'<p>${_("Message")}</p>')
|
input_ = io.BytesIO(b'<p>${_("Message")}</p>')
|
||||||
messages = list(extract(input_, ["_"], [], {}))
|
messages = list(extract(input_, ["_"], [], {}))
|
||||||
eq_(messages, [(1, "_", ("Message"), [])])
|
eq_(messages, [(1, "_", ("Message"), [])])
|
||||||
|
|
||||||
def test_python_gettext_call(self):
|
def test_python_gettext_call(self, extract):
|
||||||
input_ = io.BytesIO(b'<p>${_("Message")}</p>')
|
input_ = io.BytesIO(b'<p>${_("Message")}</p>')
|
||||||
messages = list(extract(input_, ["_"], [], {}))
|
messages = list(extract(input_, ["_"], [], {}))
|
||||||
eq_(messages, [(1, "_", ("Message"), [])])
|
eq_(messages, [(1, "_", ("Message"), [])])
|
||||||
|
|
||||||
def test_translator_comment(self):
|
def test_translator_comment(self, extract):
|
||||||
input_ = io.BytesIO(
|
input_ = io.BytesIO(
|
||||||
b"""
|
b"""
|
||||||
<p>
|
<p>
|
||||||
@@ -43,8 +52,8 @@ class PluginExtractTest:
|
|||||||
|
|
||||||
|
|
||||||
@requires_babel
|
@requires_babel
|
||||||
class MakoExtractTest(TemplateTest):
|
class MakoExtractTest(UsesExtract, TemplateTest):
|
||||||
def test_extract(self):
|
def test_extract(self, extract):
|
||||||
with open(
|
with open(
|
||||||
os.path.join(config.template_base, "gettext.mako")
|
os.path.join(config.template_base, "gettext.mako")
|
||||||
) as mako_tmpl:
|
) as mako_tmpl:
|
||||||
@@ -83,7 +92,7 @@ class MakoExtractTest(TemplateTest):
|
|||||||
]
|
]
|
||||||
eq_(expected, messages)
|
eq_(expected, messages)
|
||||||
|
|
||||||
def test_extract_utf8(self):
|
def test_extract_utf8(self, extract):
|
||||||
with open(
|
with open(
|
||||||
os.path.join(config.template_base, "gettext_utf8.mako"), "rb"
|
os.path.join(config.template_base, "gettext_utf8.mako"), "rb"
|
||||||
) as mako_tmpl:
|
) as mako_tmpl:
|
||||||
@@ -92,7 +101,7 @@ class MakoExtractTest(TemplateTest):
|
|||||||
)
|
)
|
||||||
assert message == (1, "_", "K\xf6ln", [])
|
assert message == (1, "_", "K\xf6ln", [])
|
||||||
|
|
||||||
def test_extract_cp1251(self):
|
def test_extract_cp1251(self, extract):
|
||||||
with open(
|
with open(
|
||||||
os.path.join(config.template_base, "gettext_cp1251.mako"), "rb"
|
os.path.join(config.template_base, "gettext_cp1251.mako"), "rb"
|
||||||
) as mako_tmpl:
|
) as mako_tmpl:
|
||||||
|
@@ -2,7 +2,6 @@ import os
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from mako.ext.linguaplugin import LinguaMakoExtractor
|
|
||||||
from mako.testing.assertions import eq_
|
from mako.testing.assertions import eq_
|
||||||
from mako.testing.config import config
|
from mako.testing.config import config
|
||||||
from mako.testing.exclusions import requires_lingua
|
from mako.testing.exclusions import requires_lingua
|
||||||
@@ -19,11 +18,14 @@ class MockOptions:
|
|||||||
class MakoExtractTest(TemplateTest):
|
class MakoExtractTest(TemplateTest):
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def register_lingua_extractors(self):
|
def register_lingua_extractors(self):
|
||||||
|
|
||||||
from lingua.extractors import register_extractors
|
from lingua.extractors import register_extractors
|
||||||
|
|
||||||
register_extractors()
|
register_extractors()
|
||||||
|
|
||||||
def test_extract(self):
|
def test_extract(self):
|
||||||
|
from mako.ext.linguaplugin import LinguaMakoExtractor
|
||||||
|
|
||||||
plugin = LinguaMakoExtractor({"comment-tags": "TRANSLATOR"})
|
plugin = LinguaMakoExtractor({"comment-tags": "TRANSLATOR"})
|
||||||
messages = list(
|
messages = list(
|
||||||
plugin(
|
plugin(
|
||||||
|
13
third_party/mako/mako/test/test_exceptions.py
vendored
13
third_party/mako/mako/test/test_exceptions.py
vendored
@@ -173,7 +173,7 @@ ${foobar}
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
'<div class="sourceline"><table class="syntax-highlightedtable">'
|
'<table class="syntax-highlightedtable">'
|
||||||
in l.get_template("foo.html").render_unicode()
|
in l.get_template("foo.html").render_unicode()
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -274,10 +274,8 @@ ${foobar}
|
|||||||
html_error = exceptions.html_error_template().render_unicode(
|
html_error = exceptions.html_error_template().render_unicode(
|
||||||
error=v, traceback=None
|
error=v, traceback=None
|
||||||
)
|
)
|
||||||
assert (
|
|
||||||
"local variable 'y' referenced before assignment"
|
assert self.indicates_unbound_local_error(html_error, "y")
|
||||||
in html_error
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_tback_trace_from_py_file(self):
|
def test_tback_trace_from_py_file(self):
|
||||||
t = self._file_template("runtimeerr.html")
|
t = self._file_template("runtimeerr.html")
|
||||||
@@ -287,10 +285,7 @@ ${foobar}
|
|||||||
except:
|
except:
|
||||||
html_error = exceptions.html_error_template().render_unicode()
|
html_error = exceptions.html_error_template().render_unicode()
|
||||||
|
|
||||||
assert (
|
assert self.indicates_unbound_local_error(html_error, "y")
|
||||||
"local variable 'y' referenced before assignment"
|
|
||||||
in html_error
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_code_block_line_number(self):
|
def test_code_block_line_number(self):
|
||||||
l = TemplateLookup()
|
l = TemplateLookup()
|
||||||
|
19
third_party/mako/mako/test/test_template.py
vendored
19
third_party/mako/mako/test/test_template.py
vendored
@@ -940,18 +940,15 @@ class ControlTest(TemplateTest):
|
|||||||
%endfor
|
%endfor
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
assert (
|
assert result_lines(
|
||||||
result_lines(
|
t.render(
|
||||||
t.render(
|
y=[
|
||||||
y=[
|
{"test": "one"},
|
||||||
{"test": "one"},
|
{"foo": "bar"},
|
||||||
{"foo": "bar"},
|
{"foo": "bar", "test": "two"},
|
||||||
{"foo": "bar", "test": "two"},
|
]
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
== ["yes x has test", "no x does not have test", "yes x has test"]
|
) == ["yes x has test", "no x does not have test", "yes x has test"]
|
||||||
)
|
|
||||||
|
|
||||||
def test_blank_control_1(self):
|
def test_blank_control_1(self):
|
||||||
self._do_memory_test(
|
self._do_memory_test(
|
||||||
|
2
third_party/mako/mako/tox.ini
vendored
2
third_party/mako/mako/tox.ini
vendored
@@ -30,7 +30,7 @@ deps=
|
|||||||
pydocstyle<4.0.0
|
pydocstyle<4.0.0
|
||||||
# used by flake8-rst-docstrings
|
# used by flake8-rst-docstrings
|
||||||
pygments
|
pygments
|
||||||
black==21.9b0
|
black==22.3.0
|
||||||
commands =
|
commands =
|
||||||
flake8 ./mako/ ./test/ setup.py --exclude test/templates,test/foo {posargs}
|
flake8 ./mako/ ./test/ setup.py --exclude test/templates,test/foo {posargs}
|
||||||
black --check .
|
black --check .
|
||||||
|
Reference in New Issue
Block a user