sabbath_school_reproducer package

Subpackages

Submodules

sabbath_school_reproducer.aggregator module

Content Aggregator Module for Sabbath School Lessons

This module combines downloaded content into a single markdown file.

class sabbath_school_reproducer.aggregator.ContentAggregator[source]

Bases: object

Combines downloaded lesson content into a single markdown file.

static combine_lesson_content(lesson_data, output_path)[source]

Combine all lesson content into a single markdown file

Parameters:
  • lesson_data (dict) – Dictionary containing all downloaded content

  • output_path (str) – Path to save the combined markdown file

Returns:

Path to the combined markdown file

Return type:

str

static create_file_section(filename, content)[source]

Format content as a file section with header

Parameters:
  • filename (str) – Name of the file section

  • content (str) – Content to include in the section

Returns:

Formatted section with header

Return type:

str

sabbath_school_reproducer.config module

Configuration Module for Sabbath School Lessons

This module handles loading and validating configuration from a YAML file.

class sabbath_school_reproducer.config.Config(config_path)[source]

Bases: object

Handles configuration loading and validation for Sabbath School lessons.

get(key, default=None)[source]

Get a config value with a default

get_github_paths()[source]

Generate GitHub repository paths based on configuration

Returns:

Dictionary with GitHub paths

Return type:

dict

load_config()[source]

Load configuration from YAML file

Returns:

Validated configuration dictionary

Return type:

dict

Raises:

Exception – If config loading or validation fails

validate_config(config)[source]

Validates the configuration data

Parameters:

config (dict) – Configuration dictionary

Returns:

Validated configuration dictionary

Return type:

dict

Raises:

ValueError – If validation fails

sabbath_school_reproducer.downloader module

GitHub Content Downloader for Sabbath School Lessons

This module handles downloading lesson content from the GitHub repository.

class sabbath_school_reproducer.downloader.GitHubDownloader(github_paths, config=None)[source]

Bases: object

Downloads Sabbath School lesson content from GitHub repository.

static check_existing_file(filename, force_overwrite=False)[source]

Check if the file already exists and prompt for overwrite

Parameters:
  • filename (str) – Path to the file

  • force_overwrite (bool) – Whether to force overwrite without prompting

Returns:

True if should proceed with download, False otherwise

Return type:

bool

download_json(url)[source]

Download and parse JSON from a URL

Parameters:

url (str) – URL to download JSON from

Returns:

Parsed JSON, or None if download failed

Return type:

dict

download_lesson_data()[source]

Download all lesson data from GitHub repository

Returns:

Dictionary containing all downloaded content

Return type:

dict

Raises:

Exception – If download of contents.json fails

download_markdown(url)[source]

Download markdown content from a URL

Parameters:

url (str) – URL to download markdown from

Returns:

Markdown content, or empty string if download failed

Return type:

str

static get_lesson_range_filename(config)[source]

Generate a filename that includes the lesson range information

Parameters:

config (Config) – Configuration object

Returns:

Filename with lesson range information

Return type:

str

sabbath_school_reproducer.main module

Sabbath School Lesson Downloader and Generator

This script downloads lesson content from GitHub and generates a PDF.

Usage: python3 main.py config.yaml [–debug] [–debug-html-only]

sabbath_school_reproducer.main.main()[source]

Main function that orchestrates the entire process

This function handles command-line arguments, loads configuration, downloads lesson content, and generates PDF output. It also supports reproduction mode for adapting historical lessons to new dates.

sabbath_school_reproducer.processor module

Markdown Processor for Sabbath School Lessons

This module processes markdown files, extracting lesson content, front matter, and back matter.

class sabbath_school_reproducer.processor.MarkdownProcessor[source]

Bases: object

Processes markdown files to extract structured content.

static add_new_lines_to_markdown(markdown_content)[source]
static adjust_dates(lessons, config)[source]

Adjust lesson dates based on the quarter_start_date in config

Parameters:
  • lessons (list) – List of lesson dictionaries

  • config (dict) – Configuration dictionary with reproduction settings

Returns:

Updated list of lesson dictionaries with adjusted dates

Return type:

list

static extract_and_remove_date(markdown_text, language_code='en')[source]

Extract date from markdown and return the text with the date removed

Parameters:
  • markdown_text (str) – The markdown text to process

  • language_code (str) – The language code

Returns:

(extracted_date, cleaned_text)

Return type:

tuple

static parse_file_sections(content)[source]

Extract content from different file sections marked with special headers

Parameters:

content (str) – Combined markdown file content

Returns:

(lessons_content, frontmatter_content, backmatter_content)

Return type:

tuple

static parse_lessons(markdown_content, language_code='en')[source]

Parse the markdown content to extract lessons using a line-by-line approach

Parameters:
  • markdown_content (str) – Markdown content containing lessons

  • language_code (str) – Language code for translations

Returns:

List of lesson dictionaries

Return type:

list

static parse_questions_from_markdown(markdown_content, language_code='en')[source]

Parse questions from markdown content.

Parameters:
  • markdown_content (str) – Markdown content containing questions

  • language_code (str) – Language code for translations

Returns:

List of question dictionaries

Return type:

list

static process_markdown_file(markdown_file, config=None)[source]

Process the markdown file to extract content

Parameters:
  • markdown_file (str) – Path to the markdown file

  • config (dict, optional) – Configuration dictionary for reproduction

Returns:

Dictionary with extracted content

Return type:

dict

sabbath_school_reproducer.setup module

Module contents

Sabbath School Lesson Downloader and PDF Generator Package

This package downloads Sabbath School lessons from the GitHub repository and generates a beautifully formatted PDF using a configurable pipeline.