File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 11## Version 0.5.0 (in development)
22
3+ ### Enhancements
4+
5+ * Added CLI option ` --traceback ` . [ #57 ]
6+
7+
38## Version 0.4.1 (from 2024-02-13)
49
510### Fixes
Original file line number Diff line number Diff line change @@ -112,3 +112,25 @@ def test_some_slices_and_no_target(self):
112112 "Error: Missing 'target_dir' in configuration\n " , result .output
113113 )
114114 self .assertFalse (FileObj ("memory://target.zarr" ).exists ())
115+
116+ def test_some_slices_and_no_target_with_traceback (self ):
117+ make_test_dataset (uri = "memory://slice-1.zarr" )
118+ make_test_dataset (uri = "memory://slice-2.zarr" )
119+ make_test_dataset (uri = "memory://slice-3.zarr" )
120+
121+ runner = CliRunner ()
122+ # noinspection PyTypeChecker
123+ result = runner .invoke (
124+ zappend ,
125+ [
126+ "--traceback" ,
127+ "memory://slice-1.zarr" ,
128+ "memory://slice-2.zarr" ,
129+ "memory://slice-3.zarr" ,
130+ ],
131+ )
132+ print (result .output )
133+ self .assertEqual (1 , result .exit_code )
134+ self .assertIn ("Traceback (most recent call last):\n " , result .output )
135+ self .assertIn ("Error: Missing 'target_dir' in configuration\n " , result .output )
136+ self .assertFalse (FileObj ("memory://target.zarr" ).exists ())
Original file line number Diff line number Diff line change 11# Copyright © 2024 Norman Fomferra
22# Permissions are hereby granted under the terms of the MIT License:
33# https://opensource.org/licenses/MIT.
4+ import sys
45
56import click
67
2829 is_flag = True ,
2930 help = "Run the tool without creating, changing," " or deleting any files." ,
3031)
32+ @click .option (
33+ "--traceback" ,
34+ is_flag = True ,
35+ help = "Show Python traceback on error." ,
36+ )
3137@click .option (
3238 "--version" ,
3339 is_flag = True ,
@@ -44,6 +50,7 @@ def zappend(
4450 config : tuple [str , ...],
4551 target : str | None ,
4652 dry_run : bool ,
53+ traceback : bool ,
4754 version : bool ,
4855 help_config : str | None ,
4956):
@@ -73,6 +80,10 @@ def zappend(
7380 try :
7481 zappend (slices , config = config , target_dir = target , dry_run = dry_run )
7582 except BaseException as e :
83+ if traceback :
84+ import traceback as tb
85+
86+ tb .print_exc (file = sys .stderr )
7687 raise click .ClickException (f"{ e } " ) from e
7788
7889
You can’t perform that action at this time.
0 commit comments