本文整理汇总了Python中cache.Cache.s3listcontents方法的典型用法代码示例。如果您正苦于以下问题:Python Cache.s3listcontents方法的具体用法?Python Cache.s3listcontents怎么用?Python Cache.s3listcontents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache.Cache
的用法示例。
在下文中一共展示了Cache.s3listcontents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: S3Iterable
# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import s3listcontents [as 别名]
class S3Iterable(object):
def __init__(self):
'''
Subclasses must handle setting up config including:
* bucketname
* parser
'''
self.bucketname = None
self.parser = None
self.cache = Cache()
self.iterator = iter
self.decompress = None
def subsets(self):
l = self.cache.s3listcontents(self.bucketname)
o = []
for i in l:
o.append(i.key)
return o
def iter(self, subset):
h = self.cache.directhandle(self.bucketname, subset, decompress=self.decompress)
for l in self.iterator(h):
if self.parser is None:
yield l
else:
yield self.parser(l)
def filter(self, subset, f):
h = self.cache.directhandle(self.bucketname, subset, decompress=self.decompress)
for l in self.iterator(h):
if self.parser is None:
j = l
else:
j = self.parser(l)
if f(j):
yield j
def byid(self, index):
(subset, i) = index
h = self.cache.directhandle(self.bucketname, subset, decompress=self.decompress)
c = 0
for l in self.iterator(h):
if c == i:
if self.parser is None:
return l
else:
return self.parser(l)
else:
c += 1
return None
def display(self, items):
for i in items:
print i