Club File Pack | Local workbook lab

Build a club handover pack from five small fictional files. The lab reads an
XLSX sheet, extracts text from text-based PDF pages, flags an image-only page,
and creates smaller PNG copies. Run these commands in this lesson's folder.

Set up once with Python 3.11 or newer.
Check your current folder with dir on Windows or ls on Mac. It should contain
requirements.txt and the Python scripts below.

Windows Command Prompt
    py -m venv .venv
    .venv\Scripts\activate.bat

macOS or Linux
    python3 -m venv .venv
    source .venv/bin/activate

Look for (.venv) in your prompt. Verify pip comes from that environment, install
the packages while connected, then check the install:
    python -m pip --version
    python -m pip install --only-binary=:all: -r requirements.txt
    python -m pip check
    python check_packages.py
Expect "The four document packages are ready."

With the environment active, run the three scripts:
    python make_fixtures.py
    python club_pack.py
    python verify_pack.py

For an offline room, on a connected computer with the same OS, CPU architecture
and Python major and minor version, activate a virtual environment and run:
    python -m pip download --only-binary=:all: -r requirements.txt -d wheels
Copy the workbook and wheels folder to the classroom computer. Place the wheels
folder beside requirements.txt. Create and activate a new .venv on that system,
then run this command in place of the connected install:
    python -m pip install --no-index --find-links=wheels -r requirements.txt
Repeat the package check before running the scripts. Keep separate wheel folders
for different operating systems, architectures or Python minor versions.

The workbook guide setup/install-python-packages.txt explains where packages
come from, how to select .venv in VS Code and how to fix a failed import.
A second extracted workbook gives you a fresh lab folder for repeating the run.
The verification script reads the pack for you. To inspect it yourself, open
PDF and PNG files in a browser and XLSX in a spreadsheet app such as LibreOffice
Calc. The viewer is optional.
What to look for

1. Open fixtures/kit-counts.xlsx and read the Kit counts sheet. Art has 4 kits,
   Music has 0 and Chess has a blank cell. Read the read_quantities() and
   write_inventory() functions in club_pack.py. Open pack/inventory.xlsx and
   check that it counts two reported rows, four kits and one missing count.
2. Open fixtures/schedule.pdf and fixtures/scanned-note.pdf, then read
   read_pdf_pages(). One page contains a picture of a sentence. Its extracted
   text is empty, so the report flags one page for review. Open
   pack/print-pack.pdf and check that all three pages are present in order.
3. Compare the original posters with the PNG copies in pack/posters. The
   announcement changes from 800 by 400 to 320 by 160. The badge stays 160 by
   160. Read write_poster_copies() to see how thumbnail() keeps proportions.
4. Run verify_pack.py after building the supplied pack. It reopens the real
   files and checks worksheet rows, PDF pages and image pixels.

The sheet uses literal whole-number counts and blank cells. openpyxl reads
and writes cells. Formula results require a spreadsheet program to calculate
and save them. pypdf extracts embedded text and copies pages. Reading text
from a photo of a page would require optical character recognition (OCR).

Try a change

Keep the supplied files as your baseline. Make a second fixture folder with
make_fixtures.py fixtures-remix. Change a count in that folder's workbook.
Predict the new report, then run club_pack.py fixtures-remix --output pack-remix
with your environment's Python. Compare the two inventory workbooks. The
verification script expects the supplied values, so check your remix against
the results you predicted.

Library guides
https://openpyxl.readthedocs.io/en/stable/tutorial.html
https://pypdf.readthedocs.io/en/stable/user/extract-text.html
https://pypdf.readthedocs.io/en/stable/user/merging-pdfs.html
https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.thumbnail
https://docs.reportlab.com/reportlab/userguide/ch2_graphics/
