예제 #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
 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
 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
    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
 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
    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
 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")