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


Python FileGenerator.list_files方法代码示例

本文整理汇总了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)
开发者ID:CitizenB,项目名称:aws-cli,代码行数:32,代码来源:test_filegenerator.py

示例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))
开发者ID:HackedByChinese,项目名称:aws-cli,代码行数:9,代码来源:test_filegenerator.py

示例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)))
开发者ID:CitizenB,项目名称:aws-cli,代码行数:14,代码来源:test_filegenerator.py

示例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)
开发者ID:emyphan,项目名称:aws-cli,代码行数:15,代码来源:test_filegenerator.py

示例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)
开发者ID:emyphan,项目名称:aws-cli,代码行数:17,代码来源:test_filegenerator.py

示例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)
开发者ID:Bjorn248,项目名称:aws-cli,代码行数:8,代码来源:test_filegenerator.py


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