You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
#!/usr/bin/env python3
|
|
|
|
'''
|
|
THIS CODE IS TOTALLY SCUFFED.
|
|
It works, but is in no way smart or efficient. It may break any second.
|
|
Use at own risk.
|
|
'''
|
|
import os
|
|
|
|
|
|
head_file = open("env/HEAD.tex", "r")
|
|
head_text = head_file.readlines()
|
|
head_file.close()
|
|
foot_file = open("env/FOOT.tex", "r")
|
|
foot_text = foot_file.readlines()
|
|
foot_file.close()
|
|
|
|
def convert_table(table):
|
|
result = []
|
|
for line in table:
|
|
line = line[1:-2]
|
|
line = line.replace("|", "&")
|
|
line = line + " \\\\"
|
|
result.append(line)
|
|
return(result)
|
|
|
|
|
|
def generate_tex(filename, env, env_content):
|
|
table = convert_table(env_content)
|
|
with open(filename, "w") as file_object:
|
|
for line in head_text:
|
|
line = line.replace("ENVIRON", env)
|
|
file_object.write(line)
|
|
file_object.write("\n")
|
|
for line in table:
|
|
file_object.write(line + "\n")
|
|
for line in foot_text:
|
|
file_object.write(line)
|
|
|
|
for root, dirs, files in os.walk("env"):
|
|
for filename in files:
|
|
if filename.endswith(".org"):
|
|
with open(os.path.join(root, filename), "r") as file_content:
|
|
text = file_content.readlines()
|
|
env = filename.split(".")[0]
|
|
generate_tex("ua-ranger-favored-environment-" + env + ".tex", env, text)
|
|
|