Update mako to 1.1.2

This commit is contained in:
JonnyWong16 2020-03-23 20:57:35 -07:00
parent 843a400b2d
commit 4564623884
27 changed files with 53 additions and 112 deletions

View file

@ -1,19 +0,0 @@
Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>.
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
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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
SOFTWARE.

View file

@ -1,52 +0,0 @@
=========================
Mako Templates for Python
=========================
Mako is a template library written in Python. It provides a familiar, non-XML
syntax which compiles into Python modules for maximum performance. Mako's
syntax and API borrows from the best ideas of many others, including Django
templates, Cheetah, Myghty, and Genshi. Conceptually, Mako is an embedded
Python (i.e. Python Server Page) language, which refines the familiar ideas
of componentized layout and inheritance to produce one of the most
straightforward and flexible models available, while also maintaining close
ties to Python calling and scoping semantics.
Nutshell
========
::
<%inherit file="base.html"/>
<%
rows = [[v for v in range(0,10)] for row in range(0,10)]
%>
<table>
% for row in rows:
${makerow(row)}
% endfor
</table>
<%def name="makerow(row)">
<tr>
% for name in row:
<td>${name}</td>\
% endfor
</tr>
</%def>
Philosophy
===========
Python is a great scripting language. Don't reinvent the wheel...your templates can handle it !
Documentation
==============
See documentation for Mako at https://docs.makotemplates.org/en/latest/
License
========
Mako is licensed under an MIT-style license (see LICENSE).
Other incorporated projects may be licensed under different licenses.
All licenses allow for non-commercial and commercial use.

View file

@ -1,8 +1,8 @@
# mako/__init__.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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
__version__ = "1.1.0"
__version__ = '1.1.2'

View file

@ -1,5 +1,5 @@
# mako/_ast_util.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/ast.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/cache.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,9 +1,10 @@
# mako/cmd.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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 argparse import ArgumentParser
import io
from os.path import dirname
from os.path import isfile
import sys
@ -46,11 +47,17 @@ def cmdline(argv=None):
parser.add_argument(
"--output-encoding", default=None, help="force output encoding"
)
parser.add_argument(
"--output-file",
default=None,
help="Write to file upon successful render instead of stdout",
)
parser.add_argument("input", nargs="?", default="-")
options = parser.parse_args(argv)
output_encoding = options.output_encoding
output_file = options.output_file
if options.input == "-":
lookup_dirs = options.template_dir or ["."]
@ -80,9 +87,16 @@ def cmdline(argv=None):
kw = dict([varsplit(var) for var in options.var])
try:
sys.stdout.write(template.render(**kw))
rendered = template.render(**kw)
except:
_exit()
else:
if output_file:
io.open(output_file, "wt", encoding=output_encoding).write(
rendered
)
else:
sys.stdout.write(rendered)
if __name__ == "__main__":

View file

@ -1,5 +1,5 @@
# mako/codegen.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/compat.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/exceptions.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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
@ -166,9 +166,7 @@ class RichTraceback(object):
module_source = info.code
template_source = info.source
template_filename = (
info.template_filename
or info.template_uri
or filename
info.template_filename or info.template_uri or filename
)
except KeyError:
# A normal .py file (not a Template)

View file

@ -1,5 +1,5 @@
# ext/autohandler.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# ext/babelplugin.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# ext/beaker_cache.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# ext/extract.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# ext/linguaplugin.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# ext/preprocessors.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# ext/pygmentplugin.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# ext/turbogears.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/filters.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/lexer.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/lookup.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/parsetree.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/pygen.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/pyparser.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/runtime.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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

View file

@ -1,5 +1,5 @@
# mako/template.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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
@ -520,17 +520,17 @@ class ModuleTemplate(Template):
"""A Template which is constructed given an existing Python module.
e.g.::
e.g.::
t = Template("this is a template")
f = file("mymodule.py", "w")
f.write(t.code)
f.close()
t = Template("this is a template")
f = file("mymodule.py", "w")
f.write(t.code)
f.close()
import mymodule
import mymodule
t = ModuleTemplate(mymodule)
print t.render()
t = ModuleTemplate(mymodule)
print(t.render())
"""

View file

@ -1,9 +1,11 @@
# mako/util.py
# Copyright 2006-2019 the Mako authors and contributors <see AUTHORS file>
# Copyright 2006-2020 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 __future__ import absolute_import
from ast import parse
import codecs
import collections
import operator
@ -257,9 +259,7 @@ def parse_encoding(fp):
m = _PYTHON_MAGIC_COMMENT_re.match(line1.decode("ascii", "ignore"))
if not m:
try:
import parser
parser.suite(line1.decode("ascii", "ignore"))
parse(line1.decode("ascii", "ignore"))
except (ImportError, SyntaxError):
# Either it's a real syntax error, in which case the source
# is not valid python source, or line2 is a continuation of