Commit 3c18243f authored by Lorenz Steinert's avatar Lorenz Steinert

ini_file should be working and help added

parent 9f5c5b07
...@@ -62,7 +62,9 @@ class Protokollskript: ...@@ -62,7 +62,9 @@ class Protokollskript:
'ACRON': re.compile('%%ACRONAME'), 'ACRON': re.compile('%%ACRONAME'),
'FSRN': re.compile('%%FSRNAME')} 'FSRN': re.compile('%%FSRNAME')}
self.fsr = sorted([re.sub(re.escape('\t'), self.fsr = ['','']
self.fsr[0] = sorted([re.sub(re.escape('\t'),
' ', ' ',
line.rstrip('\n')) line.rstrip('\n'))
for line in codecs.open('./fsr', for line in codecs.open('./fsr',
...@@ -70,19 +72,18 @@ class Protokollskript: ...@@ -70,19 +72,18 @@ class Protokollskript:
'utf-8').readlines()], 'utf-8').readlines()],
key=lambda x: ''.join(x.split(' ')[::-1])) key=lambda x: ''.join(x.split(' ')[::-1]))
self.fsr_extern = sorted([re.sub(re.escape('\t'), self.fsr[1] = sorted([re.sub(re.escape('\t'),
' ', ' ',
line.rstrip('\n')) line.rstrip('\n'))
for line in codecs.open('./fsr_extern', 'r', for line in codecs.open('./fsr_extern', 'r',
'utf-8').readlines()], 'utf-8').readlines()],
key=lambda x: ''.join(x.split(' ')[::-1])) key=lambda x: ''.join(x.split(' ')[::-1]))
self.opt = {'-d': False, '-VV': False} self.opt = {'-d': False, '-VV': False, '-h': False}
for i in opt[1:]: for i in opt[1:]:
if i in self.opt.keys(): if i in self.opt.keys():
self.opt[i] = True self.opt[i] = True
print(self.opt)
else: else:
print(i + ' ist keine Option für das Protokollskript. \ print(i + ' ist keine Option für das Protokollskript. \
\nVerfügbare Optionen sind: \n' + \nVerfügbare Optionen sind: \n' +
...@@ -193,7 +194,7 @@ class Protokollskript: ...@@ -193,7 +194,7 @@ class Protokollskript:
if len(mon) < 2: mon = "0" + mon if len(mon) < 2: mon = "0" + mon
if len(day) < 2: day = "0" + day if len(day) < 2: day = "0" + day
date = day + "." + mon + "." + year date = day + "." + mon + "." + year
return date, day, mon, year return (date, year, mon, day)
return date return date
@staticmethod @staticmethod
...@@ -204,16 +205,27 @@ class Protokollskript: ...@@ -204,16 +205,27 @@ class Protokollskript:
return etmp return etmp
return editor return editor
@staticmethod
def help():
print('')
print('proto.py : Erstellt ein Sitzungs-Protokoll')
print('proto.py -h : Gibt diese Hilfe aus.')
print('proto.py -VV: erstellt ein VV-Protokoll.')
raise SystemExit(0)
def main(self): def main(self):
"""main function of the class""" """main function of the class"""
if self.opt['-h']: self.help()
num_cols = self.config['DEFAULT'].getint('num_cols') num_cols = self.config['DEFAULT'].getint('num_cols')
num_cols_ext = self.config['DEFAULT'].getint('num_cols_ext') num_cols_ext = self.config['DEFAULT'].getint('num_cols_ext')
print("\n") print("\n")
protokollant = self.get_protokollant_ldap(self.config['DEFAULT']['Protokollant']) protokollant = self.get_protokollant_ldap(self.config['DEFAULT']['Protokollant'])
self.fsr = self.get_fsr_ldap(self.fsr) self.fsr[0] = self.get_fsr_ldap(self.fsr[0])
self.fsr_extern = self.get_fsr_extern_ldap(self.fsr_extern) self.fsr[1] = self.get_fsr_extern_ldap(self.fsr[1])
print("\n") print("\n")
print("Wenn der Standardwert (in []) stimmt einfach Enter!\n") print("Wenn der Standardwert (in []) stimmt einfach Enter!\n")
...@@ -231,7 +243,7 @@ class Protokollskript: ...@@ -231,7 +243,7 @@ class Protokollskript:
shutil.copyfile("./FS-Logo.pdf", outdir + "FS-Logo.pdf") shutil.copyfile("./FS-Logo.pdf", outdir + "FS-Logo.pdf")
outfile = outdir + "/fsr_physik_protokoll_" + self.date[1] + "-" \ outfile = outdir + "/fsr_physik_protokoll_" + self.date[1] + "-" \
+ self.date[2] + "-" + self.date[3] + ".tex" + self.date[2] + "-" + self.date[3] + ".tex"
with codecs.open('name.tex', 'r', 'utf-8') as fobj_name: with codecs.open('name.tex', 'r', 'utf-8') as fobj_name:
f_name = fobj_name.read() f_name = fobj_name.read()
...@@ -276,7 +288,7 @@ class Protokollskript: ...@@ -276,7 +288,7 @@ class Protokollskript:
msg += "FSR-Mitglieder\\\\\n\\\\\n\\scriptsize{\\begin{tabular}{" \ msg += "FSR-Mitglieder\\\\\n\\\\\n\\scriptsize{\\begin{tabular}{" \
+ tabdef + "}\n\\hline\n" + tabdef + "}\n\\hline\n"
for i in zip(self.fsr, range(len(self.fsr))): for i in zip(self.fsr[0], range(len(self.fsr[0]))):
if i[1] % num_cols == 0: if i[1] % num_cols == 0:
msg += " " msg += " "
else: else:
...@@ -292,8 +304,8 @@ class Protokollskript: ...@@ -292,8 +304,8 @@ class Protokollskript:
else: else:
msg += "\n" msg += "\n"
if not len(self.fsr)%num_cols == 0: if not len(self.fsr[0])%num_cols == 0:
for i in range(num_cols - len(self.fsr)%num_cols): for i in range(num_cols - len(self.fsr[0])%num_cols):
msg += "& &\n" msg += "& &\n"
msg += "\\\\\\hline\n" msg += "\\\\\\hline\n"
...@@ -307,7 +319,7 @@ class Protokollskript: ...@@ -307,7 +319,7 @@ class Protokollskript:
+ r"\scriptsize{\begin{tabular}{" \ + r"\scriptsize{\begin{tabular}{" \
+ tabdef + "}\n\\hline\n" + tabdef + "}\n\\hline\n"
for i in zip(self.fsr_extern, range(len(self.fsr_extern))): for i in zip(self.fsr[1], range(len(self.fsr[1]))):
if i[1] % num_cols_ext == 0: if i[1] % num_cols_ext == 0:
msg += " " msg += " "
else: else:
...@@ -322,6 +334,12 @@ class Protokollskript: ...@@ -322,6 +334,12 @@ class Protokollskript:
msg += "\\\\\\hline\n" msg += "\\\\\\hline\n"
else: else:
msg += "\n" msg += "\n"
if not len(self.fsr[1])%num_cols_ext == 0:
for i in range(num_cols_ext - len(self.fsr[1])%num_cols_ext):
msg += "& &\n"
msg += "\\\\\\hline\n"
msg += "\\end{tabular}}\\normalsize" msg += "\\end{tabular}}\\normalsize"
msg += f_foot msg += f_foot
......
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