Sometimes the dict returned by the library doesn't have a colourcode key. The following code gives all of the dates for 2024.
from datetime import date
from dateutil.rrule import rrule, DAILY
from liturgical_colour.liturgical import liturgical_colour
start = date(2024,1,1)
end = date(2024,12,31)
colourfreqs = {}
for dt in rrule(DAILY, dtstart=start, until=end):
cdt = liturgical_colour(dt)
try:
if cdt['colourcode'] in colourfreqs:
colourfreqs[cdt['colourcode']] +=1
else:
colourfreqs[cdt['colourcode']] = 1
except KeyError:
print(cdt)
Sometimes the dict returned by the library doesn't have a colourcode key. The following code gives all of the dates for 2024.
which gives the following output: