Skip to content

Commit

Permalink
fix: entrypoint.py
Browse files Browse the repository at this point in the history
  • Loading branch information
somaz94 committed Feb 7, 2025
1 parent d3b9d8a commit bb63711
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,24 @@ def print_success(message):
def print_error(message):
print(f"❌ {message}")

def get_file_size(file_path):
def get_file_size(size_or_path):
"""Return human readable file size"""
size = os.path.getsize(file_path)
for unit in ['B', 'KB', 'MB', 'GB']:
if size < 1024:
return f"{size:.2f} {unit}"
size /= 1024
return f"{size:.2f} TB"
try:
# If input is a path, get its size
if isinstance(size_or_path, str):
size = os.path.getsize(size_or_path)
# If input is already a number, use it directly
else:
size = size_or_path

for unit in ['B', 'KB', 'MB', 'GB']:
if size < 1024:
return f"{size:.2f} {unit}"
size /= 1024
return f"{size:.2f} TB"
except Exception as e:
logger.error(f"Error calculating size: {e}")
return "Unknown size"

def validate_format(format):
"""Validate compression format"""
Expand Down

0 comments on commit bb63711

Please sign in to comment.