officiumdivinum.DSL package¶
Submodules¶
officiumdivinum.DSL.dsl_parser module¶
Parser for a very basic dsl to describe liturgical dates. It has fixed methods:
>>> from officiumdivinum.DSL.dsl_parser import specials
>>> specials["Christmas"](2020)
datetime.date(2020, 12, 25)
>>> specials["Easter"](2020)
datetime.date(2020, 4, 12)
>>> specials["Lent"](2020)
datetime.date(2020, 3, 1)
>>> specials["Septuagesima"](2020)
datetime.date(2020, 2, 9)
>>> specials["Epiphany"](2021)
datetime.date(2021, 1, 6)
It also has a parser to turn expressions into dates. Expressions should evaluate to only one date in any one year.
-
officiumdivinum.DSL.dsl_parser.dsl_parser(datestr: str, year: int) → datetime.date[source]¶ Parse dsl str for a given year.
>>> from officiumdivinum.DSL.dsl_parser import dsl_parser >>> dsl_parser("Easter", 2020) datetime.date(2020, 4, 12)
>>> dsl_parser("1 Jan", 2020) datetime.date(2020, 1, 1)
>>> dsl_parser("Sun between 2 Jan 4 Jan OR 2 Jan", 2016) datetime.date(2016, 1, 3)
>>> dsl_parser("Sun between 2 Jan 4 Jan OR 2 Jan", 2017) datetime.date(2017, 1, 2)
>>> dsl_parser("22nd Sun after Pentecost", 2021) datetime.date(2021, 10, 24)
- Parameters
datestr (str : Expression to be parsed.)
year (int : Year in which to evaluate expression)
- Returns
date – a date in the year in question.
officiumdivinum.DSL.util module¶
-
officiumdivinum.DSL.util.ordinals= ('0th', '1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th', '11th', '12th', '13th', '14th', '15th', '16th', '17th', '18th', '19th', '20th', '21st', '22nd', '23rd', '24th', '25th')¶ These exist largely to map divinumofficium file names onto the right ‘special’ day.