Skip to content

Buntool Modernisation#2

Draft
DanielAtCosmicDNA wants to merge 42 commits intoTrisSherliker:mainfrom
CosmicDNA:main
Draft

Buntool Modernisation#2
DanielAtCosmicDNA wants to merge 42 commits intoTrisSherliker:mainfrom
CosmicDNA:main

Conversation

@DanielAtCosmicDNA
Copy link

@DanielAtCosmicDNA DanielAtCosmicDNA commented Dec 10, 2025

This update refactors the Buntool application into a proper Python package, introducing modern development practices, improving code structure, and simplifying installation and execution.

Key Changes:

  1. Project Structure and Packaging:
  • The project is now structured as an installable Python package named buntool.
  • Source code from app.py, bundle.py, and makedocxindex.py has been moved into a buntool/ directory.
  • A pyproject.toml file has been added to manage project metadata, dependencies, and build configurations using setuptools.
  • The old requirements.txt has been removed in favour of pyproject.toml.
  1. Simplified Installation and Execution:
  • Installation is now a standard pip install -e . for editable mode. The previous manual step of copying fonts has been eliminated.
  • The application can be launched with a simple buntool command, thanks to the [project.scripts] entry point in pyproject.toml.
  1. Code Refactoring and Modernization:
  • Flask App Factory: The buntool/app.py module now uses the app factory pattern (create_app), which is a best practice for Flask applications. This improves testability and configuration management.
  • Pathlib Usage: os.path has been replaced with pathlib.Path throughout the codebase for a more modern and object-oriented approach to filesystem paths.
  • Configuration Management: A new buntool/bundle_config.py introduces a BundleConfig dataclass. This centralizes all bundle-related settings, replacing long and unwieldy function parameter lists.
  • Modular Functions: Large functions in app.py and bundle.py have been broken down into smaller, single-responsibility functions (e.g., _process_uploaded_files, _handle_csv_index_upload, _generate_toc_entry). This greatly enhances readability and maintainability.
  • Improved Logging: The application now uses colorlog for more readable, colored console output. Session-specific logging is also better managed.
  1. Frontend and User Experience:
  • The index.html template has been updated to use a <label> for the file upload zone, improving accessibility and removing the need for a JavaScript click() handler.
  • JavaScript in buntool.js has been slightly refactored for better clarity when handling form data.

…p advanced linting with Rufus, use comprehensions whenever possible and fix table in docx_output generation.
@DanielAtCosmicDNA DanielAtCosmicDNA marked this pull request as draft December 18, 2025 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant