def semestergruppe(self, tup, buffer): """@result: [ (semestergruppe, gruppenKuerzel, fach, dozent, raum, jahr, woche, wochentag, anfang, ende, infoString), (eintrag-Tupel), ... ] """ subTree = multiMap(tup[-1], buffer=buffer) infoString, jahr, semestergruppe = dispatchList( self, subTree['header'], buffer)[0] result = [] if "sections" in subTree: eintraege = dispatchList(self, subTree['sections'], buffer)[0] if semestergruppe == None: semestergruppe = self._derive_gruppenkuerzel(eintraege) for e in eintraege: gruppenKuerzel, fach, dozent, raum, woche, wochentag, anfang, ende = e result.append( (semestergruppe, gruppenKuerzel, fach, dozent, raum, jahr, woche, wochentag, anfang, ende, infoString)) return result
def wochenRange(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) anfangsWoche = dispatchList(self, subTree['anfangsWoche'], buffer)[0] endWoche = dispatchList(self, subTree['endWoche'], buffer)[0] return map(lambda x: str(x), range( int(anfangsWoche), int(endWoche) + 1))
def semestergruppe(self, tup, buffer): """@result: [ (semestergruppe, gruppenKuerzel, fach, dozent, raum, jahr, woche, wochentag, anfang, ende, infoString), (eintrag-Tupel), ... ] """ subTree = multiMap(tup[-1], buffer=buffer) infoString, jahr, semestergruppe = dispatchList(self, subTree["header"], buffer)[0] result = [] if "sections" in subTree: eintraege = dispatchList(self, subTree["sections"], buffer)[0] for e in eintraege: gruppenKuerzel, fach, dozent, raum, woche, wochentag, anfang, ende = e result.append( ( semestergruppe, gruppenKuerzel, fach, dozent, raum, jahr, woche, wochentag, anfang, ende, infoString, ) ) return result
def eintrag(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) if 'sixtupel' in subTree: result = dispatchList(self, subTree['sixtupel'], buffer)[0] else: result = dispatchList(self, subTree['septupel'], buffer)[0] return result
def wahlpflichtmodul(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) alphanumGruppe = dispatchList(self, subTree['alphanumGruppe'], buffer)[0] no = dispatchList(self, subTree['no'], buffer)[0] return wahlpflichtmodul2FullName(alphanumGruppe, no)
def teamStudienEinstieg(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) gruppe = "" if "gruppe" in subTree: gruppe = dispatchList(self, subTree['gruppe'], buffer)[0] return veranstaltung2FullName("TSE", gruppe=gruppe)
def wpPraktikum(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) alphanumGruppe = dispatchList(self, subTree['alphanumGruppe'], buffer)[0] no = dispatchList(self, subTree['no'], buffer)[0] gruppe = dispatchList(self, subTree['gruppe'], buffer)[0] return wpPraktikum2FullName(alphanumGruppe, no, gruppe)
def wocheOrWochenRange(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) wochen = [] if 'woche' in subTree: wochen = dispatchList(self, subTree['woche'], buffer) if 'wochenRange' in subTree: wochen = dispatchList(self, subTree['wochenRange'], buffer)[0] return wochen
def header(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) infoString, jahr = dispatchList(self,subTree['ersteZeile'], buffer)[0] gruppenKuerzel = '' if 'zweiteZeile' in subTree: gruppenKuerzel = dispatchList(self,subTree['zweiteZeile'], buffer)[0] else: gruppenKuerzel = None return (infoString, jahr, gruppenKuerzel)
def sixtupel(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) gruppenKuerzel, fach = dispatchList(self, subTree['fach'], buffer)[0] dozent = dispatchList(self, subTree['dozent'], buffer)[0] raum = dispatchList(self, subTree['raum'], buffer)[0] wochentag = dispatchList(self, subTree['wochentag'], buffer)[0] anfang = dispatchList(self, subTree['anfang'], buffer)[0] ende = dispatchList(self, subTree['ende'], buffer)[0] return (gruppenKuerzel, fach, dozent, raum, wochentag, anfang, ende)
def sixtupel(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) gruppenKuerzel, fach = dispatchList(self, subTree["fach"], buffer)[0] dozent = dispatchList(self, subTree["dozent"], buffer)[0] raum = dispatchList(self, subTree["raum"], buffer)[0] wochentag = dispatchList(self, subTree["wochentag"], buffer)[0] anfang = dispatchList(self, subTree["anfang"], buffer)[0] ende = dispatchList(self, subTree["ende"], buffer)[0] return (gruppenKuerzel, fach, dozent, raum, wochentag, anfang, ende)
def header(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) infoString, jahr = dispatchList(self, subTree['ersteZeile'], buffer)[0] gruppenKuerzel = '' if 'zweiteZeile' in subTree: gruppenKuerzel = dispatchList(self, subTree['zweiteZeile'], buffer)[0] else: gruppenKuerzel = None return (infoString, jahr, gruppenKuerzel)
def vorlUebung(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) fachKuerzel = dispatchList(self, subTree['fachKuerzel'], buffer)[0] nummer = "" if "nummer" in subTree: nummer = dispatchList(self, subTree['nummer'], buffer)[0] return veranstaltung2FullName(fachKuerzel, "Vorl./Übung", nummer)
def section(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) wochen = dispatchList(self,subTree['wochen'], buffer)[0] eintraege = dispatchList(self,subTree['eintrag'], buffer) eintraegeMitWoche = [] for woche in wochen: for e in eintraege: gruppenKuerzel, fach, dozent, raum, wochentag, anfang, ende = e eintraegeMitWoche.append((gruppenKuerzel, fach, dozent, raum, woche, wochentag, anfang, ende)) return eintraegeMitWoche
def tutorium(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) fachKuerzel = dispatchList(self, subTree['fachKuerzel'], buffer)[0] nummer = "" if "nummer" in subTree: nummer = dispatchList(self, subTree['nummer'], buffer)[0] return veranstaltung2FullName(fachKuerzel, "Tutorium", nummer=nummer)
def awSeminar(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) fachKuerzel = "AW" nummer = "" if "nummer" in subTree: nummer = dispatchList(self, subTree['nummer'], buffer)[0] return veranstaltung2FullName(fachKuerzel, "Seminar", nummer)
def section(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) wochen = dispatchList(self, subTree['wochen'], buffer)[0] eintraege = dispatchList(self, subTree['eintrag'], buffer) eintraegeMitWoche = [] for woche in wochen: for e in eintraege: gruppenKuerzel, fach, dozent, raum, wochentag, anfang, ende = e eintraegeMitWoche.append((gruppenKuerzel, fach, dozent, raum, woche, wochentag, anfang, ende)) return eintraegeMitWoche
def uebung(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) fachKuerzel = dispatchList(self, subTree['fachKuerzel'], buffer)[0] nummer = "" if "no" in subTree: nummer = dispatchList(self, subTree['no'], buffer)[0] gruppe = dispatchList(self, subTree['gruppe'], buffer)[0] return veranstaltung2FullName(fachKuerzel, "Übung", nummer, gruppe)
def projekt(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) gruppe = "" if "gruppe" in subTree: gruppe = dispatchList(self, subTree['gruppe'], buffer)[0] nummer = "" if "nummer" in subTree: nummer = dispatchList(self, subTree['nummer'], buffer)[0] return veranstaltung2FullName("PJ", nummer=nummer, gruppe=gruppe)
def orientierungseinheit(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) roemNr = "" if "oe1" in subTree: roemNr = dispatchList(self, subTree["oe1"], buffer)[0] elif "oe2" in subTree: roemNr = dispatchList(self, subTree["oe2"], buffer)[0] else: # raise Exception("wrong control flow! Veranstaltungskuerzel = " + buffer) roemNr = "" #FIXME: just a workaround return orientierungseinheit2FullName(roemNr)
def labor(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) labKuerzel = dispatchList(self, subTree['labKuerzel'], buffer)[0] #remove the trailing 'L' fachKuerzel = labKuerzel[0:len(labKuerzel)-1] nummer = "" if "no" in subTree: nummer = dispatchList(self, subTree['no'], buffer)[0] gruppe = "" if "gruppe" in subTree: gruppe = dispatchList(self, subTree['gruppe'], buffer)[0] return veranstaltung2FullName(fachKuerzel, "Labor", nummer, gruppe)
def praktikum(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) prakKuerzel = dispatchList(self, subTree['prakKuerzel'], buffer)[0] #remove the trailing 'P' fachKuerzel = prakKuerzel[0:len(prakKuerzel)-1] nummer = "" if "no" in subTree: nummer = dispatchList(self, subTree['no'], buffer)[0] gruppe = "" if "gruppe" in subTree: gruppe = dispatchList(self, subTree['gruppe'], buffer)[0] return veranstaltung2FullName(fachKuerzel, "Praktikum", nummer, gruppe)
def veranstaltung(self, tup, buffer): """@return: String - full event name """ subTree = multiMap(tup[-1], buffer=buffer) def get(veranstaltung): return dispatchList(self, subTree[veranstaltung], buffer)[0] if "awSeminar" in subTree: result = get("awSeminar") elif "gwKurs" in subTree: result = get("gwKurs") elif "labor" in subTree: result = get("labor") elif "orientierungseinheit" in subTree: result = get("orientierungseinheit") elif "praktikum" in subTree: result = get("praktikum") elif "projekt" in subTree: result = get("projekt") elif "seminar" in subTree: result = get("seminar") elif "teamStudienEinstieg" in subTree: result = get("teamStudienEinstieg") elif "tutorium" in subTree: result = get("tutorium") elif "uebung" in subTree: result = get("uebung") elif "verbundprojekt" in subTree: result = get("verbundprojekt") elif "vorlesung" in subTree: result = get("vorlesung") elif "vorkurs" in subTree: result = get("vorkurs") elif "vorlUebung" in subTree: result = get("vorlUebung") elif "wahlpflichtmodul" in subTree: result = get("wahlpflichtmodul") elif "wpPraktikum" in subTree: result = get("wpPraktikum") elif "unknown" in subTree: logging.warning("veranstaltungenParser could not parse this: " + buffer) result = buffer # no mappings found else: raise Exception("wrong control flow! Veranstaltungskuerzel = " + buffer) return result
def verbundprojekt(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) verbKuerzel = dispatchList(self, subTree['verbKuerzel'], buffer)[0] #remove the trailing 'J' fachKuerzel = verbKuerzel[0:len(verbKuerzel)-1] no = "" if "no" in subTree: no = dispatchList(self, subTree['no'], buffer)[0] gruppe = "" if "gruppe" in subTree: gruppe = dispatchList(self, subTree['gruppe'], buffer)[0] fullName = veranstaltung2FullName(fachKuerzel, "Verbundprojekt", no, gruppe) return fullName.replace("Verbundprojekt Verbundprojekt", "Verbundprojekt")
def semestergruppe(self,tup,buffer): """@result: [ (semestergruppe, gruppenKuerzel, fach, dozent, raum, jahr, woche, wochentag, anfang, ende, infoString, version), (eintrag-Tupel), ... ] """ subTree = multiMap(tup[-1],buffer=buffer) infoString, version, semester, jahr, semestergruppe = dispatchList(self,subTree['header'], buffer)[0] result = [] if "sections" in subTree: eintraege = dispatchList(self,subTree['sections'], buffer)[0] if semestergruppe == None: semestergruppe = self._derive_gruppenkuerzel(eintraege) for e in eintraege: gruppenKuerzel, fach, dozent, raum, woche, wochentag, anfang, ende = e result.append((semestergruppe, gruppenKuerzel, fach, dozent, raum, jahr, woche, wochentag, anfang, ende, infoString, version, semester)) return result
def ersteZeile(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) infoString, jahr = dispatchList(self, subTree['infoString'], buffer)[0] return (infoString, jahr)
def infoString(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) jahr = dispatchList(self, subTree['semester'], buffer)[0] infoString = str(getString(tup, buffer)) return (infoString, jahr)
def ende(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) h, m = dispatchList(self, subTree['uhrzeit'], buffer)[0] return (h, m)
def uhrzeit(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) h = dispatchList(self, subTree['h'], buffer)[0] m = dispatchList(self, subTree['m'], buffer)[0] return (h, m)
def sections(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) eintraegeList = dispatchList(self, subTree['section'], buffer) eintraege = reduce(lambda x, y: x + y, eintraegeList) return eintraege
def endWoche(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) endWoche = dispatchList(self, subTree['woche'], buffer)[0] return endWoche
def semester(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) jahr = dispatchList(self, subTree['jahr'], buffer)[0] return jahr
def zweiteZeile(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) gruppenKuerzel = dispatchList(self, subTree['gruppenKuerzel'], buffer)[0] return gruppenKuerzel
def gwKurs(self, tup, buffer): subTree = multiMap(tup[-1],buffer=buffer) gwKuerzel = dispatchList(self, subTree['gwKuerzel'], buffer)[0] return gwKurs2FullName(gwKuerzel)
def fach(self, tup, buffer): subTree = multiMap(tup[-1], buffer=buffer) gruppenKuerzel = dispatchList(self, subTree['gruppe'], buffer)[0] fach = str(getString(tup, buffer)) return gruppenKuerzel, fach
def parameter_list(self, (tag, start, stop, subtags), buffer): """ Process C{simple_content} production. """ return dp.getString((tag, start, stop, subtags), buffer) def instance_list(self, (tag, start, stop, subtags), buffer): """ Process C{complex_content} production. @return: a 2-tuple of (keywords, parameter lists), where keywords is the list of KEYWORD occurrences and parameter lists is a list of strings (each of which is an unparsed parameter list). """ inst = dp.multiMap((tag, start, stop, subtags), buffer) return inst.get("KEYWORD"), inst.get("parameter_list") def simple_instance(self, (tag, start, stop, subtags), buffer): """ Process C{simple_instance} production. """ inst = dp.singleMap(subtags, self, buffer) iname = int(inst.get("ENTITY_INSTANCE_NAME")) self.res["contents"][iname] = inst.get("parameter_list") self.res["insttype"][iname] = inst.get("KEYWORD") self.res["typeinst"][inst.get("KEYWORD")].append(iname) def complex_instance(self, (tag, start, stop, subtags), buffer): """ Process C{complex_instance} production.
def parameter_list(self, (tag, start, stop, subtags), buffer): """ Process C{simple_content} production. """ return dp.getString((tag, start, stop, subtags), buffer) def instance_list(self, (tag, start, stop, subtags), buffer): """ Process C{complex_content} production. @return: a 2-tuple of (keywords, parameter lists), where keywords is the list of KEYWORD occurrences and parameter lists is a list of strings (each of which is an unparsed parameter list). """ inst = dp.multiMap((tag, start, stop, subtags), buffer) return inst.get('KEYWORD'), inst.get('parameter_list') def simple_instance(self, (tag, start, stop, subtags), buffer): """ Process C{simple_instance} production. """ inst = dp.singleMap(subtags, self, buffer) iname = int(inst.get('ENTITY_INSTANCE_NAME')) self.res['contents'][iname] = inst.get('parameter_list') self.res['insttype'][iname] = inst.get('KEYWORD') self.res['typeinst'][inst.get('KEYWORD')].append(iname) def complex_instance(self, (tag, start, stop, subtags), buffer): """ Process C{complex_instance} production.