controller.utils.slide_controller_data_manager

File:

EuljiroWorship/controller/utils/slide_controller_data_manager.py

Author:

Benjamin Jaedon Choi - https://github.com/saintbenjamin

Affiliated Church:

The Eulji-ro Presbyterian Church [대한예수교장로회(통합) 을지로교회]

Address:

The Eulji-ro Presbyterian Church, 24-10, Eulji-ro 20-gil, Jung-gu, Seoul 04549, South Korea

Telephone:

+82-2-2266-3070

E-mail:

euljirochurch [at] G.M.A.I.L. (replace [at] with @ and G.M.A.I.L as you understood.)

License:

MIT License with Attribution Requirement (see LICENSE file for details); Copyright (c) 2025 The Eulji-ro Presbyterian Church.

Persistent data manager for the slide controller.

This module manages the persistent state used by the slide controller:

  • Loading slide data from the active slide JSON file

  • Tracking the current slide index

  • Backing up slide data before emergency interruption

  • Restoring slides after emergency mode is cleared

It intentionally contains no UI logic and serves as a thin I/O and state coordination layer for controller.slide_controller.SlideController.

class controller.utils.slide_controller_data_manager.SlideControllerDataManager(slide_file)[source]

Bases: object

Manages persistent slide data and controller state.

This class is responsible for:

  • Loading slide data from disk

  • Keeping track of the current slide index

  • Backing up slide data before emergency interruption

  • Restoring slide data after emergency mode exits

slide_file

Path to the active slide JSON file.

Type:

str

slides

List of currently loaded slide dictionaries.

Type:

list[dict]

index

Current slide index.

Type:

int

last_slide_index

Previously active slide index, if tracked.

Type:

int | None

__init__(slide_file)[source]

Initialize the data manager with a slide file path.

Parameters:

slide_file (str) – Path to the JSON file currently used by the slide controller.

Returns:

None

load_slides()[source]

Load slides from the active slide file into memory.

  • On success, populates self.slides with parsed slide dictionaries.

  • On failure, resets the slide list to an empty list and prints an error.

Returns:

None

backup_slides()[source]

Create a backup copy of the active slide file.

Copies core.config.paths.SLIDE_FILE to core.config.paths.SLIDE_BACKUP_FILE.

This backup is used to restore slides after emergency caption mode.

Returns:

None

restore_from_backup()[source]

Restore slide data from the backup file if available.

Loads slides from core.config.paths.SLIDE_BACKUP_FILE into memory.

Returns:

  • True if backup restoration succeeded.

  • False if no backup exists or restoration failed.

Return type:

bool

clear_backups()[source]

Remove the slide backup file if it exists.

Deletes core.config.paths.SLIDE_BACKUP_FILE from disk to clear stale backup state.

Returns:

None