#!/usr/bin/env python3 """ Simple test script to verify that the EPUB reader fixes are working correctly. """ import sys import os # Add the pyWebLayout directory to the Python path sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'pyWebLayout')) try: from pyWebLayout.io.readers.epub_reader import read_epub print("Successfully imported epub_reader module") # Test reading the EPUB file epub_path = os.path.join('pyWebLayout', 'examples', 'pg174-images-3.epub') if not os.path.exists(epub_path): print(f"EPUB file not found: {epub_path}") sys.exit(1) print(f"Reading EPUB file: {epub_path}") # Try to read the EPUB book = read_epub(epub_path) print(f"Successfully read EPUB file!") print(f"Book title: {book.title}") print(f"Number of chapters: {len(book.chapters)}") # Check first chapter if book.chapters: first_chapter = book.chapters[0] print(f"First chapter title: {first_chapter.title}") print(f"First chapter has {len(first_chapter.blocks)} blocks") except Exception as e: print(f"Error: {e}") import traceback traceback.print_exc() sys.exit(1) print("Test completed successfully!")