treex-cli 0.1.2__tar.gz → 0.1.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: treex-cli
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: List directory contents as a tree with file metadata
5
5
  Author: Corey Goldberg
6
6
  Maintainer: Corey Goldberg
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "treex-cli"
7
- version = "0.1.2"
7
+ version = "0.1.3"
8
8
  description="List directory contents as a tree with file metadata"
9
9
  license = "MIT"
10
10
  license-files = ["LICENSE"]
@@ -60,7 +60,7 @@ class GitIgnore:
60
60
  return result.returncode == 0
61
61
 
62
62
 
63
- def format_size(size): # noqa: RET503
63
+ def _format_size(size): # noqa: RET503
64
64
  """Format bytes as a human-readable size."""
65
65
  units = ["B", "KB", "MB", "GB", "TB"]
66
66
  for unit in units:
@@ -71,12 +71,12 @@ def format_size(size): # noqa: RET503
71
71
  size /= 1024
72
72
 
73
73
 
74
- def format_modified(timestamp):
74
+ def _format_modified(timestamp):
75
75
  """Format a modification timestamp."""
76
76
  return datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M")
77
77
 
78
78
 
79
- def is_binary_file(path, chunk_size=8192):
79
+ def _is_binary_file(path, chunk_size=8192):
80
80
  """Check if the file appears to be binary."""
81
81
  try:
82
82
  with path.open("rb") as f:
@@ -97,7 +97,7 @@ def is_binary_file(path, chunk_size=8192):
97
97
  return True
98
98
 
99
99
 
100
- def count_lines(path):
100
+ def _count_lines(path):
101
101
  """Count lines without loading the entire file into memory."""
102
102
  try:
103
103
  with path.open("rb") as f:
@@ -106,18 +106,18 @@ def count_lines(path):
106
106
  return None
107
107
 
108
108
 
109
- def file_info(path):
110
- """Get file info."""
109
+ def _file_metadata(path):
110
+ """Get file metadata."""
111
111
  try:
112
112
  stat = path.stat()
113
113
  size = stat.st_size
114
- modified = format_modified(stat.st_mtime)
114
+ modified = _format_modified(stat.st_mtime)
115
115
  except OSError:
116
116
  return "?", "[unreadable]", 0, None
117
- size_text = format_size(size)
118
- if is_binary_file(path):
117
+ size_text = _format_size(size)
118
+ if _is_binary_file(path):
119
119
  return size_text, "[binary]", size, modified
120
- lines = count_lines(path)
120
+ lines = _count_lines(path)
121
121
  if lines is None:
122
122
  return size_text, "[unreadable]", size, modified
123
123
  return size_text, f"{lines:,} lines", size, modified
@@ -173,7 +173,7 @@ def _collect_tree(
173
173
  )
174
174
  elif entry.is_file():
175
175
  stats["files"] += 1
176
- size_text, info, size, modified = file_info(entry)
176
+ size_text, info, size, modified = _file_metadata(entry)
177
177
  stats["total_size"] += size
178
178
  timestamp = modified if show_modified else None
179
179
  rows.append((tree_name, (size_text, info, timestamp)))
@@ -266,7 +266,7 @@ def main():
266
266
  print(
267
267
  f"{stats['directories']} directories • "
268
268
  f"{stats['files']} files • "
269
- f"{format_size(stats['total_size'])}"
269
+ f"{_format_size(stats['total_size'])}"
270
270
  )
271
271
  return 0
272
272
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: treex-cli
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: List directory contents as a tree with file metadata
5
5
  Author: Corey Goldberg
6
6
  Maintainer: Corey Goldberg
File without changes
File without changes
File without changes