Skip to content
Snippets Groups Projects
Select Git revision
  • b785db86a8c5ed58fec47dcc24dedf0d34eb2a26
  • 3.9 default
  • develop
  • 6.0
  • 5.0
  • 4.0
  • scrutinizer-patch-4
  • scrutinizer-patch-3
  • scrutinizer-patch-2
  • scrutinizer-patch-1
  • 3.7
  • 3.8
  • 3.6
  • 3.9_backported
  • 3.8_backported
  • 3.7_backported
  • 3.5
  • 3.6_backported
  • 3.5_backported
  • 3.4
  • 3.3_backported
  • 6.0.4
  • 6.0.3
  • 5.0.7
  • 6.0.2
  • 6.0.1
  • 5.0.6
  • 6.0.0
  • 5.0.5
  • 6.0.0-rc
  • 5.0.4
  • 6.0.0-beta
  • 5.0.3
  • 4.0.6
  • 5.0.2
  • 5.0.1
  • 4.0.5
  • 5.0.0
  • 4.0.4
  • 5.0.0-rc2
  • 5.0.0-rc1
41 results

ModulesTest.php

Blame
  • common_functions.py 872 B
    import datetime
    from typing import List, Optional, TypeVar
    
    ChoiceType = TypeVar("ChoiceType")
    
    
    def select_from_list(choices: List[ChoiceType], choice_name: str) -> ChoiceType:
        print(f'Choose the {choice_name} from this list:')
        for i in range(len(choices)):
            print(f'{i+1})\t{choices[i]}'.expandtabs(4))
        selection = input('Enter selection: ')
        return choices[int(selection) - 1]
    
    
    def strip_html(text: Optional[str]) -> Optional[str]:
        import re
        if text is not None:
            return re.sub(re.compile('<.*?>'), '', text)
        else:
            return None
    
    def semester_stamp() -> str:
        today = datetime.date.today()
        year: int = today.year
        month: int = today.month
        # Normalize month to semester start
        if month < 5:
            month = 1
        elif month < 8:
            month = 5
        else:
            month = 8
        return f'{year}-0{month}'