Python:Sheet

From wiki
Jump to navigation Jump to search

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

   """
   I am a relevance level
   """
   pageTitle:str
   gid:Optional[str] # the gid of this Sheet
   concept:Optional[str] # the concept this Sheet hold data for
   url:Optional[str] # the base url for the sheet
   @classmethod
   def askQuery(cls):
       """
       get the ask Query for Sheet
       
       Returns:
           str: the mediawiki markup for the ask query
       """

ask="""

pageTitlegidconcepturl
Sheet/Chapter0https://docs.google.com/spreadsheets/d/1nyVE n3XI-qHfVh0o96111d B9vXM7xyu8RMkqJV93E/edit#gid=0
Sheet/Exercise1282894417Exercisehttps://docs.google.com/spreadsheets/d/1nyVE n3XI-qHfVh0o96111d B9vXM7xyu8RMkqJV93E/edit#gid=1282894417
Sheet/LearningGoal307094130LearningGoalhttps://docs.google.com/spreadsheets/d/1nyVE n3XI-qHfVh0o96111d B9vXM7xyu8RMkqJV93E/edit#gid=307094130
Sheet/Presentation1102202836https://docs.google.com/spreadsheets/d/1nyVE n3XI-qHfVh0o96111d B9vXM7xyu8RMkqJV93E/edit#gid=1102202836
Sheet/Publication1841126334Publicationhttps://docs.google.com/spreadsheets/d/1nyVE n3XI-qHfVh0o96111d B9vXM7xyu8RMkqJV93E/edit#gid=1841126334
Sheet/RelevanceLevel1148466902https://docs.google.com/spreadsheets/d/1nyVE n3XI-qHfVh0o96111d B9vXM7xyu8RMkqJV93E/edit#gid=1148466902
Sheet/Task479494308Taskhttps://docs.google.com/spreadsheets/d/1nyVE n3XI-qHfVh0o96111d B9vXM7xyu8RMkqJV93E/edit#gid=479494308

"""

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