Skip to main content

Provides an API for scraping the web page from https://bible.usccb.org/bible/readings/ to get the readings

Project description

catholic-mass-readings

CI Build PyPI Version versions

Provides an API for scraping the web page from Daily Readings website of United States Conference of Catholic Bishops.

Development

Setup Python Environment:

Run scripts/console.sh poetry install

If you need to relock:

Run scripts/lock.sh

Run code

Run scripts/console.sh poetry run catholic_mass_readings

API Usage:

import asyncio
import datetime

from catholic_mass_readings import USCCB

# To get a mass for a particular date:
async with USCCB() as usccb:
    mass = await usccb.get_mass_from_date(datetime.date(2024, 12, 25))
    print(mass.dumps())

# To query for a range of Sunday masses:
async with USCCB() as usccb:
    masses: list[models.Mass] = []
    dates = usccb.get_sunday_mass_dates(datetime.date(2024, 12, 25), datetime.date(2024, 1, 25))
    for task in asyncio.as_completed([usccb.get_mass_from_date(dt) for dt in dates]):
        mass = await task
        if mass:
            print(mass.dumps())

    masses.sort(key=lambda m: m.date.toordinal() if m.date else -1)
    print(mass.dumps())

# To query for a range of masses (step how you want to):
async with USCCB() as usccb:
    masses: list[models.Mass] = []
    dates = usccb.get_mass_dates(datetime.date(2024, 12, 25), datetime.date(2024, 1, 25), step=datetime.timedelta(days=1))
    for task in asyncio.as_completed([usccb.get_mass_from_date(dt) for dt in dates]):
        mass = await task
        if mass:
            print(mass.dumps())

    masses.sort(key=lambda m: m.date.toordinal() if m.date else -1)
    print(mass.dumps())

As a CLI

# To get a mass for a particular date:
python -m catholic_mass_readings get-mass --date 2024-12-25

# To query for a range of Sunday masses:
python -m catholic_mass_readings get-sunday-mass-range --start 2024-12-25 --end 2025-01-01

# To query for a range of masses (step how you want to):
python -m catholic_mass_readings get-mass-range --start 2024-12-25 --end 2025-01-01 --step 7

...Or saving to a file

# To get a mass for a particular date:
python -m catholic_mass_readings get-mass --date 2024-12-25 --save mass.json

# To query for a range of Sunday masses:
python -m catholic_mass_readings get-sunday-mass-range --start 2024-12-25 --end 2025-01-01 --save mass.json

# To query for a range of masses (step how you want to):
python -m catholic_mass_readings get-mass-range --start 2024-12-25 --end 2025-01-01 --step 7 --save mass.json

Installation

To install catholic-mass-readings from PyPI, use the following command:

$ pip install catholic-mass-readings

You can also clone the repo and run the following command in the project root to install the source code as editable:

$ pip install -e .

Documentation

The documentation for catholic-mass-readings can be found here or in the project's docstrings.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

catholic_mass_readings-0.2.1.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

catholic_mass_readings-0.2.1-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file catholic_mass_readings-0.2.1.tar.gz.

File metadata

  • Download URL: catholic_mass_readings-0.2.1.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.9.20 Linux/6.8.0-1017-azure

File hashes

Hashes for catholic_mass_readings-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a823556d2ab1b9775249a590dda6ff60e7c66ff0b704c2d025b89a675d66d903
MD5 d3a179df9ca29b6f77f70730abcb5894
BLAKE2b-256 3ab0fe9fdabef4c5aef5ca15290f77100284e72bf1030ca7fee2a7e1ca63485b

See more details on using hashes here.

File details

Details for the file catholic_mass_readings-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for catholic_mass_readings-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b430012f7ce69e77fd9c381647b87c7f2e052c9689c63e88c12f7f9e4ddf5568
MD5 0c876cf8d99041393485f8fa3088bedb
BLAKE2b-256 7cfd2cfa0080e0498bbfb4ed770a6f7145d8cdd4c60a0ca686c008dce446f786

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page