from pathlib import Path
import unreal

current_file_path = Path(__file__).resolve()
plugin_dir = current_file_path.parent.parent.parent

extras_version = '0.8.0'
extras_url = f'https://storage.googleapis.com/assets-inworld-ai/unreal-plugin/RuntimeExtras_v{extras_version}.zip'
extras_filename = f'RuntimeExtras_v{extras_version}.zip'
extras_path = plugin_dir / 'Extras'
extras_config = extras_path / 'extras.ini'

py_path = plugin_dir / 'Content' / 'Python'
py_functions_path = py_path / 'functions'

engine_dir = Path(unreal.Paths.engine_dir())
unreal_python_exe_path = engine_dir / "Binaries" / "ThirdParty" / "Python3" / "Win64" / "python.exe"

def bytes_to_str(num_bytes):
    # Define units and their corresponding byte values
    units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
    size = num_bytes
    unit_index = 0

    # Convert to the largest possible unit
    while size >= 1024 and unit_index < len(units) - 1:
        size /= 1024.0
        unit_index += 1

    # Format the size with two decimal places
    return f"{size:.2f} {units[unit_index]}"
