Commit 40881272 authored by Lorenz Steinert's avatar Lorenz Steinert

added some comments

parent a360e3a0
......@@ -33,7 +33,7 @@ def build_parser():
def gen_head(share_dir, reg, sprecher, protokollant, date):
"""generate the head of the protokoll"""
#look for the name.tex and if not found ignore it
if os.path.isfile(os.path.join(share_dir, 'name.tex')):
with codecs.open(os.path.join(share_dir, 'name.tex'),
'r', 'utf-8') as fobj_name:
......@@ -43,6 +43,8 @@ def gen_head(share_dir, reg, sprecher, protokollant, date):
+ " not found. Ignoring")
f_name = ""
#look for the acroname.tex and the acro.tex if one is not found
#ignore both
if (os.path.isfile(os.path.join(share_dir, 'acroname.tex'))
and os.path.isfile(os.path.join(share_dir, 'acro.tex'))):
......@@ -61,6 +63,7 @@ def gen_head(share_dir, reg, sprecher, protokollant, date):
f_acroname = ""
f_acro = ""
#look for teh head.tex and abort if it is not found
if os.path.isfile(os.path.join(share_dir, 'head.tex')):
with codecs.open(os.path.join(share_dir, 'head.tex'),
'r', 'utf-8') as fobj_head:
......@@ -70,6 +73,7 @@ def gen_head(share_dir, reg, sprecher, protokollant, date):
+ " not found. Aborting!")
sys.exit(1)
#Replace the paceholder strings with the files
f_head = reg['FSRN'].sub(f_name, f_head)
f_head = reg['ACRON'].sub(f_acroname, f_head)
f_head = reg['ACRO'].sub(f_acro, f_head)
......@@ -80,7 +84,7 @@ def gen_head(share_dir, reg, sprecher, protokollant, date):
return f_head
def gen_attendance_tab(fsr, num_cols=4, ext=False):
def gen_attendance_tab(fsr, num_cols=5, ext=False):
"""generate the atandance tables"""
fsr_tab, tabdef = '', '||'
for i in range(num_cols):
......@@ -107,6 +111,7 @@ def gen_attendance_tab(fsr, num_cols=4, ext=False):
else:
fsr_tab += "\n"
#add empty cells to padd the last row
if not len(fsr) % num_cols == 0:
for i in range(num_cols - len(fsr) % num_cols):
fsr_tab += "& &\n"
......@@ -123,6 +128,8 @@ def gen_attendance_tab(fsr, num_cols=4, ext=False):
def gen_foot(share_dir, vollversamlung, reg, sprecher, protokollant, date):
"""generate the foot of the protokoll"""
#look for the foot*.tex skripts
# if not found abort
if vollversamlung:
if os.path.isfile(os.path.join(share_dir, 'foot_VV.tex')):
with codecs.open(os.path.join(share_dir, 'foot_VV.tex'),
......@@ -142,6 +149,7 @@ def gen_foot(share_dir, vollversamlung, reg, sprecher, protokollant, date):
+ " not found. Aborting")
sys.exit(1)
#replace the placeholder strings in f_foot
f_foot = reg['SPR'].sub(sprecher, f_foot)
f_foot = reg['PRO'].sub(protokollant, f_foot)
f_foot = reg['DATE'].sub(date[0], f_foot)
......@@ -170,8 +178,7 @@ if __name__ == "__main__":
NUM_COLS = 5
NUM_COLS_EXT = 5
TABDEF = "||"
#Set the timeout to 1 if we just want to test stuff
if OPT.test:
ESME = FsrLdap(OPT.debug,
timeout=1)
......@@ -182,18 +189,22 @@ if __name__ == "__main__":
print("\n")
print("Wenn der Standardwert (in []) stimmt einfach Enter!\n")
# get data form user
if CONFIG:
SPRECHER = get_sprecher(CONFIG['DEFAULT']['Sprecher'])
PROTOKOLLANT = ESME.get_protokollant_ldap(CONFIG['DEFAULT']['Protokollant'])
else:
SPRECHER = get_sprecher('')
PROTOKOLLANT = ESME.get_protokollant_ldap('')
DATE = get_date(OPT.test)
#Fetch the FSR from the Server
#and if not able to connect fall back to the textfiles
FSR = [ESME.get_fsr_ldap(SHARE_DIR),
ESME.get_fsr_extern_ldap(SHARE_DIR)]
#Generate the Path for the Protokoll in depandance of OPT.VV
#and make the directory
if OPT.Vollversamlung:
OUTDIR = os.path.join(get_path(RUNDIR, CONFIG, OPT.path), DATE[1],
"fsr_physik_vollversamlung_" + '-'.join(DATE[1:]))
......@@ -203,6 +214,7 @@ if __name__ == "__main__":
if not os.path.exists(OUTDIR):
os.makedirs(OUTDIR)
#Generate the path of the .tex file
OUTFILE = os.path.join(OUTDIR, "fsr_physik_protokoll_"
+ '-'.join(DATE[1:]) + ".tex")
......
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