当前位置: 首页>>代码示例>>Python>>正文


Python BucketLister.list_objects方法代码示例

本文整理汇总了Python中awscli.customizations.s3.utils.BucketLister.list_objects方法的典型用法代码示例。如果您正苦于以下问题:Python BucketLister.list_objects方法的具体用法?Python BucketLister.list_objects怎么用?Python BucketLister.list_objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在awscli.customizations.s3.utils.BucketLister的用法示例。


在下文中一共展示了BucketLister.list_objects方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: list_objects

# 需要导入模块: from awscli.customizations.s3.utils import BucketLister [as 别名]
# 或者: from awscli.customizations.s3.utils.BucketLister import list_objects [as 别名]
 def list_objects(self, s3_path, dir_op):
     """
     This function yields the appropriate object or objects under a
     common prefix depending if the operation is on objects under a
     common prefix.  It yields the file's source path, size, and last
     update.
     """
     # Short circuit path: if we are not recursing into the s3
     # bucket and a specific path was given, we can just yield
     # that path and not have to call any operation in s3.
     bucket, prefix = find_bucket_key(s3_path)
     if not dir_op and prefix:
         yield self._list_single_object(s3_path)
     else:
         lister = BucketLister(self._client)
         for key in lister.list_objects(bucket=bucket, prefix=prefix,
                                        page_size=self.page_size):
             source_path, response_data = key
             if response_data['Size'] == 0 and source_path.endswith('/'):
                 if self.operation_name == 'delete':
                     # This is to filter out manually created folders
                     # in S3.  They have a size zero and would be
                     # undesirably downloaded.  Local directories
                     # are automatically created when they do not
                     # exist locally.  But user should be able to
                     # delete them.
                     yield source_path, response_data
             elif not dir_op and s3_path != source_path:
                 pass
             else:
                 yield source_path, response_data
开发者ID:hirose31,项目名称:aws-cli,代码行数:33,代码来源:filegenerator.py

示例2: test_urlencoded_with_unicode_keys

# 需要导入模块: from awscli.customizations.s3.utils import BucketLister [as 别名]
# 或者: from awscli.customizations.s3.utils.BucketLister import list_objects [as 别名]
 def test_urlencoded_with_unicode_keys(self):
     now = mock.sentinel.now
     self.operation.paginate.return_value = [
         (None, {'Contents': [
             {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': '%E2%9C%93', 'Size': 1}]}),
     ]
     lister = BucketLister(self.operation, self.endpoint, self.date_parser)
     objects = list(lister.list_objects(bucket='foo'))
     # And note how it's been converted to '\r'.
     self.assertEqual(objects, [(u'foo/\u2713', 1, now)])
开发者ID:DocFrank,项目名称:aws-cli,代码行数:13,代码来源:test_utils.py

示例3: test_urlencoded_with_unicode_keys

# 需要导入模块: from awscli.customizations.s3.utils import BucketLister [as 别名]
# 或者: from awscli.customizations.s3.utils.BucketLister import list_objects [as 别名]
 def test_urlencoded_with_unicode_keys(self):
     now = mock.sentinel.now
     self.client.get_paginator.return_value.paginate = self.fake_paginate
     self.responses = [
         {'Contents': [
             {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': '%E2%9C%93', 'Size': 1}]},
     ]
     lister = BucketLister(self.client, self.date_parser)
     objects = list(lister.list_objects(bucket='foo'))
     # And note how it's been converted to '\r'.
     self.assertEqual(objects, [(u'foo/\u2713', 1, now)])
开发者ID:Frame02,项目名称:aws-cli,代码行数:14,代码来源:test_utils.py

示例4: test_urlencoded_keys

# 需要导入模块: from awscli.customizations.s3.utils import BucketLister [as 别名]
# 或者: from awscli.customizations.s3.utils.BucketLister import list_objects [as 别名]
 def test_urlencoded_keys(self):
     # In order to workaround control chars being in key names,
     # we force the urlencoding of the key names and we decode
     # them before yielding them.  For example, note the %0D
     # in bar.txt:
     now = mock.sentinel.now
     self.operation.paginate.return_value = [
         (None, {'Contents': [
             {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': 'bar%0D.txt', 'Size': 1}]}),
     ]
     lister = BucketLister(self.operation, self.endpoint, self.date_parser)
     objects = list(lister.list_objects(bucket='foo'))
     # And note how it's been converted to '\r'.
     self.assertEqual(objects, [('foo/bar\r.txt', 1, now)])
开发者ID:DocFrank,项目名称:aws-cli,代码行数:17,代码来源:test_utils.py

示例5: test_list_objects

# 需要导入模块: from awscli.customizations.s3.utils import BucketLister [as 别名]
# 或者: from awscli.customizations.s3.utils.BucketLister import list_objects [as 别名]
 def test_list_objects(self):
     now = mock.sentinel.now
     self.operation.paginate.return_value = [
         (None, {'Contents': [
             {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': 'a', 'Size': 1},
             {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': 'b', 'Size': 2},]}),
         (None, {'Contents': [
             {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': 'c', 'Size': 3},
         ]}),
     ]
     lister = BucketLister(self.operation, self.endpoint, self.date_parser)
     objects = list(lister.list_objects(bucket='foo'))
     self.assertEqual(objects, [('foo/a', 1, now), ('foo/b', 2, now),
                                ('foo/c', 3, now)])
开发者ID:DocFrank,项目名称:aws-cli,代码行数:19,代码来源:test_utils.py

示例6: test_list_objects_passes_in_extra_args

# 需要导入模块: from awscli.customizations.s3.utils import BucketLister [as 别名]
# 或者: from awscli.customizations.s3.utils.BucketLister import list_objects [as 别名]
 def test_list_objects_passes_in_extra_args(self):
     self.client.get_paginator.return_value.paginate.return_value = [
         {'Contents': [
             {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': 'mykey', 'Size': 3}
         ]}
     ]
     lister = BucketLister(self.client, self.date_parser)
     list(
         lister.list_objects(
             bucket='mybucket', extra_args={'RequestPayer': 'requester'}
         )
     )
     self.client.get_paginator.return_value.paginate.assert_called_with(
         Bucket='mybucket', PaginationConfig={'PageSize': None},
         RequestPayer='requester'
     )
开发者ID:aws,项目名称:aws-cli,代码行数:19,代码来源:test_utils.py

示例7: test_list_objects

# 需要导入模块: from awscli.customizations.s3.utils import BucketLister [as 别名]
# 或者: from awscli.customizations.s3.utils.BucketLister import list_objects [as 别名]
 def test_list_objects(self):
     now = mock.sentinel.now
     self.client.get_paginator.return_value.paginate = self.fake_paginate
     self.responses = [
         {'Contents': [
             {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': 'a', 'Size': 1},
             {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': 'b', 'Size': 2}]},
         {'Contents': [
             {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': 'c', 'Size': 3}]}
     ]
     lister = BucketLister(self.client, self.date_parser)
     objects = list(lister.list_objects(bucket='foo'))
     self.assertEqual(objects, [('foo/a', 1, now), ('foo/b', 2, now),
                                ('foo/c', 3, now)])
开发者ID:Frame02,项目名称:aws-cli,代码行数:19,代码来源:test_utils.py

示例8: test_urlencoded_keys

# 需要导入模块: from awscli.customizations.s3.utils import BucketLister [as 别名]
# 或者: from awscli.customizations.s3.utils.BucketLister import list_objects [as 别名]
 def test_urlencoded_keys(self):
     # In order to workaround control chars being in key names,
     # we force the urlencoding of the key names and we decode
     # them before yielding them.  For example, note the %0D
     # in bar.txt:
     now = mock.sentinel.now
     self.client.get_paginator.return_value.paginate = self.fake_paginate
     individual_response_element = {
         'LastModified': '2014-02-27T04:20:38.000Z',
         'Key': 'bar%0D.txt', 'Size': 1}
     self.responses = [
         {'Contents': [individual_response_element]}
     ]
     lister = BucketLister(self.client, self.date_parser)
     objects = list(lister.list_objects(bucket='foo'))
     # And note how it's been converted to '\r'.
     self.assertEqual(
         objects, [('foo/bar\r.txt', individual_response_element)])
     self.assertEqual(individual_response_element['LastModified'], now)
开发者ID:hirose31,项目名称:aws-cli,代码行数:21,代码来源:test_utils.py

示例9: test_list_objects

# 需要导入模块: from awscli.customizations.s3.utils import BucketLister [as 别名]
# 或者: from awscli.customizations.s3.utils.BucketLister import list_objects [as 别名]
 def test_list_objects(self):
     now = mock.sentinel.now
     self.client.get_paginator.return_value.paginate = self.fake_paginate
     individual_response_elements = [
         {'LastModified': '2014-02-27T04:20:38.000Z',
          'Key': 'a', 'Size': 1},
         {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': 'b', 'Size': 2},
         {'LastModified': '2014-02-27T04:20:38.000Z',
              'Key': 'c', 'Size': 3}
     ]
     self.responses = [
         {'Contents': individual_response_elements[0:2]},
         {'Contents': [individual_response_elements[2]]}
     ]
     lister = BucketLister(self.client, self.date_parser)
     objects = list(lister.list_objects(bucket='foo'))
     self.assertEqual(objects,
         [('foo/a', individual_response_elements[0]),
          ('foo/b', individual_response_elements[1]),
          ('foo/c', individual_response_elements[2])])
     for individual_response in individual_response_elements:
         self.assertEqual(individual_response['LastModified'], now)
开发者ID:hirose31,项目名称:aws-cli,代码行数:25,代码来源:test_utils.py

示例10: test_list_objects

# 需要导入模块: from awscli.customizations.s3.utils import BucketLister [as 别名]
# 或者: from awscli.customizations.s3.utils.BucketLister import list_objects [as 别名]
 def test_list_objects(self):
     now = mock.sentinel.now
     self.client.get_paginator.return_value.paginate = self.fake_paginate
     individual_response_elements = [
         {"LastModified": "2014-02-27T04:20:38.000Z", "Key": "a", "Size": 1},
         {"LastModified": "2014-02-27T04:20:38.000Z", "Key": "b", "Size": 2},
         {"LastModified": "2014-02-27T04:20:38.000Z", "Key": "c", "Size": 3},
     ]
     self.responses = [
         {"Contents": individual_response_elements[0:2]},
         {"Contents": [individual_response_elements[2]]},
     ]
     lister = BucketLister(self.client, self.date_parser)
     objects = list(lister.list_objects(bucket="foo"))
     self.assertEqual(
         objects,
         [
             ("foo/a", individual_response_elements[0]),
             ("foo/b", individual_response_elements[1]),
             ("foo/c", individual_response_elements[2]),
         ],
     )
     for individual_response in individual_response_elements:
         self.assertEqual(individual_response["LastModified"], now)
开发者ID:aws,项目名称:aws-cli,代码行数:26,代码来源:test_utils.py


注:本文中的awscli.customizations.s3.utils.BucketLister.list_objects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。