Skip to content

Commit

Permalink
MAINT: Fix template expansion
Browse files Browse the repository at this point in the history
Discourage expansion if contents are identical
  • Loading branch information
bashtage committed Dec 21, 2019
1 parent 13e294e commit 052e5b7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,15 @@ def src_join(*fname):
output_file_name = splitext(templated_file)[0]
with open(templated_file, "r") as source_file:
template = tempita.Template(source_file.read())
processed = template.substitute()
with open(output_file_name, "w", newline="\n") as output_file:
output_file.write(processed)
processed = template.substitute().replace("\r\n", "\n")
contents = ''
if exists(output_file_name):
with open(output_file_name, "r") as output_file:
contents = output_file.read()
if contents != processed:
print("Processing {0} to {1}".format(templated_file, output_file_name))
with open(output_file_name, "w", newline="\n") as output_file:
output_file.write(processed)

extensions = []
for name in ("bounded_integers", "common", "entropy", "generator",
Expand Down

0 comments on commit 052e5b7

Please sign in to comment.