111 lines
3.0 KiB
Python
Raw Normal View History

2016-10-11 19:01:39 +02:00
# coding: utf-8
# sehr einfache Erzeugung des Markups für vollständige Seiten
# jeweils 3 Abschnitte:
# - begin
# - content
# - end
# bei der Liste wird der content-Abschnitt wiederholt
# beim Formular nicht
import codecs
import os.path
import string
#----------------------------------------------------------
class View_cl(object):
#----------------------------------------------------------
#-------------------------------------------------------
def __init__(self):
#-------------------------------------------------------
pass
#-------------------------------------------------------
2016-10-21 12:54:01 +02:00
def createList_px(self, data_opl, form=None):
2016-10-11 19:01:39 +02:00
#-------------------------------------------------------
# hier müsste noch eine Fehlerbehandlung ergänzt werden !
2016-10-21 12:54:01 +02:00
print("CreateList: ", form)
2016-10-11 19:01:39 +02:00
markup_s = ''
2016-10-21 12:54:01 +02:00
if (form == "0" or form == None):
markup_s += self.readFile_p('list0.tpl')
markupV_s = self.readFile_p('list1.tpl')
lineT_o = string.Template(markupV_s)
for loop_i in range(0,15):
data_a = data_opl[str(loop_i)]
markup_s += lineT_o.safe_substitute (name1_s=data_a[0]
, vorname1_s=data_a[1]
, matrnr1_s=data_a[2]
, semesteranzahl1_s=data_a[3]
, name2_s=data_a[4]
, vorname2_s=data_a[5]
, matrnr2_s=data_a[6]
, semesteranzahl2_s=data_a[7]
, id_s=str(loop_i)
)
markup_s += self.readFile_p('list2.tpl')
return markup_s
elif(form == "1"):
markup_s += self.readFile_p('listaufz0.tpl')
markupV_s = self.readFile_p('listaufz1.tpl')
lineT_o = string.Template(markupV_s)
2016-10-11 19:01:39 +02:00
2016-10-21 12:54:01 +02:00
# mehrfach nutzen, um die einzelnen Zeilen der Tabelle zu erzeugen
for loop_i in range(0,15):
data_a = data_opl[str(loop_i)]
markup_s += lineT_o.safe_substitute (name1_s=data_a[0]
, vorname1_s=data_a[1]
, matrnr1_s=data_a[2]
, semesteranzahl1_s=data_a[3]
, name2_s=data_a[4]
, vorname2_s=data_a[5]
, matrnr2_s=data_a[6]
, semesteranzahl2_s=data_a[7]
, id_s=str(loop_i)
)
markup_s += self.readFile_p('listaufz2.tpl')
return markup_s
2016-10-17 18:04:28 +02:00
2016-10-11 19:01:39 +02:00
#-------------------------------------------------------
2016-10-21 12:54:01 +02:00
def createForm_px(self, id_spl, data_opl, form):
2016-10-11 19:01:39 +02:00
#-------------------------------------------------------
# hier müsste noch eine Fehlerbehandlung ergänzt werden !
markup_s = ''
markup_s += self.readFile_p('form0.tpl')
markupV_s = self.readFile_p('form1.tpl')
2016-10-21 12:54:01 +02:00
markupV_s += self.readFile_p('form2.tpl')
2016-10-11 19:01:39 +02:00
lineT_o = string.Template(markupV_s)
2016-10-17 18:04:28 +02:00
markup_s += lineT_o.safe_substitute (name1_s=data_opl[0]
2016-10-11 19:01:39 +02:00
, vorname1_s=data_opl[1]
, matrnr1_s=data_opl[2]
2016-10-17 18:04:28 +02:00
, semesteranzahl1_s=data_opl[3]
, name2_s=data_opl[4]
, vorname2_s=data_opl[5]
, matrnr2_s=data_opl[6]
, semesteranzahl2_s=data_opl[7]
2016-10-11 19:01:39 +02:00
, id_s=id_spl
2016-10-21 12:54:01 +02:00
, form_s=form
2016-10-11 19:01:39 +02:00
)
2016-10-21 12:54:01 +02:00
2016-10-11 19:01:39 +02:00
return markup_s
#-------------------------------------------------------
def readFile_p(self, fileName_spl):
#-------------------------------------------------------
content_s = ''
with codecs.open(os.path.join('template', fileName_spl), 'r', 'utf-8') as fp_o:
content_s = fp_o.read()
return content_s
# EOF