Skip to content

Commit

Permalink
ls/ls-url: use tqmd instead of humanize.naturalsize
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Aug 22, 2023
1 parent 3783d65 commit cae1b1b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dvc/commands/ls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@


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)


Expand Down
8 changes: 8 additions & 0 deletions dvc/utils/humanize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ dependencies = [
"tqdm<5,>=4.63.1",
"voluptuous>=0.11.7",
"zc.lockfile>=1.2.1",
"humanize",
]

[project.optional-dependencies]
Expand Down

0 comments on commit cae1b1b

Please sign in to comment.