Commit bd55a52b authored by Lorenz Steinert's avatar Lorenz Steinert

added reading of proto.ini and renaming of vars

parent 27ecd3d0
......@@ -3,7 +3,7 @@
"""
Created on Fri Nov 24 15:35:04 2017
@author: lorico
@author: Lorenz Steinert
"""
import re
......@@ -12,6 +12,7 @@ import sys
import shutil
import time
import codecs
import configparser
import ldap3 as ldap
try:
......@@ -32,13 +33,8 @@ class Protokollskript:
"""Class die die protokoll .tex datei erstellt"""
def __init__(self, opt):
""" Hier Sprecher und Protokollant setzen """
self.sprecher = "Silvia Hiebel"
self.protokollant = "Markus Ühlein"
self.num_cols = 4
self.num_cols_ext = 1
self.editor = "vim"
""" Ab hier bitte nur etwas aendern, wenn du weisst was du tust! """
config = configparser.ConfigParser()
config.read('./proto.ini')
self.server = ldap.Server("rincewind.fs.physik.uni-kl.de")
self.base = "dc=fs,dc=physik,dc=uni-kl,dc=de"
......@@ -204,18 +200,22 @@ class Protokollskript:
def main(self):
"""main function of the class"""
num_cols = self.config['DEFAULT'].getint('num_cols')
num_cols_ext = self.config['DEFAULT'].getint('num_cols_ext')
print("\n")
self.protokollant = self.get_protokollant_ldap(self.protokollant)
protokollant = self.get_protokollant_ldap(self.config['DEFAULT']['Sprecher'])
self.fsr = self.get_fsr_ldap(self.fsr)
self.fsr_extern = self.get_fsr_extern_ldap(self.fsr_extern)
print("\n")
print("Wenn der Standardwert (in []) stimmt einfach Enter!\n")
# get data form user
self.sprecher = self.get_sprecher(self.sprecher)
self.protokollant = self.get_protokollant(self.protokollant)
sprecher = self.get_sprecher(self.config['DEFAULT']['Sprecher'])
protokollant = self.get_protokollant(protokollant)
self.date, self.day, self.mon, self.year = self.get_date(self.date)
self.editor = self.get_editor(self.editor)
# self.editor = self.get_editor(self.editor)
outdir = "../" + self.year + "/fsr_physik_sitzung_" + self.year + "-" \
+ self.mon + "-" + self.day + "/"
......@@ -242,8 +242,8 @@ class Protokollskript:
f_head = self.reg['FSRN'].sub(f_name, f_head)
f_head = self.reg['ACRON'].sub(f_acroname, f_head)
f_head = self.reg['ACRO'].sub(f_acro, f_head)
f_head = self.reg['SPR'].sub(self.sprecher, f_head)
f_head = self.reg['PRO'].sub(self.protokollant, f_head)
f_head = self.reg['SPR'].sub(sprecher, f_head)
f_head = self.reg['PRO'].sub(protokollant, f_head)
f_head = self.reg['DATE'].sub(self.date, f_head)
if self.opt['-VV']:
......@@ -253,8 +253,8 @@ class Protokollskript:
with codecs.open('foot.tex', 'r', 'utf-8') as fobj_foot:
f_foot = fobj_foot.read()
f_foot = self.reg['SPR'].sub(self.sprecher, f_foot)
f_foot = self.reg['PRO'].sub(self.protokollant, f_foot)
f_foot = self.reg['SPR'].sub(sprecher, f_foot)
f_foot = self.reg['PRO'].sub(protokollant, f_foot)
f_foot = self.reg['DATE'].sub(self.date, f_foot)
msg = ""
......@@ -267,7 +267,7 @@ class Protokollskript:
if not self.opt['-VV']:
tabdef = "||"
for i in range(self.num_cols):
for i in range(num_cols):
tabdef += "c|l||"
msg += "FSR-Mitglieder\\\\\n\\\\\n\\scriptsize{\\begin{tabular}{" \
+ tabdef + "}\n\\hline\n"
......@@ -275,7 +275,7 @@ class Protokollskript:
#+ tabdef + "}\n\\hline\n")
for i in zip(self.fsr, range(len(self.fsr))):
if i[1] % self.num_cols == 0:
if i[1] % num_cols == 0:
msg += " "
#fobj_out.write(" ")
else:
......@@ -289,15 +289,15 @@ class Protokollskript:
msg += " &" + i[0]
#fobj_out.write(" &" + i[0])
if i[1] % self.num_cols == self.num_cols - 1:
if i[1] % num_cols == 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):
if not len(self.fsr)%num_cols == 0:
for i in range(num_cols - len(self.fsr)%num_cols):
msg += "& &\n"
#fobj_out.write("& &\n")
msg += "\\\\\\hline\n"
......@@ -309,7 +309,7 @@ class Protokollskript:
#fobj_out.write("\n\\newline\n")
tabdef = "||"
for i in range(self.num_cols_ext):
for i in range(num_cols_ext):
tabdef += "c|l||"
msg += "Externe Referenten\\\\\n\\\\\n" \
+ r"\scriptsize{\begin{tabular}{" \
......@@ -319,7 +319,7 @@ class Protokollskript:
#+ tabdef + "}\n\\hline\n")
for i in zip(self.fsr_extern, range(len(self.fsr_extern))):
if i[1] % self.num_cols_ext == 0:
if i[1] % num_cols_ext == 0:
msg += " "
#fobj_out.write(" ")
else:
......@@ -333,7 +333,7 @@ class Protokollskript:
msg += " &" +i[0]
#fobj_out.write(" &" + i[0])
if i[1] % self.num_cols_ext == self.num_cols_ext - 1:
if i[1] % num_cols_ext == num_cols_ext - 1:
msg += "\\\\\\hline\n"
#fobj_out.write("\\\\\\hline\n")
else:
......
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