def test_folder_type_map_case(self): book = get_simple_book() c = get_container(book) c.add_file('Image/testcase.png', b'xxx') rationalize_folders(c, {'image': 'image'}) self.assertTrue(c.has_name('Image/testcase.png')) self.assertTrue(c.exists('Image/testcase.png')) self.assertFalse(c.has_name('image/testcase.png'))
def test_folder_type_map_case(self): book = get_simple_book() c = get_container(book) c.add_file('Image/testcase.png', b'xxx') rationalize_folders(c, {'image':'image'}) self.assertTrue(c.has_name('Image/testcase.png')) self.assertTrue(c.exists('Image/testcase.png')) self.assertFalse(c.has_name('image/testcase.png'))
def rationalize_folders(self): c = current_container() if not c.SUPPORTS_FILENAMES: return error_dialog(self.gui, _('Not supported'), _('The %s format does not support file and folder names internally, therefore' ' arranging files into folders is not allowed.') % c.book_type.upper(), show=True) d = RationalizeFolders(self.gui) if d.exec_() != d.Accepted: return self.commit_all_editors_to_container() name_map = rationalize_folders(c, d.folder_map) if not name_map: return info_dialog(self.gui, _('Nothing to do'), _( 'The files in this book are already arranged into folders'), show=True) self.add_savepoint(_('Arrange into folders')) self.gui.blocking_job( 'rationalize_folders', _('Renaming and updating links...'), partial(self.rename_done, name_map), rename_files, current_container(), name_map)