@@ -58,11 +58,11 @@ def get_buckets(self, transport, bucket_type=None, timeout=None):
58
58
"""
59
59
_validate_timeout (timeout )
60
60
if bucket_type :
61
- bucketfn = lambda name : bucket_type . bucket ( name )
61
+ bucketfn = self . _bucket_type_bucket_builder
62
62
else :
63
- bucketfn = lambda name : self .bucket ( name )
63
+ bucketfn = self ._default_type_bucket_builder
64
64
65
- return [bucketfn (bytes_to_str (name )) for name in
65
+ return [bucketfn (bytes_to_str (name ), bucket_type ) for name in
66
66
transport .get_buckets (bucket_type = bucket_type ,
67
67
timeout = timeout )]
68
68
@@ -103,9 +103,9 @@ def stream_buckets(self, bucket_type=None, timeout=None):
103
103
"""
104
104
_validate_timeout (timeout )
105
105
if bucket_type :
106
- bucketfn = lambda name : bucket_type . bucket ( name )
106
+ bucketfn = self . _bucket_type_bucket_builder
107
107
else :
108
- bucketfn = lambda name : self .bucket ( name )
108
+ bucketfn = self ._default_type_bucket_builder
109
109
110
110
resource = self ._acquire ()
111
111
transport = resource .object
@@ -114,7 +114,7 @@ def stream_buckets(self, bucket_type=None, timeout=None):
114
114
stream .attach (resource )
115
115
try :
116
116
for bucket_list in stream :
117
- bucket_list = [bucketfn (bytes_to_str (name ))
117
+ bucket_list = [bucketfn (bytes_to_str (name ), bucket_type )
118
118
for name in bucket_list ]
119
119
if len (bucket_list ) > 0 :
120
120
yield bucket_list
@@ -1000,6 +1000,27 @@ def update_datatype(self, datatype, w=None, dw=None, pw=None,
1000
1000
timeout = timeout ,
1001
1001
include_context = include_context )
1002
1002
1003
+ def _bucket_type_bucket_builder (self , name , bucket_type ):
1004
+ """
1005
+ Build a bucket from a bucket type
1006
+
1007
+ :param name: Bucket name
1008
+ :param bucket_type: A bucket type
1009
+ :return: A bucket object
1010
+ """
1011
+ return bucket_type .bucket (name )
1012
+
1013
+ def _default_type_bucket_builder (self , name , unused ):
1014
+ """
1015
+ Build a bucket for the default bucket type
1016
+
1017
+ :param name: Default bucket name
1018
+ :param unused: Unused
1019
+ :return: A bucket object
1020
+ """
1021
+ del unused # Ignored parameters.
1022
+ return self .bucket (name )
1023
+
1003
1024
@retryable
1004
1025
def _fetch_datatype (self , transport , bucket , key , r = None , pr = None ,
1005
1026
basic_quorum = None , notfound_ok = None ,
@@ -1052,6 +1073,6 @@ def _validate_timeout(timeout):
1052
1073
Raises an exception if the given timeout is an invalid value.
1053
1074
"""
1054
1075
if not (timeout is None or
1055
- ((type (timeout ) == int or (PY2 and type (timeout ) == long ))
1056
- and timeout > 0 )):
1076
+ ((type (timeout ) == int or (PY2 and type (timeout ) == long )) and
1077
+ timeout > 0 )):
1057
1078
raise ValueError ("timeout must be a positive integer" )
0 commit comments