コード例 #1
0
ファイル: test_macro.py プロジェクト: zendbit/peppy
 def testMacroSubdir(self):
     macro = PythonScriptableMacro("actions", "python1")
     MacroFS.addMacro(macro, "Python")
     names = vfs.get_names("macro:")
     assert "python1" not in names
     names = vfs.get_names("macro:Python")
     assert "python1" in names
コード例 #2
0
ファイル: test_macro.py プロジェクト: zendbit/peppy
 def testPickle(self):
     bytes = MacroSaveData.packVersion1()
     MacroFS.root = MemDir()
     RecentMacros.setStorage([])
     names = vfs.get_names("macro:")
     assert "name" not in names
     
     version, data = pickle.loads(bytes)
     MacroSaveData.unpackVersion1(data)
     names = vfs.get_names("macro:")
     assert "name" in names
コード例 #3
0
ファイル: test_tarfs.py プロジェクト: zendbit/peppy
 def test30_get_names(self):
     names = vfs.get_names('tar:vfs/sample.tar.bz2')
     self.assertEqual(True, 'hello.txt' in names)
     self.assertEqual(True, 'dir1' in names)
     self.assertEqual(True, 'dir1.txt' in names)
     names = vfs.get_names('tar:vfs/sample.tar.bz2/dir1')
     self.assertEqual(True, 'only-in-dir1.txt' in names)
     self.assertEqual(True, 'dir2' in names)
     self.assertEqual(True, 'dir2.txt' in names)
     names = vfs.get_names('tar:vfs/sample.tar.bz2/dir1/dir2')
     self.assertEqual(True, 'small.py' in names)
     self.assertEqual(False, 'hello.txt' in names)
     self.assertEqual(False, 'hello1.txt' in names)
コード例 #4
0
ファイル: test_sftpfs.py プロジェクト: betsegaw/peppy
 def test30_get_names(self):
     filenames = vfs.get_names(self.root)
     print(filenames)
     assert 'README' in filenames
     assert 'demo_sftp.py' in filenames
     assert 'wxyz' not in filenames
     self.assertRaises(OSError, vfs.get_names, self.root + 'zzzzz')
コード例 #5
0
ファイル: test_sftpfs.py プロジェクト: zendbit/peppy
 def test30_get_names(self):
     filenames = vfs.get_names(self.root)
     print(filenames)
     assert 'README' in filenames
     assert 'demo_sftp.py' in filenames
     assert 'wxyz' not in filenames
     self.assertRaises(OSError, vfs.get_names, self.root + 'zzzzz')
コード例 #6
0
ファイル: minibuffer.py プロジェクト: robmcmullen/peppy
    def completePath(self, text, uri, path):
        paths = []
        if "/" in path:
            if path.endswith("/"):
                # It's already a directory
                uridir = uri
                pattern = ""
            else:
                # The stuff after the last slash is the pattern to match
                uridir, pattern = path.rsplit("/", 1)
                uridir = vfs.get_dirname(uri)
        elif path == ".":
            # Needed to handle protocols that don't use leading slashes
            uridir = uri
            pattern = ""
        else:
            uridir = vfs.get_dirname(uri)
            pattern = path

        self.dprint("dir=%s pattern=%s" % (uridir, pattern))
        try:
            for name in vfs.get_names(uridir):
                if not name.startswith(pattern):
                    self.dprint("skipping %s because it doesn't start with %s" % (name, pattern))
                    continue
                uri = uridir.resolve2(name)
                path = str(uri)
                if vfs.is_folder(uri) and not path.endswith("/"):
                    path += "/"
                self.dprint(path)
                paths.append(path)
        except vfs.AuthenticationCancelled:
            pass
        return paths
コード例 #7
0
ファイル: macro.py プロジェクト: zendbit/peppy
 def getMacroNamesFromMajorModeClass(cls, modecls):
     """Get the list of macro names available for the specified major mode
     class.
     
     This is roughly equivalent to using C{vfs.get_names("macro:%s" %
     mode.keyword)} except that it also handles the case of universal
     macros linked to the abstract L{MajorMode} that are in the macro
     directory "".
     
     @param modecls: major mode class
     
     @returns: tuple containing the path in the macro: filesystem and the
     list of all macros in that path
     """
     keyword = modecls.keyword
     if keyword == "Abstract_Major_Mode":
         path = ""
     else:
         path = keyword
     try:
         all_names = vfs.get_names("macro:%s" % path)
     except OSError:
         all_names = []
     
     # Check to see that all the names are macro names and not directories
     macro_names = []
     for name in all_names:
         url = "macro:" + path + "/" + name
         if vfs.is_file(url):
             macro_names.append(name)
     return path, macro_names
コード例 #8
0
ファイル: test_macro.py プロジェクト: zendbit/peppy
 def testMacroSubdirAndRename(self):
     """Checking to see that a macro will get renamed if a directory is
     attempted to be created with the same name.
     
     Note that the MacroFS behaves like a normal filesystem when accessed
     using the regular filesystem commands.  Only when adding macros using
     the addMacro method will this happen.
     """
     macro = PythonScriptableMacro("actions", "Python")
     MacroFS.addMacro(macro)
     names = vfs.get_names("macro:")
     assert "Python" in names
     macro = PythonScriptableMacro("actions", "python1")
     MacroFS.addMacro(macro, "Python")
     names = vfs.get_names("macro:")
     assert "Python<1>" in names
     names = vfs.get_names("macro:Python")
     assert "python1" in names
コード例 #9
0
ファイル: test_webdavfs.py プロジェクト: zendbit/peppy
 def test_simple(self):
     vfs.make_folder(self.root + 'tmp')
     file = vfs.make_file(self.root + 'tmp/blah.txt')
     file.write("BLAH!!!")
     file.close()
     
     # Probably too loose of a test, but the modification time has a 10
     # second window for correctness
     mtime = vfs.get_mtime(self.root + 'tmp/blah.txt')
     current = datetime.now()
     assert abs(mtime - current) < timedelta(10)
     
     file = vfs.open(self.root + 'tmp/blah.txt')
     self.assertEqual(file.read(), 'BLAH!!!')
     assert vfs.exists(self.root + 'tmp')
     
     names = vfs.get_names(self.root)
     assert "tmp" in names
     names = vfs.get_names(self.root + 'tmp')
     assert "blah.txt" in names
     
     vfs.remove(self.root + 'tmp')
     assert not vfs.exists(self.root + 'tmp')
     assert not vfs.exists(self.root + 'tmp/blah.txt')
コード例 #10
0
ファイル: test_webdavfs.py プロジェクト: robmcmullen/peppy
    def test_simple(self):
        vfs.make_folder(self.root + "tmp")
        file = vfs.make_file(self.root + "tmp/blah.txt")
        file.write("BLAH!!!")
        file.close()

        # Probably too loose of a test, but the modification time has a 10
        # second window for correctness
        mtime = vfs.get_mtime(self.root + "tmp/blah.txt")
        current = datetime.now()
        assert abs(mtime - current) < timedelta(10)

        file = vfs.open(self.root + "tmp/blah.txt")
        self.assertEqual(file.read(), "BLAH!!!")
        assert vfs.exists(self.root + "tmp")

        names = vfs.get_names(self.root)
        assert "tmp" in names
        names = vfs.get_names(self.root + "tmp")
        assert "blah.txt" in names

        vfs.remove(self.root + "tmp")
        assert not vfs.exists(self.root + "tmp")
        assert not vfs.exists(self.root + "tmp/blah.txt")
コード例 #11
0
ファイル: macro.py プロジェクト: zendbit/peppy
 def appendAllFromMajorMode(self, keyword):
     """Append all macros for a given major mode
     
     """
     if keyword == "Abstract_Major_Mode":
         keyword = "Universal Macros"
         path = ""
     else:
         path = keyword
     item = self.AppendItem(self.root, _(keyword))
     try:
         names = vfs.get_names("macro:%s" % path)
         self.appendItems(item, path, names)
     except OSError:
         pass
     self.Expand(item)
コード例 #12
0
    def completePath(self, text, uri, path):
        paths = []
        if '/' in path:
            if path.endswith('/'):
                # It's already a directory
                uridir = uri
                pattern = ''
            else:
                # The stuff after the last slash is the pattern to match
                uridir, pattern = path.rsplit('/', 1)
                uridir = vfs.get_dirname(uri)
        elif path == '.':
            # Needed to handle protocols that don't use leading slashes
            uridir = uri
            pattern = ''
        else:
            uridir = vfs.get_dirname(uri)
            pattern = path

        self.dprint('dir=%s pattern=%s' % (uridir, pattern))
        try:
            for name in vfs.get_names(uridir):
                if not name.startswith(pattern):
                    self.dprint(
                        "skipping %s because it doesn't start with %s" %
                        (name, pattern))
                    continue
                uri = uridir.resolve2(name)
                path = str(uri)
                if vfs.is_folder(uri) and not path.endswith('/'):
                    path += '/'
                self.dprint(path)
                paths.append(path)
        except vfs.AuthenticationCancelled:
            pass
        return paths
コード例 #13
0
ファイル: test_vfs.py プロジェクト: zendbit/peppy
 def test18_get_names(self):
     self.assertEqual('hello.txt.old' in vfs.get_names('vfs'), True)
     # Remove temporary file
     vfs.remove('vfs/hello.txt.old')
コード例 #14
0
ファイル: test_vfs.py プロジェクト: betsegaw/peppy
 def test18_get_names(self):
     self.assertEqual('hello.txt.old' in vfs.get_names('vfs'), True)
     # Remove temporary file
     vfs.remove('vfs/hello.txt.old')
コード例 #15
0
ファイル: test_memfs.py プロジェクト: zendbit/peppy
 def test30_get_names(self):
     assert 'blah.txt' in vfs.get_names('mem:tmp')
     assert 'wxyz' not in vfs.get_names('mem:tmp')
     assert 'wxyz' not in vfs.get_names('mem:')
     self.assertRaises(OSError, vfs.get_names, 'mem:zzzzz')
コード例 #16
0
ファイル: test_memfs.py プロジェクト: betsegaw/peppy
 def test30_get_names(self):
     assert 'blah.txt' in vfs.get_names('mem:tmp')
     assert 'wxyz' not in vfs.get_names('mem:tmp')
     assert 'wxyz' not in vfs.get_names('mem:')
     self.assertRaises(OSError, vfs.get_names, 'mem:zzzzz')
コード例 #17
0
ファイル: dired.py プロジェクト: zendbit/peppy
 def getListItems(self):
     use_hidden = self.classprefs.show_hidden
     for name in vfs.get_names(self.url):
         if use_hidden or not name.startswith("."):
             yield name
コード例 #18
0
ファイル: test_macro.py プロジェクト: zendbit/peppy
 def testNames(self):
     names = vfs.get_names("macro:")
     assert "name" in names
     assert "name<1>" in names
     assert "different name" in names
     assert "different name<1>" not in names
コード例 #19
0
ファイル: test_macro.py プロジェクト: zendbit/peppy
 def testNotFound(self):
     names = vfs.get_names("macro:")
     assert "wxyz" not in names
     assert_raises(OSError, vfs.get_names, "macro:sir not appearing in this film")