File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ def get_args() -> argparse.Namespace:
2222 "-a" ,
2323 "--artifacts-base-dir" ,
2424 required = True ,
25- type = helpers .check_dir_arg ,
25+ type = helpers .check_dir_arg_keep ,
2626 help = "Path to a directory with testing artifacts" ,
2727 )
2828 return parser .parse_args ()
@@ -42,7 +42,7 @@ def main() -> int:
4242
4343 state_dir = pl .Path (socket_env ).parent
4444 cluster_obj = clusterlib .ClusterLib (state_dir = state_dir )
45- location = pl . Path ( args .artifacts_base_dir ). expanduser (). resolve ()
45+ location = args .artifacts_base_dir
4646 balance , rewards = testnet_cleanup .addresses_info (cluster_obj = cluster_obj , location = location )
4747 LOGGER .info (f"Uncleaned balance: { balance } Lovelace ({ balance / 1_000_000 } ADA)" )
4848 LOGGER .info (f"Uncleaned rewards: { rewards } Lovelace ({ balance / 1_000_000 } ADA)" )
Original file line number Diff line number Diff line change @@ -221,6 +221,23 @@ def check_dir_arg(dir_path: str) -> pl.Path | None:
221221 return abs_path
222222
223223
224+ def check_dir_arg_keep (dir_path : str ) -> pl .Path | None :
225+ """Check that the dir passed as argparse parameter is a valid existing dir.
226+
227+ Keep the original path instead resolving it to absolute.
228+ """
229+ if not dir_path :
230+ return None
231+ orig_path = pl .Path (dir_path )
232+ abs_path = orig_path .expanduser ().resolve ()
233+ if not (abs_path .exists () and abs_path .is_dir ()):
234+ msg = f"check_dir_arg: directory '{ dir_path } ' doesn't exist"
235+ raise argparse .ArgumentTypeError (msg )
236+ if dir_path .startswith ("~" ):
237+ orig_path .expanduser ()
238+ return orig_path
239+
240+
224241def check_file_arg (file_path : str ) -> pl .Path | None :
225242 """Check that the file passed as argparse parameter is a valid existing file."""
226243 if not file_path :
You can’t perform that action at this time.
0 commit comments