Select Git revision
ModulesTest.php
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}'