Exemple #1
0
 def get_fs(cls, registry, fs_name, fs_name_params, fs_path, writeable,
            create_dir):
     from fs.memoryfs import MemoryFS
     memfs = MemoryFS()
     if create_dir:
         memfs = memfs.makeopendir(fs_path)
     return memfs, None
Exemple #2
0
    def test_movedir_root(self):
        """Test movedir to root dir"""        
        fs1 = MemoryFS()
        fs2 = MemoryFS()
        fs1sub = fs1.makeopendir("from")
        self._make_fs(fs1sub)            
        utils.movedir((fs1, "from"), fs2)
        self.assert_(not fs1.exists("from"))     
        self._check_fs(fs2)

        fs1 = TempFS()
        fs2 = TempFS()
        fs1sub = fs1.makeopendir("from")
        self._make_fs(fs1sub)            
        utils.movedir((fs1, "from"), fs2)
        self.assert_(not fs1.exists("from"))        
        self._check_fs(fs2)
Exemple #3
0
    def test_movedir_indir(self):
        """Test movedir in a directory"""        
        fs1 = MemoryFS()
        fs2 = MemoryFS()
        fs1sub = fs1.makeopendir("from")
        self._make_fs(fs1sub)            
        utils.movedir((fs1, "from"), (fs2, "copy"))        
        self.assert_(not fs1.exists("from"))     
        self._check_fs(fs2.opendir("copy"))

        fs1 = TempFS()
        fs2 = TempFS()
        fs1sub = fs1.makeopendir("from")
        self._make_fs(fs1sub)            
        utils.movedir((fs1, "from"), (fs2, "copy"))
        self.assert_(not fs1.exists("from"))      
        self._check_fs(fs2.opendir("copy"))
Exemple #4
0
class TestWalk(unittest.TestCase):
    
    def setUp(self):
        self.fs = MemoryFS()
        self.fs.setcontents('a.txt', 'hello')
        self.fs.setcontents('b.txt', 'world')
        self.fs.makeopendir('foo').setcontents('c', '123')
        self.fs.makeopendir('.svn').setcontents('ignored', '')
    
    def test_wildcard(self):
        for dir_path, paths in self.fs.walk(wildcard='*.txt'):
            for path in paths:
                self.assert_(path.endswith('.txt'))
        for dir_path, paths in self.fs.walk(wildcard=lambda fn:fn.endswith('.txt')):
            for path in paths:
                self.assert_(path.endswith('.txt'))
    
    def test_dir_wildcard(self):
        
        for dir_path, paths in self.fs.walk(dir_wildcard=lambda fn:not fn.endswith('.svn')):            
            for path in paths:                
                self.assert_('.svn' not in path)
Exemple #5
0
 def get_fs(cls, registry, fs_name, fs_name_params, fs_path,  writeable, create_dir):
     from fs.memoryfs import MemoryFS
     memfs = MemoryFS()
     if create_dir:
         memfs = memfs.makeopendir(fs_path)
     return memfs, None