treex-cli 0.1.4__tar.gz → 0.1.5__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.4
3
+ Version: 0.1.5
4
4
  Summary: List directory contents as a tree with file metadata
5
5
  Author: Corey Goldberg
6
6
  Maintainer: Corey Goldberg
@@ -99,7 +99,7 @@ Install `treex` from [PyPI][pypi-home] using either `pip` or `pipx`:
99
99
 
100
100
  ```
101
101
  $ treex --help
102
- usage: treex [-h] [-a] [-m] [-s] [directory]
102
+ usage: treex [-h] [-a] [-m] [-q] [-s] [directory]
103
103
 
104
104
  List directory contents as a tree with file metadata.
105
105
 
@@ -110,6 +110,7 @@ options:
110
110
  -h, --help show this help message and exit
111
111
  -a, --all show all files (including those ignored by Git)
112
112
  -m, --modified show file modification times
113
+ -q, --quiet don't show file metadata
113
114
  -s, --summary show summary only
114
115
  ```
115
116
 
@@ -74,7 +74,7 @@ Install `treex` from [PyPI][pypi-home] using either `pip` or `pipx`:
74
74
 
75
75
  ```
76
76
  $ treex --help
77
- usage: treex [-h] [-a] [-m] [-s] [directory]
77
+ usage: treex [-h] [-a] [-m] [-q] [-s] [directory]
78
78
 
79
79
  List directory contents as a tree with file metadata.
80
80
 
@@ -85,6 +85,7 @@ options:
85
85
  -h, --help show this help message and exit
86
86
  -a, --all show all files (including those ignored by Git)
87
87
  -m, --modified show file modification times
88
+ -q, --quiet don't show file metadata
88
89
  -s, --summary show summary only
89
90
  ```
90
91
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "treex-cli"
7
- version = "0.1.4"
7
+ version = "0.1.5"
8
8
  description="List directory contents as a tree with file metadata"
9
9
  license = "MIT"
10
10
  license-files = ["LICENSE"]
@@ -147,6 +147,7 @@ def _collect_tree(
147
147
  stats,
148
148
  gitignore,
149
149
  rows,
150
+ show_metadata,
150
151
  show_modified,
151
152
  ):
152
153
  """Walk the tree once and collect the output rows."""
@@ -169,22 +170,29 @@ def _collect_tree(
169
170
  stats,
170
171
  gitignore,
171
172
  rows,
173
+ show_metadata,
172
174
  show_modified,
173
175
  )
174
176
  elif entry.is_file():
175
177
  stats["files"] += 1
176
- size_text, info, size, modified = _file_metadata(entry)
177
- stats["total_size"] += size
178
- timestamp = modified if show_modified else None
179
- rows.append((tree_name, (size_text, info, timestamp)))
178
+ if show_metadata:
179
+ size_text, info, size, modified = _file_metadata(entry)
180
+ stats["total_size"] += size
181
+ timestamp = modified if show_modified else None
182
+ rows.append((tree_name, (size_text, info, timestamp)))
183
+ else:
184
+ stats["total_size"] = None
185
+ rows.append((tree_name, None))
180
186
 
181
187
 
182
188
  def print_summary(stats):
183
- print(
184
- f"{stats['directories']:,} directories • "
185
- f"{stats['files']:,} files • "
186
- f"{_format_size(stats['total_size'])}"
187
- )
189
+ directories = stats["directories"]
190
+ files = stats["files"]
191
+ total_size = stats["total_size"]
192
+ summary = f"{directories:,} directories • {files:,} files"
193
+ if total_size:
194
+ summary += f" • {_format_size(total_size)}"
195
+ print(summary)
188
196
 
189
197
 
190
198
  def print_tree(
@@ -192,6 +200,7 @@ def print_tree(
192
200
  prefix="",
193
201
  stats=None,
194
202
  gitignore=None,
203
+ show_metadata=True,
195
204
  show_modified=False,
196
205
  show_tree=True,
197
206
  ):
@@ -200,7 +209,15 @@ def print_tree(
200
209
  stats = {"directories": 0, "files": 0, "total_size": 0}
201
210
  rows = []
202
211
  # Walk the filesystem once and collect the output
203
- _collect_tree(Path(directory), prefix, stats, gitignore, rows, show_modified)
212
+ _collect_tree(
213
+ Path(directory),
214
+ prefix,
215
+ stats,
216
+ gitignore,
217
+ rows,
218
+ show_metadata,
219
+ show_modified,
220
+ )
204
221
  if show_tree:
205
222
  # Align file metadata with the longest tree/name
206
223
  max_tree_name_width = max(
@@ -243,6 +260,12 @@ def parse_args(argv=None):
243
260
  action="store_true",
244
261
  help="show file modification times",
245
262
  )
263
+ parser.add_argument(
264
+ "-q",
265
+ "--quiet",
266
+ action="store_true",
267
+ help="don't show file metadata",
268
+ )
246
269
  parser.add_argument(
247
270
  "-s",
248
271
  "--summary",
@@ -261,11 +284,13 @@ def main():
261
284
  # Only initialize Git support if it will be used
262
285
  gitignore = None if args.all else GitIgnore(path)
263
286
  show_tree = not args.summary
287
+ show_metadata = not args.quiet
264
288
  if show_tree:
265
289
  print(path)
266
290
  stats = print_tree(
267
291
  path,
268
292
  gitignore=gitignore,
293
+ show_metadata=show_metadata,
269
294
  show_modified=args.modified,
270
295
  show_tree=show_tree,
271
296
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: treex-cli
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: List directory contents as a tree with file metadata
5
5
  Author: Corey Goldberg
6
6
  Maintainer: Corey Goldberg
@@ -99,7 +99,7 @@ Install `treex` from [PyPI][pypi-home] using either `pip` or `pipx`:
99
99
 
100
100
  ```
101
101
  $ treex --help
102
- usage: treex [-h] [-a] [-m] [-s] [directory]
102
+ usage: treex [-h] [-a] [-m] [-q] [-s] [directory]
103
103
 
104
104
  List directory contents as a tree with file metadata.
105
105
 
@@ -110,6 +110,7 @@ options:
110
110
  -h, --help show this help message and exit
111
111
  -a, --all show all files (including those ignored by Git)
112
112
  -m, --modified show file modification times
113
+ -q, --quiet don't show file metadata
113
114
  -s, --summary show summary only
114
115
  ```
115
116
 
File without changes
File without changes