61 lines
880 B
Python
Executable file
61 lines
880 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import sys as _sys
|
|
import argparse as _argparse
|
|
|
|
|
|
def file_read(
|
|
path
|
|
):
|
|
handle = open(path, "r")
|
|
content = handle.read()
|
|
handle.close()
|
|
return content
|
|
|
|
|
|
def string_coin(
|
|
template,
|
|
arguments
|
|
):
|
|
result = template
|
|
for (key, value, ) in arguments.items():
|
|
result = result.replace("{{%s}}" % key, value)
|
|
return result
|
|
|
|
|
|
def main(
|
|
):
|
|
## args
|
|
argument_parser = _argparse.ArgumentParser()
|
|
argument_parser.add_argument(
|
|
dest = "index_template_path",
|
|
type = str,
|
|
)
|
|
argument_parser.add_argument(
|
|
"-t",
|
|
"--template",
|
|
dest = "template_paths",
|
|
type = str,
|
|
action = "append",
|
|
default = []
|
|
)
|
|
args = argument_parser.parse_args()
|
|
|
|
## exec
|
|
_sys.stdout.write(
|
|
string_coin(
|
|
file_read(args.index_template_path),
|
|
{
|
|
"templates": "".join(
|
|
map(
|
|
file_read,
|
|
args.template_paths
|
|
)
|
|
),
|
|
}
|
|
)
|
|
)
|
|
|
|
|
|
main()
|
|
|