示例#1
0
 def rename_dir(self, prev_dir_name, new_dir_name):
     for file_name in self.parser.sections():
         if is_subdirectory(dirname(join(self._base_dir, file_name)), prev_dir_name):
             k, m = self._get_split_info(file_name)
             chunks = self._get_chunks(file_name)
             state = self._get_state(file_name)
             new_file_path = join(new_dir_name, basename(file_name))
             self.add_file(new_file_path, k, m, state)
             self.update_chunks_for_file(new_file_path, chunks)
             self._remove_file(file_name)
示例#2
0
 def rename_dir(self, prev_dir_name, new_dir_name):
     for file_name in self.parser.sections():
         if is_subdirectory(dirname(join(self._base_dir, file_name)),
                            prev_dir_name):
             k, m = self._get_split_info(file_name)
             chunks = self._get_chunks(file_name)
             state = self._get_state(file_name)
             new_file_path = join(new_dir_name, basename(file_name))
             self.add_file(new_file_path, k, m, state)
             self.update_chunks_for_file(new_file_path, chunks)
             self._remove_file(file_name)
示例#3
0
 def decorated(*args, **kwargs):
     base_dir = args[0].base_dir
     file_path = args[1]
     if not is_subdirectory(dirname(file_path), base_dir):
         raise NotInBaseDirException
     return func(*args, **kwargs)
示例#4
0
 def get_files_in_dir(self, dir_name):
     return [file_path for file_path in self.parser.sections() if is_subdirectory(dirname(join(self._base_dir, file_path)), dir_name)]
示例#5
0
 def remove_dir(self, dir_name):
     for file_name in self.parser.sections():
         if is_subdirectory(dirname(join(self._base_dir, file_name)), dir_name):
             self._remove_file(file_name)
示例#6
0
 def decorated(*args, **kwargs):
     base_dir = args[0].base_dir
     file_path = args[1]
     if not is_subdirectory(dirname(file_path), base_dir):
         raise NotInBaseDirException
     return func(*args, **kwargs)
示例#7
0
 def get_files_in_dir(self, dir_name):
     return [
         file_path
         for file_path in self.parser.sections() if is_subdirectory(
             dirname(join(self._base_dir, file_path)), dir_name)
     ]
示例#8
0
 def remove_dir(self, dir_name):
     for file_name in self.parser.sections():
         if is_subdirectory(dirname(join(self._base_dir, file_name)),
                            dir_name):
             self._remove_file(file_name)
示例#9
0
 def test_is_subdirectory(self):
     self.assertFalse(is_subdirectory('/var/test2', '/var/test'))
     self.assertFalse(is_subdirectory('/var/test', '/var/test2'))
     self.assertFalse(is_subdirectory('var/test2', 'var/test'))
     self.assertFalse(is_subdirectory('var/test', 'var/test2'))
     self.assertTrue(is_subdirectory('/var/test/sub', '/var/test'))
     self.assertFalse(is_subdirectory('/var/test', '/var/test/sub'))
     self.assertTrue(is_subdirectory('var/test/sub', 'var/test'))
     self.assertTrue(is_subdirectory('var/test', 'var/test'))
     self.assertTrue(is_subdirectory('var/test', 'var/test/fake_sub/..'))
     self.assertTrue(is_subdirectory('var/test/sub/sub2/sub3/../..', 'var/test'))
     self.assertTrue(is_subdirectory('var/test/sub', 'var/test/fake_sub/..'))
     self.assertFalse(is_subdirectory('var/test', 'var/test/sub'))