@@ -241,7 +241,7 @@ def ensure_present(
241
241
return True
242
242
243
243
@staticmethod
244
- def ensure_absent (name , volumes = None , tmphlq = None ):
244
+ def ensure_absent (name , volumes = None , tmphlq = None , noscratch = False ):
245
245
"""Deletes provided data set if it exists.
246
246
247
247
Parameters
@@ -252,13 +252,15 @@ def ensure_absent(name, volumes=None, tmphlq=None):
252
252
The volumes the data set may reside on.
253
253
tmphlq : str
254
254
High Level Qualifier for temporary datasets.
255
+ noscratch : bool
256
+ If True, the data set is uncataloged but not physically removed from the volume.
255
257
256
258
Returns
257
259
-------
258
260
bool
259
261
Indicates if changes were made.
260
262
"""
261
- changed , present = DataSet .attempt_catalog_if_necessary_and_delete (name , volumes , tmphlq = tmphlq )
263
+ changed , present = DataSet .attempt_catalog_if_necessary_and_delete (name , volumes , tmphlq = tmphlq , noscratch = noscratch )
262
264
return changed
263
265
264
266
# ? should we do additional check to ensure member was actually created?
@@ -1003,7 +1005,7 @@ def attempt_catalog_if_necessary(name, volumes, tmphlq=None):
1003
1005
return present , changed
1004
1006
1005
1007
@staticmethod
1006
- def attempt_catalog_if_necessary_and_delete (name , volumes , tmphlq = None ):
1008
+ def attempt_catalog_if_necessary_and_delete (name , volumes , tmphlq = None , noscratch = False ):
1007
1009
"""Attempts to catalog a data set if not already cataloged, then deletes
1008
1010
the data set.
1009
1011
This is helpful when a data set currently cataloged is not the data
@@ -1019,6 +1021,8 @@ def attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=None):
1019
1021
The volumes the data set may reside on.
1020
1022
tmphlq : str
1021
1023
High Level Qualifier for temporary datasets.
1024
+ noscratch : bool
1025
+ If True, the data set is uncataloged but not physically removed from the volume.
1022
1026
1023
1027
Returns
1024
1028
-------
@@ -1039,7 +1043,7 @@ def attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=None):
1039
1043
present = DataSet .data_set_cataloged (name , volumes , tmphlq = tmphlq )
1040
1044
1041
1045
if present :
1042
- DataSet .delete (name )
1046
+ DataSet .delete (name , noscratch = noscratch )
1043
1047
changed = True
1044
1048
present = False
1045
1049
else :
@@ -1074,7 +1078,7 @@ def attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=None):
1074
1078
1075
1079
if present :
1076
1080
try :
1077
- DataSet .delete (name )
1081
+ DataSet .delete (name , noscratch = noscratch )
1078
1082
except DatasetDeleteError :
1079
1083
try :
1080
1084
DataSet .uncatalog (name , tmphlq = tmphlq )
@@ -1101,14 +1105,14 @@ def attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=None):
1101
1105
present = DataSet .data_set_cataloged (name , volumes , tmphlq = tmphlq )
1102
1106
1103
1107
if present :
1104
- DataSet .delete (name )
1108
+ DataSet .delete (name , noscratch = noscratch )
1105
1109
changed = True
1106
1110
present = False
1107
1111
else :
1108
1112
present = DataSet .data_set_cataloged (name , None , tmphlq = tmphlq )
1109
1113
if present :
1110
1114
try :
1111
- DataSet .delete (name )
1115
+ DataSet .delete (name , noscratch = noscratch )
1112
1116
changed = True
1113
1117
present = False
1114
1118
except DatasetDeleteError :
@@ -1414,7 +1418,7 @@ def create(
1414
1418
return changed
1415
1419
1416
1420
@staticmethod
1417
- def delete (name ):
1421
+ def delete (name , noscratch = False ):
1418
1422
"""A wrapper around zoautil_py
1419
1423
datasets.delete() to raise exceptions on failure.
1420
1424
@@ -1428,7 +1432,7 @@ def delete(name):
1428
1432
DatasetDeleteError
1429
1433
When data set deletion fails.
1430
1434
"""
1431
- rc = datasets .delete (name )
1435
+ rc = datasets .delete (name , noscratch = noscratch )
1432
1436
if rc > 0 :
1433
1437
raise DatasetDeleteError (name , rc )
1434
1438
@@ -2721,7 +2725,7 @@ def ensure_present(self, tmp_hlq=None, replace=False, force=False):
2721
2725
self .set_state ("present" )
2722
2726
return rc
2723
2727
2724
- def ensure_absent (self , tmp_hlq = None ):
2728
+ def ensure_absent (self , tmp_hlq = None , noscratch = False ):
2725
2729
"""Removes the data set.
2726
2730
2727
2731
Parameters
@@ -2734,7 +2738,7 @@ def ensure_absent(self, tmp_hlq=None):
2734
2738
int
2735
2739
Indicates if changes were made.
2736
2740
"""
2737
- rc = DataSet .ensure_absent (self .name , self .volumes , tmphlq = tmp_hlq )
2741
+ rc = DataSet .ensure_absent (self .name , self .volumes , tmphlq = tmp_hlq , noscratch = noscratch )
2738
2742
if rc == 0 :
2739
2743
self .set_state ("absent" )
2740
2744
return rc
0 commit comments