mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 15:32:38 -07:00
Update mako to 1.1.2
This commit is contained in:
parent
843a400b2d
commit
4564623884
27 changed files with 53 additions and 112 deletions
|
@ -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__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue