Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def bucket_items_side_effect(*args, **kwargs):
bucket = args[0].name # self
if bucket == 'foo':
return [
datalab.storage._item.Item(bucket, 'item1', context=context),
datalab.storage._item.Item(bucket, 'item2', context=context),
datalab.storage._item.Item(bucket, 'item3', context=context),
]
elif bucket == 'bar':
return [
datalab.storage._item.Item(bucket, 'object1', context=context),
datalab.storage._item.Item(bucket, 'object3', context=context),
]
else:
return []
return bucket_items_side_effect
def bucket_items_side_effect(*args, **kwargs):
bucket = args[0].name # self
if bucket == 'foo':
return [
datalab.storage._item.Item(bucket, 'item1', context=context),
datalab.storage._item.Item(bucket, 'item2', context=context),
datalab.storage._item.Item(bucket, 'item3', context=context),
]
elif bucket == 'bar':
return [
datalab.storage._item.Item(bucket, 'object1', context=context),
datalab.storage._item.Item(bucket, 'object3', context=context),
]
else:
return []
return bucket_items_side_effect
def bucket_items_side_effect(*args, **kwargs):
bucket = args[0].name # self
if bucket == 'foo':
return [
datalab.storage._item.Item(bucket, 'item1', context=context),
datalab.storage._item.Item(bucket, 'item2', context=context),
datalab.storage._item.Item(bucket, 'item3', context=context),
]
elif bucket == 'bar':
return [
datalab.storage._item.Item(bucket, 'object1', context=context),
datalab.storage._item.Item(bucket, 'object3', context=context),
]
else:
return []
return bucket_items_side_effect
def item(self, key):
"""Retrieves an Item object for the specified key in this bucket.
The item need not exist.
Args:
key: the key of the item within the bucket.
Returns:
An Item instance representing the specified key.
"""
return _item.Item(self._name, key, context=self._context)
Args:
new_key: the new key to copy this item to.
bucket: the bucket of the new item; if None (the default) use the same bucket.
Returns:
An Item corresponding to new key.
Raises:
Exception if there was an error copying the item.
"""
if bucket is None:
bucket = self._bucket
try:
new_info = self._api.objects_copy(self._bucket, self._key, bucket, new_key)
except Exception as e:
raise e
return Item(bucket, new_key, new_info, context=self._context)