コード例 #1
0
 def __call__(self, from_dir='/', with_user_typing=''):
     RestoreCmd(stdout=self.out,
                stderr=self.err,
                environ=self.environ,
                exit=[].append,
                input=lambda msg: with_user_typing,
                curdir=lambda: from_dir).run([])
コード例 #2
0
 def setUp(self):
     self.stdout = StringIO()
     self.stderr = StringIO()
     self.cmd = RestoreCmd(stdout=self.stdout,
                           stderr=self.stderr,
                           environ={},
                           exit=self.capture_exit_status,
                           input=lambda x: self.user_reply,
                           version=None)
コード例 #3
0
 def run_restore(self, with_user_typing=''):
     RestoreCmd(stdout=self.out,
                stderr=self.err,
                environ={
                    'XDG_DATA_HOME': self.XDG_DATA_HOME
                },
                exit=[].append,
                input=lambda msg: with_user_typing,
                curdir=lambda: self.current_dir).run([])
コード例 #4
0
def restore():
    from trashcli.restore import RestoreCmd
    try:  # Python 2
        input23 = raw_input
    except:  # Python 3
        input23 = input
    RestoreCmd(stdout=sys.stdout,
               stderr=sys.stderr,
               environ=os.environ,
               exit=sys.exit,
               input=input23).run(sys.argv)
コード例 #5
0
 def setUp(self):
     trash_directories = make_trash_directories()
     trashed_files = TrashedFiles(trash_directories, None, contents_of)
     self.cmd = RestoreCmd(None, None,
                           exit=None,
                           input=None,
                           curdir=lambda: "dir",
                           trashed_files=trashed_files,
                           mount_points=os_mount_points)
     self.cmd.handle_trashed_files = self.capture_trashed_files
     self.trashed_files = Mock(spec=['all_trashed_files'])
     self.cmd.trashed_files = self.trashed_files
コード例 #6
0
 def setUp(self):
     remove_file_if_exists('parent/path')
     remove_dir_if_exists('parent')
     trash_directories = make_trash_directories()
     trashed_files = TrashedFiles(trash_directories, TrashDirectory(),
                                  contents_of)
     self.cmd = RestoreCmd(None,
                           None,
                           exit=None,
                           input=None,
                           trashed_files=trashed_files,
                           mount_points=os_mount_points)
コード例 #7
0
 def setUp(self):
     self.temp_dir = MyPath.make_temp_dir()
     trash_directories = make_trash_directories()
     trashed_files = TrashedFiles(trash_directories, TrashDirectory(),
                                  contents_of)
     self.cmd = RestoreCmd(None,
                           None,
                           exit=None,
                           input=None,
                           trashed_files=trashed_files,
                           mount_points=os_mount_points,
                           fs=restore.FileSystem())
コード例 #8
0
 def setUp(self):
     self.stdout = StringIO()
     self.stderr = StringIO()
     trash_directories = make_trash_directories()
     trashed_files = TrashedFiles(trash_directories, TrashDirectory(),
                                  contents_of)
     self.cmd = RestoreCmd(stdout=self.stdout,
                           stderr=self.stderr,
                           exit = self.capture_exit_status,
                           input =lambda x: self.user_reply,
                           version=None,
                           trashed_files=trashed_files,
                           mount_points=os_mount_points)
コード例 #9
0
 def run_restore(self, with_user_typing=''):
     environ = {'XDG_DATA_HOME': self.XDG_DATA_HOME}
     trash_directories = TrashDirectories(volume_of, os.getuid, environ)
     trash_directories2 = TrashDirectories2(volume_of, trash_directories)
     trashed_files = TrashedFiles(trash_directories2, TrashDirectory(),
                                  contents_of)
     RestoreCmd(stdout=self.out,
                stderr=self.err,
                exit=[].append,
                input=lambda msg: with_user_typing,
                curdir=lambda: self.current_dir,
                trashed_files=trashed_files,
                mount_points=os_mount_points).run([])
コード例 #10
0
    def test_something(self):
        cmd = RestoreCmd(None, None, {}, None, None)
        cmd.contents_of = lambda path: 'Path=name\nDeletionDate=2001-01-01T10:10:10'
        path_to_trashinfo = 'info/info_path.trashinfo'
        trash_dir = Mock([])
        trash_dir.volume = '/volume'
        trash_dir.all_info_files = Mock([], return_value=[path_to_trashinfo])
        cmd.all_trash_directories2 = lambda: [trash_dir]

        cmd.curdir = lambda: '/volume'
        trashed_files = list(cmd.all_trashed_files())

        trashed_file = trashed_files[0]
        assert_equals('/volume/name', trashed_file.original_location)
        assert_equals(datetime.datetime(2001, 1, 1, 10, 10, 10),
                      trashed_file.deletion_date)
        assert_equals('info/info_path.trashinfo', trashed_file.info_file)
        assert_equals('files/info_path', trashed_file.original_file)
コード例 #11
0
 def setUp(self):
     self.cmd = RestoreCmd(None, None, None, None, None)
     self.cmd.curdir = lambda: "dir"
     self.cmd.handle_trashed_files = self.capture_trashed_files
コード例 #12
0
 def setUp(self):
     remove_file_if_exists('parent/path')
     remove_dir_if_exists('parent')
     self.cmd = RestoreCmd(None, None, None, None, None)