def quarter_from(text): estimated = text.endswith('(E)') text = text[:-3] if estimated else text comp = text.split('/') return Quarter(year=int(comp[0]), number=int(int(comp[1]) / 3), estimated=estimated)
def quarter_from(text: str) -> Quarter: if (not text) or ('/' not in text): return None estimated = text.endswith('(E)') text = text[:-3] if estimated else text comp = text.split('/') return Quarter(year=int(comp[0]), number=int(int(comp[1]) / 3), estimated=estimated)