<commit_before>#!/usr/bin/python3.3
import os, argparse
from jinja2 import Environment, FileSystemLoader

# Command-line arguments and help text
stdin_parser=argparse.ArgumentParser(description='Compiles Jinja2 templates into a complete and hopefully usable file.', epilog='Report bugs to <<EMAIL>>.')
stdin_parser.add_argument('inputfile', metavar='INPUTFILE', help='Input file')
stdin_parser.add_argument('-t', '--templates', metavar='DIR', help='Path to templates that INPUTFILE extends from', required=True)
stdin_parser.add_argument('-o', dest='outputfile', metavar='OUTPUTFILE', type=argparse.FileType('w'), help='Output file')
stdin_args=stdin_parser.parse_args()

# Render the jinja
env=Environment(loader=FileSystemLoader([os.path.normpath(stdin_args.templates), os.path.relpath(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(), stdin_args.inputfile))))]))
rendered=env.get_template(os.path.basename(stdin_args.inputfile)).render()
if stdin_args.outputfile:
	stdin_args.outputfile.write(rendered)
else:
	print(rendered)
<commit_msg>No need for output parameter, can use redirection instead<commit_after>#!/usr/bin/python3.3
import os, argparse
from jinja2 import Environment, FileSystemLoader

# Command-line arguments and help text
stdin_parser=argparse.ArgumentParser(description='Compiles Jinja2 templates into a complete and hopefully usable file.', epilog='Report bugs to <<EMAIL>>.')
stdin_parser.add_argument('inputfile', metavar='INPUTFILE', help='Input file')
stdin_parser.add_argument('-t', '--templates', metavar='DIR', help='Path to templates that INPUTFILE extends from', required=True)
stdin_args=stdin_parser.parse_args()

# Render the jinja
env=Environment(loader=FileSystemLoader([os.path.normpath(stdin_args.templates), os.path.relpath(os.path.dirname(os.path.normpath(os.path.join(os.getcwd(), stdin_args.inputfile))))]))
rendered=env.get_template(os.path.basename(stdin_args.inputfile)).render()
print(rendered)

{'fraction_non_alphanumeric': 0.13794871794871794, 'fraction_numerical': 0.0041025641025641026, 'mean_word_length': 8.610837438423646, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6733824', 'n_tokens_mistral': 632, 'n_tokens_neox': 619, 'n_words': 122}