Updated readme

This commit is contained in:
Dimitris Zlatanidis 2023-04-16 11:08:58 +03:00
parent f6b32fae3a
commit 2337ee6bdc
3 changed files with 17 additions and 16 deletions

View file

@ -1,6 +1,7 @@
4.7.9 - 15/04/203
Updated:
- For proxies configuration
- For convert file sizes
Fixed:
- Clear screen when dialog is disabled

View file

@ -162,23 +162,20 @@ class Utilities:
""" A general method to raise an error message and exit. """
raise SystemExit(f"\n{self.configs.prog_name}: {self.bred}Error{self.endc}: {message}.\n")
def get_file_size(self, file: Path) -> str:
""" Get the local file size and converted to units. """
size = Path(file).stat().st_size
return self.convert_file_sizes(size)
@staticmethod
def get_file_size(file: Path) -> str:
""" Get the file size and converted to units. """
unit: str = 'KB'
file_size = Path(file).stat().st_size
mb = file_size / 1024 ** 2
gb = file_size / 1024 ** 3
def convert_file_sizes(size: int) -> str:
""" Convert file sizes. """
units: list = ['KB', 'MB', 'GB']
if mb >= 0.1:
file_size = mb
unit: str = 'MB'
if gb >= 0.1:
file_size = mb
unit: str = 'GB'
return f'{str(round(file_size, 2))} {unit}'
for unit in units:
size: float = size / 1000
if size < 1000:
return f'{size:.2f} {unit}'
@staticmethod
def apply_package_pattern(data: dict, packages: list) -> list:

View file

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import os
import re
from typing import Any
from pathlib import Path
@ -60,7 +61,9 @@ class ViewMessage(Configs):
if self.option_for_binaries:
version: str = self.data[package][0]
size: str = self.data[package][4]
size: str = self.utils.convert_file_sizes(
int(''.join(re.findall(r'\d+', self.data[package][4])))
)
repo: str = self.repo
else:
version: str = self.data[package][2]