The application now uses a virtual environment for dependencies. Use the convenience script:
./run.shOr activate the virtual environment manually:
source venv/bin/activate
python email_deleter.pySee RUNNING.md for detailed instructions and troubleshooting.
outlook-email-deleter/
├── src/ # All application code
│ ├── auth/ # OAuth2 authentication
│ ├── imap/ # IMAP email operations
│ ├── ui/ # User interface
│ ├── utils/ # Utilities (logging, parsing)
│ ├── config.py # Configuration management
│ └── exceptions.py # Custom exceptions
├── tests/ # Unit tests
├── email_deleter.py # Main entry point
└── requirements.txt # Dependencies
# Setup (first time)
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Run all tests
pytest tests/ -v
# Run specific test file
pytest tests/test_config.py -v
# Run with coverage
pytest tests/ --cov=src# Authentication
from src.auth import OAuth2Authenticator, TokenCache
# IMAP operations
from src.imap import EmailDeleter
# UI components
from src.ui.display import display_preview, display_welcome_banner
# Utilities
from src.utils.date_parser import parse_date_range
from src.utils.logger import setup_logger
# Configuration
from src.config import AppConfig, IMAP_CONFIG, OAUTH_CONFIG
# Exceptions
from src.exceptions import (
AuthenticationError,
IMAPConnectionError,
EmailSearchError
)- Update
src/imap/client.py::search_emails()method - Add tests in
tests/test_imap_client.py - Update UI in
src/ui/display.pyif needed
- Add to appropriate config class in
src/config.py - Add validation if needed
- Add tests in
tests/test_config.py - Use in relevant modules
Application logs to email_deleter.log by default:
from src.utils.logger import setup_logger
logger = setup_logger(__name__)
logger.info("Operation started")
logger.error("Operation failed", exc_info=True)Use specific exceptions for better error handling:
from src.exceptions import AuthenticationError
try:
# Your code
pass
except AuthenticationError as e:
print(f"Auth failed: {e}")
print(e.get_recovery_guidance()) # User-friendly recovery stepsConfiguration is validated on startup:
from src.config import AppConfig
try:
config = AppConfig() # Loads from .env
print(f"Email: {config.email}")
print(f"IMAP Server: {config.imap.SERVER}")
except ConfigurationError as e:
print(f"Config error: {e}")- Better Error Messages: Specific exceptions with recovery guidance
- Logging: All operations logged to file for debugging
- Testing: 59 comprehensive unit tests
- Type Safety: Full type hints for IDE support
- Modular: Easy to extend and maintain
- Main README: Usage and setup instructions
- REFACTORING_SUMMARY.md: Detailed refactoring changes
- Docstrings: Every function and class documented
- Check
email_deleter.logfor debugging - Run tests:
pytest tests/ -v - Read docstrings: All modules have comprehensive documentation
- Check REFACTORING_SUMMARY.md for architecture details