Python:Chapter

From wiki
Jump to navigation Jump to search

from dataclasses import dataclass from typing import Optional import dacite @dataclass class Chapter:

   """
   a chapter of a lecture
   """
   pageTitle:str
   key:Optional[str] # The key of the presentation for this Chapter 
   no:Optional[str] # The number of the Chapter 
   pres_id:Optional[str] # The numeric id of the presentation for the Chapter 
   week:Optional[str] # The relative week of the Chapter 
   de:Optional[str] # Das Thema des Kapitels in deutsch
   en:Optional[str] # The topic of the chapter in english
   @classmethod
   def askQuery(cls):
       """
       get the ask Query for Chapter
       
       Returns:
           str: the mediawiki markup for the ask query
       """

ask="""

pageTitlekeynopres_idweekdeen
Chapter/1Orga101OrganisationOrganization
Chapter/3ERM322Entity-Relationship (erste Hälfte)Entity-Relationship (first half)
Chapter/4ERM423Entity-Relationship (zweite Hälfte)Entity-Relationship (second half)
Chapter/8SQL847SQL (Änderungsoperationen der Data Manipulation Language)SQL (Change operations of the Data Manipulation Language)
Chapter/9RelQuery958AnfragebearbeitungQuery processing
Chapter/10RelQuery1059DB Algorithmen und IndexstrukturenDB Algorithms and Index Structures
Chapter/11RelDesign11610Funktionale Abhängigkeiten & Armstrong KalkülFunctional Dependencies & Armstrong Calculus
Chapter/12RelDesign12611Zerlegungen und NormalformenDecompositions and Normal Forms
Chapter/14AltDM14713AltDM Teil 2AltDM Part 2
Chapter/16TM16815Transaktionsverwaltung (Teil 1)Transaction Management (Part 1)
Chapter/17TM17816Transaktionsverwaltung (Teil 2)Transaction Management (Part 2)

"""

       return ask
       
   @classmethod
   def fromDict(cls,data:dict):
       """
       create a Chapter from the given dict
       
       Args:
           data(dict): the dict to create the Chapter from
       
       Returns:
           Chapter: the freshly created Chapter
       """
       chapter=dacite.from_dict(data_class=cls,data=data)
       return chapter