treex-cli 0.1.6__tar.gz → 0.1.7__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.6
3
+ Version: 0.1.7
4
4
  Summary: List directory contents as a tree with file and directory 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.6"
7
+ version = "0.1.7"
8
8
  description="List directory contents as a tree with file and directory metadata"
9
9
  license = "MIT"
10
10
  license-files = ["LICENSE"]
@@ -14,6 +14,7 @@ filesystem is scanned normally without Git filtering.
14
14
 
15
15
  import argparse
16
16
  import subprocess
17
+ import sys
17
18
  from contextlib import suppress
18
19
  from datetime import datetime
19
20
  from pathlib import Path
@@ -199,8 +200,10 @@ def print_summary(stats):
199
200
  directories = stats["directories"]
200
201
  files = stats["files"]
201
202
  total_size = stats["total_size"]
202
- summary = f"{directories:,} directories • {files:,} files"
203
- if total_size:
203
+ directory_label = "directory" if directories == 1 else "directories"
204
+ file_label = "file" if files == 1 else "files"
205
+ summary = f"{directories:,} {directory_label} • {files:,} {file_label}"
206
+ if total_size is not None:
204
207
  summary += f" • {_format_size(total_size)}"
205
208
  print(summary)
206
209
 
@@ -289,28 +292,33 @@ def parse_args(argv=None):
289
292
 
290
293
 
291
294
  def main():
292
- args = parse_args()
293
- path = args.directory
294
- if not path.is_dir():
295
- print(f"Not a directory: {path}")
296
- return 1
297
- # Only initialize Git support if it will be used
298
- gitignore = None if args.all else GitIgnore(path)
299
- show_tree = not args.summary
300
- show_metadata = not args.quiet
301
- if show_tree:
302
- print(path)
303
- stats = print_tree(
304
- path,
305
- gitignore=gitignore,
306
- show_metadata=show_metadata,
307
- show_modified=args.modified,
308
- show_tree=show_tree,
309
- )
310
- if show_tree:
311
- print()
312
- print_summary(stats)
313
- return 0
295
+ try:
296
+ args = parse_args()
297
+ path = args.directory
298
+ if not path.is_dir():
299
+ print(f"Not a directory: {path}", file=sys.stderr)
300
+ return 1
301
+ # Only initialize Git support if it will be used
302
+ gitignore = None if args.all else GitIgnore(path)
303
+ show_tree = not args.summary
304
+ show_metadata = not args.quiet
305
+ if show_tree:
306
+ print(path)
307
+ stats = print_tree(
308
+ path,
309
+ gitignore=gitignore,
310
+ show_metadata=show_metadata,
311
+ show_modified=args.modified,
312
+ show_tree=show_tree,
313
+ )
314
+ if show_tree:
315
+ print()
316
+ print_summary(stats)
317
+ except KeyboardInterrupt:
318
+ print("\nInterrupted", file=sys.stderr)
319
+ return 130
320
+ else:
321
+ return 0
314
322
 
315
323
 
316
324
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: treex-cli
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: List directory contents as a tree with file and directory metadata
5
5
  Author: Corey Goldberg
6
6
  Maintainer: Corey Goldberg
File without changes
File without changes
File without changes