mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-17 07:48:18 +01:00
Updated readme
This commit is contained in:
parent
f6b32fae3a
commit
2337ee6bdc
3 changed files with 17 additions and 16 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue