本文整理汇总了Python中awscli.customizations.s3.filegenerator.FileGenerator.list_files方法的典型用法代码示例。如果您正苦于以下问题:Python FileGenerator.list_files方法的具体用法?Python FileGenerator.list_files怎么用?Python FileGenerator.list_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类awscli.customizations.s3.filegenerator.FileGenerator
的用法示例。
在下文中一共展示了FileGenerator.list_files方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_list_local_files_with_unicode_chars
# 需要导入模块: from awscli.customizations.s3.filegenerator import FileGenerator [as 别名]
# 或者: from awscli.customizations.s3.filegenerator.FileGenerator import list_files [as 别名]
def test_list_local_files_with_unicode_chars(self):
p = os.path.join
open(p(self.directory, u"a"), "w").close()
open(p(self.directory, u"a\u0300"), "w").close()
open(p(self.directory, u"a\u0300-1"), "w").close()
open(p(self.directory, u"a\u03001"), "w").close()
open(p(self.directory, u"z"), "w").close()
open(p(self.directory, u"\u00e6"), "w").close()
os.mkdir(p(self.directory, u"a\u0300a"))
open(p(self.directory, u"a\u0300a", u"a"), "w").close()
open(p(self.directory, u"a\u0300a", u"z"), "w").close()
open(p(self.directory, u"a\u0300a", u"\u00e6"), "w").close()
file_generator = FileGenerator(None, None, None, None)
values = list(el[0] for el in file_generator.list_files(self.directory, dir_op=True))
expected_order = [
os.path.join(self.directory, el)
for el in [
u"a",
u"a\u0300",
u"a\u0300-1",
u"a\u03001",
u"a\u0300a%sa" % os.path.sep,
u"a\u0300a%sz" % os.path.sep,
u"a\u0300a%s\u00e6" % os.path.sep,
u"z",
u"\u00e6",
]
]
self.assertEqual(values, expected_order)
示例2: test_error_raised_on_decoding_error
# 需要导入模块: from awscli.customizations.s3.filegenerator import FileGenerator [as 别名]
# 或者: from awscli.customizations.s3.filegenerator.FileGenerator import list_files [as 别名]
def test_error_raised_on_decoding_error(self, listdir_mock):
# On Python3, sys.getdefaultencoding
file_generator = FileGenerator(None, None, None, None)
# utf-8 encoding for U+2713.
listdir_mock.return_value = [b'\xe2\x9c\x93']
with self.assertRaises(FileDecodingError):
list(file_generator.list_files(self.directory, dir_op=True))
示例3: test_list_files_is_in_sorted_order
# 需要导入模块: from awscli.customizations.s3.filegenerator import FileGenerator [as 别名]
# 或者: from awscli.customizations.s3.filegenerator.FileGenerator import list_files [as 别名]
def test_list_files_is_in_sorted_order(self):
p = os.path.join
open(p(self.directory, "test-123.txt"), "w").close()
open(p(self.directory, "test-321.txt"), "w").close()
open(p(self.directory, "test123.txt"), "w").close()
open(p(self.directory, "test321.txt"), "w").close()
os.mkdir(p(self.directory, "test"))
open(p(self.directory, "test", "foo.txt"), "w").close()
file_generator = FileGenerator(None, None, None, None)
values = list(el[0] for el in file_generator.list_files(self.directory, dir_op=True))
self.assertEqual(values, list(sorted(values)))
示例4: test_error_raised_on_decoding_error
# 需要导入模块: from awscli.customizations.s3.filegenerator import FileGenerator [as 别名]
# 或者: from awscli.customizations.s3.filegenerator.FileGenerator import list_files [as 别名]
def test_error_raised_on_decoding_error(self, listdir_mock):
# On Python3, sys.getdefaultencoding
file_generator = FileGenerator(None, None, None)
# utf-8 encoding for U+2713.
listdir_mock.return_value = [b'\xe2\x9c\x93']
list(file_generator.list_files(self.directory, dir_op=True))
# Ensure the message was added to the result queue and is
# being skipped.
self.assertFalse(file_generator.result_queue.empty())
warning_message = file_generator.result_queue.get()
self.assertIn("warning: Skipping file ", warning_message.message)
self.assertIn("Please check your locale settings.",
warning_message.message)
示例5: test_list_files_is_in_sorted_order
# 需要导入模块: from awscli.customizations.s3.filegenerator import FileGenerator [as 别名]
# 或者: from awscli.customizations.s3.filegenerator.FileGenerator import list_files [as 别名]
def test_list_files_is_in_sorted_order(self):
p = os.path.join
open(p(self.directory, 'test-123.txt'), 'w').close()
open(p(self.directory, 'test-321.txt'), 'w').close()
open(p(self.directory, 'test123.txt'), 'w').close()
open(p(self.directory, 'test321.txt'), 'w').close()
os.mkdir(p(self.directory, 'test'))
open(p(self.directory, 'test', 'foo.txt'), 'w').close()
file_generator = FileGenerator(None, None, None)
values = list(el[0] for el in file_generator.list_files(
self.directory, dir_op=True))
ref_vals = list(sorted(values,
key=lambda items: items.replace(os.sep, '/')))
self.assertEqual(values, ref_vals)
示例6: test_list_files_with_invalid_timestamp
# 需要导入模块: from awscli.customizations.s3.filegenerator import FileGenerator [as 别名]
# 或者: from awscli.customizations.s3.filegenerator.FileGenerator import list_files [as 别名]
def test_list_files_with_invalid_timestamp(self, stat_mock):
stat_mock.return_value = 9, None
open(os.path.join(self.directory, 'test'), 'w').close()
file_generator = FileGenerator(None, None, None)
value = list(file_generator.list_files(self.directory, dir_op=True))[0]
self.assertIs(value[1]['LastModified'], EPOCH_TIME)