ShiftPrint is a Windows desktop app that batch-prints shift schedule templates via Microsoft Word COM automation.
- Production-focused Word automation: open, replace, print, and close with cleanup safeguards
- Domain logic handles complex monthly rotation scheduling (e.g. "third Thursday" patterns)
- Defensive workflow with preflight checks, per-document retry paths, and CSV failure reporting
- Modular architecture with strong unit-test coverage and static quality gates
- Packaged as a single-file executable for non-technical end users via PyInstaller
- Independent Day and Night print selections with single-date or date-range scope for each shift
- Exact preflight-neutral print manifest showing the selected dates, document count, and printer before a run starts
- Date replacement across body, header, and footer story ranges
- Template path, printer, and date-range preflight validation before any processing begins
- Ambiguous template names are rejected at preflight rather than resolved silently
- Per-document retry handling for transient COM errors with structured failure logging
- Cancelable background processing with responsive UI progress updates
- Timestamped CSV failure reports for audit and retry workflows
src/main.py— orchestration and workflow controlsrc/ui.py— Tkinter/ttk interface layersrc/word_processor.py— Word COM automation lifecycle (open, replace, print, close)src/print_manifest.py— shift selection, validation, and print manifest constructionsrc/scheduler.py— date resolution and template path logicsrc/config.py— config managementsrc/path_validation.py— path traversal and filename safety checks
| Layer | Technology |
|---|---|
| Language | Python 3.12 |
| UI | Tkinter/ttk |
| Office integration | pywin32 (Word COM) |
| Date picker | tkcalendar |
| Testing | pytest + pytest-cov |
| Quality | black + mypy + pylint |
| Packaging | PyInstaller |
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
python main.pyWindows helper scripts:
setup.bat— installs all dependencies into a virtualenvstart_app.bat— activates the environment and launches the app
pip install -r requirements-dev.txt
pytest # run test suite with coverage
black --check src tests # formatting check
mypy src # type checking
pylint src --fail-under=8.0 # linting gateAll four gates run in CI on pushes to main and test, and on pull requests to
main. The test suite mocks all Windows-only modules so it can run on any
platform.
Before a release, use the Windows print smoke test to verify real Word COM and physical printer behavior for Night-only, Day-only, both-shift, and mixed scope runs.
test is the working branch. Every push to it runs the quality gates, then
builds a Windows executable and uploads it as
ShiftPrint-v<version>-<commit>, so a downloadable build always exists for the
commit you are working on. Push builds expire after 7 days.
main does not trigger a build of its own: it only ever receives commits that
already passed on test, so running everything again would duplicate the work
for a single commit. Pull requests into main run the gates only.
The version is read from __version__ in src/__init__.py; it is not entered
by hand. To cut a published release:
- Bump
__version__and commit. - Run the Build workflow via
workflow_dispatchwithcreate_releaseenabled.
The build runs only after the quality gates pass, and the tag, artifact name, and in-app version all come from that one value.
- Word documents open in read-only mode during processing; originals are never modified
- Word macros are force-disabled on every document open
- Path validation blocks traversal outside configured template root directories
- Template names that collide after normalization are rejected, so a run can never print an arbitrary file chosen by directory order
- Date range limits prevent runaway batch operations
- Config writes are atomic; all operations are logged with structured timestamps
main.py— top-level entry pointsrc/— application modules (controller, UI, scheduler, COM processor, config, validation)tests/— unit tests and module fixtures.github/workflows/build.yml— quality gates on every push, plus the on-demand Windows build and release workflow via PyInstaller
MIT (see LICENSE)