def _calculate_proper( self, observances: List[Observance]) -> List[Tuple['Proper', 'Proper']]: """ Accommodate propers for given observance to the current calendar day. For example: * In paschal time show paschal gradual instead of regular gradual * In Lent show tractus instead of gradual * In feria days, when the proper from the last sunday is used, adjust day's class, remove "alleluja", etc. * In Sundays after Epiphany moved to the period after Pentecost adjust the sections accordingly * Show proper prefatio * etc. """ if observances and all([i.has_proper() for i in observances]): retval: List[Tuple[Proper, Proper]] = [] for observance in observances: inter_readings_section = self._infer_inter_reading_section( observance) preface = get_custom_preface(observance, next(iter(self.tempora), None)) proper_config = ProperConfig( preface=preface, inter_readings_section=inter_readings_section) retval.append(observance.get_proper(proper_config)) return retval else: # It's a feria day without its own proper for which the last Sunday's proper is used inferred_observances = self._infer_observance() if observances: rank: int = observances[0].rank preface: str = get_custom_preface(observances[0]) else: rank: int = 4 preface: str = get_custom_preface(inferred_observances) preface = preface if preface is not None else PREFATIO_COMMUNIS config: ProperConfig = ProperConfig(preface=preface, strip_alleluia=True, strip_tract=True) propers: Tuple[Proper, Proper] = inferred_observances.get_proper(config) for proper in propers: proper.rank = rank return [propers]
def __init__(self, proper_id: str, lang: str, config: ProperConfig = None): self.proper_id: str = proper_id self.lang = lang self.config = config or ProperConfig()
def get_proper_by_id(proper_id: str, lang: str) -> Tuple[Proper, Proper]: config: ProperConfig = ProperConfig( preface=get_custom_preface(Proper(proper_id, lang))) return ProperParser(proper_id, lang, config).parse()
def test_correct_preface_calculated_by_proper_id(proper_id, preface_name, preface_body): _, proper_latin = ProperParser(proper_id, language, ProperConfig(preface=preface_name)).parse() assert preface_body == proper_latin.get_section(PREFATIO).get_body()[0]