ls/ls-url: use tqmd instead of humanize.naturalsize

Per https://github.com/iterative/dvc/pull/9857#issuecomment-1683185006
This commit is contained in:
Ruslan Kuprieiev
2023-08-22 20:21:08 +03:00
parent 3783d65dde
commit cae1b1b647
3 changed files with 10 additions and 3 deletions
+2 -2
View File
@@ -12,13 +12,13 @@ logger = logging.getLogger(__name__)
def _format_entry(entry, fmt):
from humanize import naturalsize
from dvc.utils.humanize import naturalsize
size = entry.get("size")
if size is None:
size = ""
else:
size = naturalsize(size, gnu=True)
size = naturalsize(size)
return size, fmt(entry)
+8
View File
@@ -31,3 +31,11 @@ def truncate_text(text: str, max_length: int, with_ellipsis: bool = True) -> str
return text[: max_length - 1] + ELLIPSIS
return text[:max_length]
def naturalsize(value: float, base: int = 1024) -> str:
from tqdm import tqdm
if value < base:
return f"{value:.0f}"
return tqdm.format_sizeof(value, divisor=base)
-1
View File
@@ -65,7 +65,6 @@ dependencies = [
"tqdm<5,>=4.63.1",
"voluptuous>=0.11.7",
"zc.lockfile>=1.2.1",
"humanize",
]
[project.optional-dependencies]