#!/usr/bin/env python3

import sys as _sys

def string_coin(
	template,
	arguments
):
	result = template
	for (key, value, ) in arguments.items():
		result = result.replace("{{%s}}" % key, value)
	return result
	

def file_read(path):
	handle = open(path, "r")
	content = handle.read()
	handle.close()
	return content
	

def file_write(path, content):
	handle = open(path, "w")
	handle.write(content)
	handle.close()
	

def main(args):
	## args
	path_main = args.pop(0)
	paths_templates = args
	args = []

	## exec
	_sys.stdout.write(
		string_coin(
			file_read(path_main),
			{
				"templates": "\n".join(map(lambda path: file_read(path), paths_templates))
			}
		)
	)
	

main(_sys.argv[1:])
