python-du 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_du-0.1.1 → python_du-0.1.2}/PKG-INFO +1 -1
- {python_du-0.1.1 → python_du-0.1.2}/pyproject.toml +1 -1
- {python_du-0.1.1 → python_du-0.1.2}/python_du/scanner.py +9 -2
- {python_du-0.1.1 → python_du-0.1.2}/python_du.egg-info/PKG-INFO +1 -1
- {python_du-0.1.1 → python_du-0.1.2}/README.md +0 -0
- {python_du-0.1.1 → python_du-0.1.2}/python_du/__init__.py +0 -0
- {python_du-0.1.1 → python_du-0.1.2}/python_du/cli.py +0 -0
- {python_du-0.1.1 → python_du-0.1.2}/python_du/renderer.py +0 -0
- {python_du-0.1.1 → python_du-0.1.2}/python_du.egg-info/SOURCES.txt +0 -0
- {python_du-0.1.1 → python_du-0.1.2}/python_du.egg-info/dependency_links.txt +0 -0
- {python_du-0.1.1 → python_du-0.1.2}/python_du.egg-info/entry_points.txt +0 -0
- {python_du-0.1.1 → python_du-0.1.2}/python_du.egg-info/top_level.txt +0 -0
- {python_du-0.1.1 → python_du-0.1.2}/setup.cfg +0 -0
|
@@ -21,6 +21,11 @@ class DirNode:
|
|
|
21
21
|
return self.path.name or str(self.path)
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
def _allocated_size(stat_result: os.stat_result) -> int:
|
|
25
|
+
blocks = getattr(stat_result, "st_blocks", None)
|
|
26
|
+
return stat_result.st_size if blocks is None else blocks * 512
|
|
27
|
+
|
|
28
|
+
|
|
24
29
|
def scan(root: Path, *, max_depth: int | None = None, follow_symlinks: bool = False) -> DirNode:
|
|
25
30
|
"""Walk *root* and return a tree of DirNode objects with computed sizes."""
|
|
26
31
|
return _scan_dir(root.resolve(), depth=0, max_depth=max_depth, follow_symlinks=follow_symlinks)
|
|
@@ -51,7 +56,8 @@ def _scan_dir(
|
|
|
51
56
|
|
|
52
57
|
if entry.is_file(follow_symlinks=follow_symlinks):
|
|
53
58
|
try:
|
|
54
|
-
|
|
59
|
+
stat_result = entry.stat(follow_symlinks=follow_symlinks)
|
|
60
|
+
node.own_size += _allocated_size(stat_result)
|
|
55
61
|
node.file_count += 1
|
|
56
62
|
except OSError:
|
|
57
63
|
pass
|
|
@@ -83,7 +89,8 @@ def _shallow_size(path: Path) -> DirNode:
|
|
|
83
89
|
for dirpath, _dirnames, filenames in os.walk(path):
|
|
84
90
|
for fname in filenames:
|
|
85
91
|
try:
|
|
86
|
-
|
|
92
|
+
stat_result = os.stat(os.path.join(dirpath, fname))
|
|
93
|
+
total += _allocated_size(stat_result)
|
|
87
94
|
fcount += 1
|
|
88
95
|
except OSError:
|
|
89
96
|
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|