@@ -132,11 +132,15 @@ def bucket_name_part(length: int) -> str:
132132 logger .info ('name_part: %s' , name_part )
133133 return name_part
134134
135+
135136T = TypeVar ('T' )
137+
138+
136139def wrap_iterables (generators : list [Iterable [T ]]):
137140 for g in generators :
138141 yield from g
139142
143+
140144@dataclass
141145class Api :
142146 account_id : str
@@ -224,20 +228,26 @@ def clean_buckets(self, quick=False):
224228 TooManyRequests ,
225229 max_tries = 8 ,
226230 )
227- def clean_bucket (self , bucket_object : Bucket | str , only_files : bool = False , only_folders : list [str ] | None = None , ignore_retentions : bool = False ):
231+ def clean_bucket (
232+ self ,
233+ bucket_object : Bucket | str ,
234+ only_files : bool = False ,
235+ only_folders : list [str ] | None = None ,
236+ ignore_retentions : bool = False ,
237+ ):
228238 """
229239 Clean contents of bucket, by default also deleting the bucket.
230240
231- Args:
232- bucket (Bucket | str): Bucket object or name
233- only_files (bool): If to only delete files and not the bucket
241+ Args:
242+ bucket (Bucket | str): Bucket object or name
243+ only_files (bool): If to only delete files and not the bucket
234244 only_folders (list[str] | None): If not None, filter to only files in given folders.
235245 ignore_retentions (bool): If deletion should happen regardless of files' retention mode.
236246 """
237247 bucket : Bucket
238248 if isinstance (bucket_object , str ):
239249 bucket = self .api .get_bucket_by_name (bucket_object )
240- else :
250+ else :
241251 bucket = bucket_object
242252
243253 if not only_files :
@@ -253,7 +263,16 @@ def clean_bucket(self, bucket_object: Bucket | str, only_files: bool = False, on
253263
254264 file_versions : Iterable [Any ]
255265 if only_folders :
256- file_versions = wrap_iterables ([bucket .ls (latest_only = False , recursive = True , folder_to_list = folder ,) for folder in only_folders ])
266+ file_versions = wrap_iterables (
267+ [
268+ bucket .ls (
269+ latest_only = False ,
270+ recursive = True ,
271+ folder_to_list = folder ,
272+ )
273+ for folder in only_folders
274+ ]
275+ )
257276 else :
258277 file_versions = bucket .ls (latest_only = False , recursive = True )
259278
0 commit comments