[arch] fix: package sizes float conversion error

This commit is contained in:
Vinicius Moreira
2022-03-28 10:56:14 -03:00
parent 4e1bffa72f
commit f44097ad7e

View File

@@ -508,7 +508,7 @@ def map_update_sizes(pkgs: List[str]) -> Dict[str, int]: # bytes:
output = run_cmd('pacman -Si {}'.format(' '.join(pkgs)))
if output:
return {pkgs[idx]: size_to_byte(float(size[0]), size[1]) for idx, size in enumerate(RE_INSTALLED_SIZE.findall(output))}
return {pkgs[idx]: size_to_byte(float(size[0].replace(',', '.')), size[1]) for idx, size in enumerate(RE_INSTALLED_SIZE.findall(output))}
return {}
@@ -517,7 +517,7 @@ def map_download_sizes(pkgs: List[str]) -> Dict[str, int]: # bytes:
output = run_cmd('pacman -Si {}'.format(' '.join(pkgs)))
if output:
return {pkgs[idx]: size_to_byte(float(size[0]), size[1]) for idx, size in enumerate(RE_DOWNLOAD_SIZE.findall(output))}
return {pkgs[idx]: size_to_byte(float(size[0].replace(',', '.')), size[1]) for idx, size in enumerate(RE_DOWNLOAD_SIZE.findall(output))}
return {}
@@ -526,7 +526,7 @@ def get_installed_size(pkgs: List[str]) -> Dict[str, int]: # bytes
output = run_cmd('pacman -Qi {}'.format(' '.join(pkgs)))
if output:
return {pkgs[idx]: size_to_byte(float(size[0]), size[1]) for idx, size in enumerate(RE_INSTALLED_SIZE.findall(output))}
return {pkgs[idx]: size_to_byte(float(size[0].replace(',', '.')), size[1]) for idx, size in enumerate(RE_INSTALLED_SIZE.findall(output))}
return {}
@@ -688,11 +688,11 @@ def map_updates_data(pkgs: Iterable[str], files: bool = False) -> dict:
latest_field = 'c'
elif field == 'Download Size':
size = val.split(' ')
data['ds'] = size_to_byte(float(size[0]), size[1])
data['ds'] = size_to_byte(float(size[0].replace(',', '.')), size[1])
latest_field = 'ds'
elif field == 'Installed Size':
size = val.split(' ')
data['s'] = size_to_byte(float(size[0]), size[1])
data['s'] = size_to_byte(float(size[0].replace(',', '.')), size[1])
latest_field = 's'
elif latest_name and latest_field == 's':
res[latest_name] = data