OXIESEC PANEL
- Current Dir:
/
/
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
mako
Server IP: 2a02:4780:11:1084:0:327f:3464:10
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
09/05/2025 09:34:06 AM
rwxr-xr-x
📄
__init__.py
242 bytes
12/18/2024 10:23:16 AM
rw-r--r--
📁
__pycache__
-
02/07/2025 10:01:51 PM
rwxr-xr-x
📄
_ast_util.py
19.77 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
ast.py
6.49 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
cache.py
7.5 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
cmd.py
2.75 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
codegen.py
46.2 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
compat.py
1.87 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
exceptions.py
12.24 KB
12/18/2024 10:23:16 AM
rw-r--r--
📁
ext
-
02/07/2025 10:01:31 PM
rwxr-xr-x
📄
filters.py
4.55 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
lexer.py
15.61 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
lookup.py
12.14 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
parsetree.py
18.56 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
pygen.py
10.17 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
pyparser.py
6.87 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
runtime.py
27.15 KB
12/18/2024 10:23:16 AM
rw-r--r--
📄
template.py
23.3 KB
12/18/2024 10:23:16 AM
rw-r--r--
📁
testing
-
02/07/2025 10:01:31 PM
rwxr-xr-x
📄
util.py
10.39 KB
12/18/2024 10:23:16 AM
rw-r--r--
Editing: cmd.py
Close
# mako/cmd.py # Copyright 2006-2022 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 from os.path import dirname from os.path import isfile import sys from mako import exceptions from mako.lookup import TemplateLookup from mako.template import Template def varsplit(var): if "=" not in var: return (var, "") return var.split("=", 1) def _exit(): sys.stderr.write(exceptions.text_error_template().render()) sys.exit(1) def cmdline(argv=None): parser = ArgumentParser() parser.add_argument( "--var", default=[], action="append", help="variable (can be used multiple times, use name=value)", ) parser.add_argument( "--template-dir", default=[], action="append", help="Directory to use for template lookup (multiple " "directories may be provided). If not given then if the " "template is read from stdin, the value defaults to be " "the current directory, otherwise it defaults to be the " "parent directory of the file provided.", ) 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 ["."] lookup = TemplateLookup(lookup_dirs) try: template = Template( sys.stdin.read(), lookup=lookup, output_encoding=output_encoding, ) except: _exit() else: filename = options.input if not isfile(filename): raise SystemExit("error: can't find %s" % filename) lookup_dirs = options.template_dir or [dirname(filename)] lookup = TemplateLookup(lookup_dirs) try: template = Template( filename=filename, lookup=lookup, output_encoding=output_encoding, ) except: _exit() kw = dict(varsplit(var) for var in options.var) try: rendered = template.render(**kw) except: _exit() else: if output_file: open(output_file, "wt", encoding=output_encoding).write(rendered) else: sys.stdout.write(rendered) if __name__ == "__main__": cmdline()