Commit d2837f28 authored by Lorenz Steinert's avatar Lorenz Steinert

fixed umlaute bug

parent 37d08e6c
...@@ -11,6 +11,7 @@ import os ...@@ -11,6 +11,7 @@ import os
import shutil import shutil
import time import time
import ldap3 as ldap import ldap3 as ldap
import codecs
try: try:
import pwd import pwd
...@@ -32,7 +33,7 @@ class Protokollskript: ...@@ -32,7 +33,7 @@ class Protokollskript:
def __init__(self): def __init__(self):
""" Hier Sprecher und Protokollant setzen """ """ Hier Sprecher und Protokollant setzen """
self.sprecher = "Silvia Hiebel" self.sprecher = "Silvia Hiebel"
self.protokollant = u"Markus Ühlein" self.protokollant = "Markus Ühlein"
self.num_cols = 4 self.num_cols = 4
self.num_cols_ext = 1 self.num_cols_ext = 1
self.editor = "vim" self.editor = "vim"
...@@ -191,16 +192,16 @@ class Protokollskript: ...@@ -191,16 +192,16 @@ class Protokollskript:
outfile = outdir + "/fsr_physik_protokoll_" + self.year + "-" \ outfile = outdir + "/fsr_physik_protokoll_" + self.year + "-" \
+ self.mon + "-" + self.day + ".tex" + self.mon + "-" + self.day + ".tex"
with open('name.tex', 'r') as fobj_name: with codecs.open('name.tex', 'r', 'utf-8') as fobj_name:
f_name = fobj_name.read() f_name = fobj_name.read()
with open('acroname.tex', 'r') as fobj_acroname: with codecs.open('acroname.tex', 'r', 'utf-8') as fobj_acroname:
f_acroname = fobj_acroname.read() f_acroname = fobj_acroname.read()
with open('acro.tex', 'r') as fobj_acro: with codecs.open('acro.tex', 'r', 'utf-8') as fobj_acro:
f_acro = fobj_acro.read() f_acro = fobj_acro.read()
with open('head.tex', 'r') as fobj_head: with codecs.open('head.tex', 'r', 'utf-8') as fobj_head:
f_head = fobj_head.read() f_head = fobj_head.read()
f_head = self.reg_fsrname.sub(f_name, f_head) f_head = self.reg_fsrname.sub(f_name, f_head)
...@@ -210,75 +211,102 @@ class Protokollskript: ...@@ -210,75 +211,102 @@ class Protokollskript:
f_head = self.reg_prot.sub(self.protokollant, f_head) f_head = self.reg_prot.sub(self.protokollant, f_head)
f_head = self.reg_date.sub(self.date, f_head) f_head = self.reg_date.sub(self.date, f_head)
with open('foot.tex', 'r') as fobj_foot: with codecs.open('foot.tex', 'r', 'utf-8') as fobj_foot:
f_foot = fobj_foot.read() f_foot = fobj_foot.read()
f_foot = self.reg_spr.sub(self.sprecher, f_foot) f_foot = self.reg_spr.sub(self.sprecher, f_foot)
f_foot = self.reg_prot.sub(self.protokollant, f_foot) f_foot = self.reg_prot.sub(self.protokollant, f_foot)
f_foot = self.reg_date.sub(self.date, f_foot) f_foot = self.reg_date.sub(self.date, f_foot)
with open(outfile, 'w') as fobj_out: msg = ""
fobj_out.write(f_head)
msg += f_head
fobj_out.write("~\\newline\n") #fobj_out.write(f_head)
tabdef = "||" msg += "~\\newline\n"
for i in range(self.num_cols): #fobj_out.write("~\\newline\n")
tabdef += "c|l||"
fobj_out.write("FSR-Mitglieder\\\\\n\\\\\n\\scriptsize{\\begin{tabular}{" tabdef = "||"
+ tabdef + "}\n\\hline\n") for i in range(self.num_cols):
tabdef += "c|l||"
for i in zip(self.fsr, range(len(self.fsr))): msg += "FSR-Mitglieder\\\\\n\\\\\n\\scriptsize{\\begin{tabular}{" \
if i[1] % self.num_cols == 0: + tabdef + "}\n\\hline\n"
fobj_out.write(" ") #fobj_out.write("FSR-Mitglieder\\\\\n\\\\\n\\scriptsize{\\begin{tabular}{"
else: #+ tabdef + "}\n\\hline\n")
fobj_out.write("&")
for i in zip(self.fsr, range(len(self.fsr))):
if "Sarah" in i[0]: if i[1] % self.num_cols == 0:
fobj_out.write(r" &Sarah Anna Kova\v{c}") msg += " "
else: #fobj_out.write(" ")
fobj_out.write(" &" + i[0]) else:
msg += "&"
if i[1] % self.num_cols == self.num_cols - 1: #fobj_out.write("&")
fobj_out.write("\\\\\\hline\n")
else: if "Sarah" in i[0]:
fobj_out.write("\n") msg += r" &Sarah Anna Kova\v{c}"
#fobj_out.write(r" &Sarah Anna Kova\v{c}")
if not len(self.fsr)%self.num_cols==0: else:
for i in range(self.num_cols - len(self.fsr)%self.num_cols): msg += " &" + i[0]
fobj_out.write("& &\n") #fobj_out.write(" &" + i[0])
fobj_out.write("\\\\\\hline\n")
if i[1] % self.num_cols == self.num_cols - 1:
msg += "\\\\\\hline\n"
#fobj_out.write("\\\\\\hline\n")
else:
msg += "\n"
#fobj_out.write("\n")
if not len(self.fsr)%self.num_cols==0:
for i in range(self.num_cols - len(self.fsr)%self.num_cols):
msg += "& &\n"
#fobj_out.write("& &\n")
msg += "\\\\\\hline\n"
#fobj_out.write("\\\\\\hline\n")
msg += r"\end{tabular}}\normalsize\vspace{1em}"
fobj_out.write(r"\end{tabular}}\normalsize\vspace{1em}") msg += "\n\\newline\n"
fobj_out.write("\n\\newline\n") #fobj_out.write(r"\end{tabular}}\normalsize\vspace{1em}")
#fobj_out.write("\n\\newline\n")
tabdef = "||"
for i in range(self.num_cols_ext): tabdef = "||"
tabdef += "c|l||" for i in range(self.num_cols_ext):
fobj_out.write("Externe Referenten\\\\\n\\\\\n" tabdef += "c|l||"
+ r"\scriptsize{\begin{tabular}{" msg += "Externe Referenten\\\\\n\\\\\n" \
+ tabdef + "}\n\\hline\n") + r"\scriptsize{\begin{tabular}{" \
+ tabdef + "}\n\\hline\n"
for i in zip(self.fsr_extern, range(len(self.fsr_extern))): #fobj_out.write("Externe Referenten\\\\\n\\\\\n"
if i[1] % self.num_cols_ext == 0: #+ r"\scriptsize{\begin{tabular}{"
fobj_out.write(" ") #+ tabdef + "}\n\\hline\n")
else:
fobj_out.write("&") for i in zip(self.fsr_extern, range(len(self.fsr_extern))):
if i[1] % self.num_cols_ext == 0:
if "Sarah" in i[0]: msg += " "
fobj_out.write(r" &Sarah Anna Kova\v{c}") #fobj_out.write(" ")
else: else:
fobj_out.write(" &" + i[0]) msg += "&"
#fobj_out.write("&")
if i[1] % self.num_cols_ext == self.num_cols_ext - 1:
fobj_out.write("\\\\\\hline\n") if "Sarah" in i[0]:
else: msg += r" &Sarah Anna Kova\v{c}"
fobj_out.write("\n") #fobj_out.write(r" &Sarah Anna Kova\v{c}")
else:
fobj_out.write("\\end{tabular}}\\normalsize") msg += " &" +i[0]
#fobj_out.write(" &" + i[0])
fobj_out.write(f_foot)
if i[1] % self.num_cols_ext == self.num_cols_ext - 1:
msg += "\\\\\\hline\n"
#fobj_out.write("\\\\\\hline\n")
else:
msg += "\n"
#fobj_out.write("\n")
msg += "\\end{tabular}}\\normalsize"
#fobj_out.write("\\end{tabular}}\\normalsize")
msg += f_foot
#fobj_out.write(f_foot)
with codecs.open(outfile, 'w', 'utf-8') as fobj_out:
fobj_out.write(msg)
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment