Commit 8fe9875a authored by Lorenz Steinert's avatar Lorenz Steinert

fixed some bugs and ignore name.tex, acroname.tex and acro.tex if they dont exist

parent 24a6ba51
......@@ -33,21 +33,40 @@ def build_parser():
def gen_head(share_dir, reg, sprecher, protokollant, date):
"""generate the head of the protokoll"""
with codecs.open(os.path.join(share_dir, 'name.tex'),
'r', 'utf-8') as fobj_name:
f_name = fobj_name.read()
with codecs.open(os.path.join(share_dir, 'acroname.tex'),
'r', 'utf-8') as fobj_acroname:
f_acroname = fobj_acroname.read()
with codecs.open(os.path.join(share_dir, 'acro.tex'),
'r', 'utf-8') as fobj_acro:
f_acro = fobj_acro.read()
with codecs.open(os.path.join(share_dir, 'head.tex'),
'r', 'utf-8') as fobj_head:
f_head = fobj_head.read()
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:
f_name = fobj_name.read()
else:
print(os.path.abspath(os.path.join(share_dir, 'name.tex')
+ " not found. Ignoring"))
f_name = ""
if (os.path.isfile(os.path.join(share_dir, 'acroname.tex'))
and os.path.isfile(os.path.join(share_dir, 'acro.tex'))):
with codecs.open(os.path.join(share_dir, 'acroname.tex'),
'r', 'utf-8') as fobj_acroname:
f_acroname = fobj_acroname.read()
with codecs.open(os.path.join(share_dir, 'acro.tex'),
'r', 'utf-8') as fobj_acro:
f_acro = fobj_acro.read()
else:
print(os.path.abspath(os.path.join(share_dir, 'acroname.tex')
+ " or "
+ os.path.abspath(os.path.join(share_dir, 'acro.tex'))
+ " not found. Ignoring"))
f_acroname = ""
f_acro = ""
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:
f_head = fobj_head.read()
else:
print(os.path.abspath(os.path.join(share_dir, 'head.tex'))
+ " not found. Aborting!")
sys.exit(1)
f_head = reg['FSRN'].sub(f_name, f_head)
f_head = reg['ACRON'].sub(f_acroname, f_head)
......@@ -103,13 +122,23 @@ 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"""
if vollversamlung:
with codecs.open(os.path.join(share_dir, 'foot_VV.tex'),
'r', 'utf-8') as fobj_foot:
f_foot = fobj_foot.read()
if os.path.isfile(os.path.join(share_dir, 'foot_VV.tex')):
with codecs.open(os.path.join(share_dir, 'foot_VV.tex'),
'r', 'utf-8') as fobj_foot:
f_foot = fobj_foot.read()
else:
print(os.path.abspath(os.path.join(share_dir, 'foot_VV.tex'))
+ " not found. Aborting")
sys.exit(1)
else:
with codecs.open(os.path.join(share_dir, 'foot.tex'),
'r', 'utf-8') as fobj_foot:
f_foot = fobj_foot.read()
if os.path.isfile(os.path.join(share_dir, 'foot.tex')):
with codecs.open(os.path.join(share_dir, 'foot.tex'),
'r', 'utf-8') as fobj_foot:
f_foot = fobj_foot.read()
else:
print(os.path.abspath(os.path.join(share_dir, 'foot.tex'))
+ " not found. Aborting")
sys.exit(1)
f_foot = reg['SPR'].sub(sprecher, f_foot)
f_foot = reg['PRO'].sub(protokollant, f_foot)
......@@ -155,7 +184,8 @@ if __name__ == "__main__":
FSR = [ESME.get_fsr_ldap(SHARE_DIR),
ESME.get_fsr_extern_ldap(SHARE_DIR)]
OUTDIR = get_path(RUNDIR, CONFIG, OPT.path)
OUTDIR = os.path.join(get_path(RUNDIR, CONFIG, OPT.path), DATE[1],
"fsr_physik_sitzung_" + '-'.join(DATE[1:]))
if not os.path.exists(OUTDIR):
os.makedirs(OUTDIR)
......@@ -173,7 +203,7 @@ if __name__ == "__main__":
msg += gen_attendance_tab(FSR[0], NUM_COLS)
msg += gen_attendance_tab(FSR[1], NUM_COLS_EXT, ext=True)
msg += gen_foot(SHARE_DIR, REG, OPT.Vollversamlung,
msg += gen_foot(SHARE_DIR, OPT.Vollversamlung, REG,
SPRECHER, PROTOKOLLANT, DATE)
with codecs.open(OUTFILE, 'w', 'utf-8') as fobj_out:
......
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