本文整理汇总了Python中swiftclient.service.SwiftService.list方法的典型用法代码示例。如果您正苦于以下问题:Python SwiftService.list方法的具体用法?Python SwiftService.list怎么用?Python SwiftService.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类swiftclient.service.SwiftService
的用法示例。
在下文中一共展示了SwiftService.list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SwiftClient
# 需要导入模块: from swiftclient.service import SwiftService [as 别名]
# 或者: from swiftclient.service.SwiftService import list [as 别名]
class SwiftClient(object):
"""Client for Swift object/blob store of Openstack
See http://swift.openstack.org
Swift requires environment variables (OS_*) for the authentication and configuration"""
def __init__(self, container, prefix=''):
self.container = container
self.prefix = prefix
self.client = SwiftService()
def download(self, source, target):
objects = [self.prefix + '/' + source]
options = {'out_file': target}
return list(self.client.download(self.container, objects, options))
def upload(self, source, target):
object_name = self.prefix + '/' + target
objects = [SwiftUploadObject(source, object_name=object_name)]
return list(self.client.upload(self.container, objects))
def ls(self, path):
fpath = self.prefix + '/' + path + '/'
clisting = self.client.list(self.container, {'prefix': fpath})
listing = list(clisting)[0]['listing']
result = [d['name'].replace(fpath, '') for d in listing]
return result
def url(self, path=''):
return self.container + '/' + self.prefix + '/' + path