went back to commit #2

had to test multiple nested "with open()"s to see if they were okay
This commit is contained in:
Ryan Gardner 2017-12-26 12:18:31 +00:00 committed by clemahieu
commit b67e9be8bc

View file

@ -4,19 +4,18 @@ import os
import subprocess
if not os.path.exists("bootstrap"):
os.mkdir("bootstrap")
os.mkdir("bootstrap")
contents = sys.stdin.read()
subs = re.findall("\{.*?\}", contents, re.DOTALL)
html_file = open("./bootstrap/index.html", "w")
html_file.write("<body>")
for block_number,sub in enumerate(subs):
with open("./bootstrap/index.html", "w") as html_file:
html_file.write("<body>")
for block_number,sub in enumerate(subs):
block_number = str(block_number)
block_file_name = "".join(("./bootstrap/block", block_number, ".json"))
block_file = open(block_file_name, "w")
block_file.write(sub)
block_file.close()
block_file = open(block_file_name, "r")
qr_file_name = "".join(("./bootstrap/block", block_number, ".png"))
html_file.write("".join(("<img src=\"block", block_number, ".png\"/>")))
subprocess.call(["qrencode", "-o", qr_file_name], stdin=block_file)
html_file.write("</body>")
with open(block_file_name, "w") as block_file:
block_file.write(sub)
with open(block_file_name, "r") as block_file:
qr_file_name = "".join(("./bootstrap/block", block_number, ".png"))
html_file.write("".join(("<img src=\"block", block_number, ".png\"/>")))
subprocess.call(["qrencode", "-o", qr_file_name], stdin=block_file)
html_file.write("</body>")