mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 11:33:25 +00:00
- Updated `pyproject.toml` to reflect new package structure. - Created `renamer/__init__.py` to initialize the package. - Implemented `RenamerApp` in `renamer/app.py` for the main application interface. - Added constants for video extensions in `renamer/constants.py`. - Developed `MediaExtractor` class in `renamer/extractor.py` for extracting metadata from media files. - Created various extractor classes in `renamer/extractors/` for handling filename, metadata, and media info extraction. - Added formatting classes in `renamer/formatters/` for displaying media information and proposed filenames. - Implemented utility functions in `renamer/utils.py` for detecting file types and extracting media track information. - Introduced `OpenScreen` in `renamer/screens.py` for user input of directory paths. - Enhanced error handling and user feedback throughout the application.
17 lines
644 B
Python
17 lines
644 B
Python
class SizeFormatter:
|
|
"""Class for formatting file sizes"""
|
|
|
|
@staticmethod
|
|
def format_size(bytes_size: int) -> str:
|
|
"""Format bytes to human readable with unit"""
|
|
for unit in ['B', 'KB', 'MB', 'GB', 'TB']:
|
|
if bytes_size < 1024:
|
|
return f"{bytes_size:.1f} {unit}"
|
|
bytes_size /= 1024
|
|
return f"{bytes_size:.1f} TB"
|
|
|
|
@staticmethod
|
|
def format_size_full(bytes_size: int) -> str:
|
|
"""Format size with both human readable and bytes"""
|
|
size_formatted = SizeFormatter.format_size(bytes_size)
|
|
return f"{size_formatted} ({bytes_size:,} bytes)" |