コード例 #1
0
ファイル: files_test.py プロジェクト: mr-wrmsr/BlackServerOS
    def testGlob(self):
        self._make_temp_directory()
        glob_plugin = files.IRGlob(session=self.session,
                                   globs=[self.temp_directory + "/*.txt"])
        result = list(glob_plugin.collect())
        self.assertTrue(
            "boo.txt" in
            [os.path.basename(unicode(x["path"].filename)) for x in result])
        self.assertEqual(len(result), 1)

        glob_plugin = files.IRGlob(session=self.session,
                                   globs=[self.temp_directory + "/**/*.txt"])
        result = list(glob_plugin.collect())
        paths = [os.path.basename(unicode(x["path"].filename)) for x in result]
        self.assertEqual(["boo.txt", "boo2.txt"], paths)
コード例 #2
0
ファイル: files_test.py プロジェクト: mr-wrmsr/BlackServerOS
    def testGlobComponents(self):
        """Check to ensure the components are created properly."""
        glob_plugin = files.IRGlob(session=self.session)
        path_components = glob_plugin.convert_glob_into_path_components(
            "/usr/*/ls")
        self.assertListEqual([str(x) for x in path_components], [
            "LiteralComponent:usr", "RegexComponent:.*\Z(?ms)",
            "LiteralComponent:ls"
        ])

        glob_plugin = files.IRGlob(session=self.session, path_sep="\\")
        path_components = glob_plugin.convert_glob_into_path_components(
            "c:\\windows\\**\*.exe")
        self.assertListEqual([str(x) for x in path_components], [
            "LiteralComponent:c:", "LiteralComponent:windows",
            "RecursiveComponent:.*\Z(?ms)", "RegexComponent:.*\\.exe\\Z(?ms)"
        ])