@@ -68,7 +68,8 @@ def url_for_api(info, api_name):
68
68
69
69
70
70
class Services :
71
- """ Gathers objects that provide high level logic over raw api usage. """
71
+ """Gathers objects that provide high level logic over raw api usage."""
72
+
72
73
UPLOAD_MANAGER_CLASS = staticmethod (UploadManager )
73
74
COPY_MANAGER_CLASS = staticmethod (CopyManager )
74
75
DOWNLOAD_MANAGER_CLASS = staticmethod (DownloadManager )
@@ -133,6 +134,7 @@ class handles several things that simplify the task of uploading
133
134
The class also keeps a cache of information needed to access the
134
135
service, such as auth tokens and upload URLs.
135
136
"""
137
+
136
138
BUCKET_FACTORY_CLASS = staticmethod (BucketFactory )
137
139
BUCKET_CLASS = staticmethod (Bucket )
138
140
SESSION_CLASS = staticmethod (B2Session )
@@ -272,8 +274,12 @@ def create_bucket(
272
274
replication = replication ,
273
275
)
274
276
bucket = self .BUCKET_FACTORY_CLASS .from_api_bucket_dict (self , response )
275
- assert name == bucket .name , f'API created a bucket with different name than requested: { name } != { name } '
276
- assert bucket_type == bucket .type_ , f'API created a bucket with different type than requested: { bucket_type } != { bucket .type_ } '
277
+ assert (
278
+ name == bucket .name
279
+ ), f'API created a bucket with different name than requested: { name } != { name } '
280
+ assert (
281
+ bucket_type == bucket .type_
282
+ ), f'API created a bucket with different type than requested: { bucket_type } != { bucket .type_ } '
277
283
self .cache .save_bucket (bucket )
278
284
return bucket
279
285
@@ -389,8 +395,9 @@ def delete_bucket(self, bucket):
389
395
account_id = self .account_info .get_account_id ()
390
396
self .session .delete_bucket (account_id , bucket .id_ )
391
397
392
- def list_buckets (self , bucket_name = None , bucket_id = None , * ,
393
- use_cache : bool = False ) -> Sequence [Bucket ]:
398
+ def list_buckets (
399
+ self , bucket_name = None , bucket_id = None , * , use_cache : bool = False
400
+ ) -> Sequence [Bucket ]:
394
401
"""
395
402
Call ``b2_list_buckets`` and return a list of buckets.
396
403
@@ -418,13 +425,14 @@ def list_buckets(self, bucket_name=None, bucket_id=None, *,
418
425
cached_list = self .cache .list_bucket_names_ids ()
419
426
buckets = [
420
427
self .BUCKET_CLASS (self , cache_b_id , name = cached_b_name )
421
- for cached_b_name , cache_b_id in cached_list if (
422
- (bucket_name is None or bucket_name == cached_b_name ) and
423
- (bucket_id is None or bucket_id == cache_b_id )
428
+ for cached_b_name , cache_b_id in cached_list
429
+ if (
430
+ (bucket_name is None or bucket_name == cached_b_name )
431
+ and (bucket_id is None or bucket_id == cache_b_id )
424
432
)
425
433
]
426
434
if buckets :
427
- logger .debug (" Using cached bucket list as it is not empty" )
435
+ logger .debug (' Using cached bucket list as it is not empty' )
428
436
return buckets
429
437
430
438
account_id = self .account_info .get_account_id ()
@@ -494,8 +502,8 @@ def get_download_url_for_file_name(self, bucket_name, file_name):
494
502
:param str file_name: a file name
495
503
"""
496
504
self .check_bucket_name_restrictions (bucket_name )
497
- return '{}/file/{}/{}' . format (
498
- self .account_info .get_download_url (), bucket_name , b2_url_encode (file_name )
505
+ return (
506
+ f' { self .account_info .get_download_url ()} /file/ { bucket_name } / { b2_url_encode (file_name )} '
499
507
)
500
508
501
509
# keys
@@ -524,7 +532,7 @@ def create_key(
524
532
key_name = key_name ,
525
533
valid_duration_seconds = valid_duration_seconds ,
526
534
bucket_id = bucket_id ,
527
- name_prefix = name_prefix
535
+ name_prefix = name_prefix ,
528
536
)
529
537
530
538
assert set (response ['capabilities' ]) == set (capabilities )
@@ -551,8 +559,9 @@ def delete_key_by_id(self, application_key_id: str) -> ApplicationKey:
551
559
response = self .session .delete_key (application_key_id = application_key_id )
552
560
return ApplicationKey .from_api_response (response )
553
561
554
- def list_keys (self , start_application_key_id : str | None = None
555
- ) -> Generator [ApplicationKey , None , None ]:
562
+ def list_keys (
563
+ self , start_application_key_id : str | None = None
564
+ ) -> Generator [ApplicationKey , None , None ]:
556
565
"""
557
566
List application keys. Lazily perform requests to B2 cloud and return all keys.
558
567
@@ -603,7 +612,7 @@ def get_file_info(self, file_id: str) -> FileVersion:
603
612
604
613
def get_file_info_by_name (self , bucket_name : str , file_name : str ) -> DownloadVersion :
605
614
"""
606
- Gets info about a file version. Similar to `get_file_info` but
615
+ Gets info about a file version. Similar to `get_file_info` but
607
616
takes the bucket name and file name instead of file id.
608
617
609
618
:param str bucket_name: The name of the bucket where the file resides.
0 commit comments