[commons.util] improvement: returning a float for 'size_to_byte' parsing

This commit is contained in:
Vinicius Moreira
2022-04-06 10:16:48 -03:00
parent 20556a9fe3
commit 7d12810772
9 changed files with 27 additions and 29 deletions

View File

@@ -474,7 +474,7 @@ def is_mirrors_available() -> bool:
return bool(shutil.which('pacman-mirrors'))
def map_update_sizes(pkgs: List[str]) -> Dict[str, int]: # bytes:
def map_update_sizes(pkgs: List[str]) -> Dict[str, float]: # bytes:
output = run_cmd('pacman -Si {}'.format(' '.join(pkgs)))
if output:
@@ -483,7 +483,7 @@ def map_update_sizes(pkgs: List[str]) -> Dict[str, int]: # bytes:
return {}
def map_download_sizes(pkgs: List[str]) -> Dict[str, int]: # bytes:
def map_download_sizes(pkgs: List[str]) -> Dict[str, float]: # bytes:
output = run_cmd('pacman -Si {}'.format(' '.join(pkgs)))
if output:
@@ -492,7 +492,7 @@ def map_download_sizes(pkgs: List[str]) -> Dict[str, int]: # bytes:
return {}
def get_installed_size(pkgs: List[str]) -> Dict[str, int]: # bytes
def get_installed_size(pkgs: List[str]) -> Dict[str, float]: # bytes
output = run_cmd('pacman -Qi {}'.format(' '.join(pkgs)))
if output:

View File

@@ -58,7 +58,7 @@ class DebianPackage(SoftwarePackage):
description: Optional[str] = None, maintainer: Optional[str] = None, installed: bool = False,
update: bool = False, app: Optional[DebianApplication] = None, compressed_size: Optional[int] = None,
uncompressed_size: Optional[int] = None, categories: Tuple[str] = None,
updates_ignored: Optional[bool] = None, transaction_size: Optional[int] = None):
updates_ignored: Optional[bool] = None, transaction_size: Optional[float] = None):
super(DebianPackage, self).__init__(id=name, name=name, version=version, installed=installed,
description=description, update=update,
latest_version=latest_version if latest_version is not None else version)

View File

@@ -410,7 +410,7 @@ def run(app_id: str):
subprocess.Popen((f'flatpak run {app_id}',), shell=True, env={**os.environ})
def map_update_download_size(app_ids: Iterable[str], installation: str, version: Version) -> Dict[str, int]:
def map_update_download_size(app_ids: Iterable[str], installation: str, version: Version) -> Dict[str, float]:
success, output = ProcessHandler().handle_simple(SimpleProcess(('flatpak', 'update', f'--{installation}')))
if version >= VERSION_1_2:
res = {}