'Remove the books specified by the book_ids from the database and delete
their format files. If ``permanent`` is False, then the format files
are placed in the recycle bin.'

@write_api
def remove_books(self, book_ids, permanent=False):

    path_map = {}
    for book_id in book_ids:
        try:
            path = self._field_for(u'path', book_id).replace(u'/', os.sep)
        except:
            path = None
        path_map[book_id] = path
    if iswindows:
        paths = (x.replace(os.sep, u'/') for x in path_map.itervalues() if x)
        self.backend.windows_check_if_files_in_use(paths)
    self.backend.remove_books(path_map, permanent=permanent)
    for field in self.fields.itervalues():
        try:
            table = field.table
        except AttributeError:
            continue
        else:
            table.remove_books(book_ids, self.backend)
    self._search_api.discard_books(book_ids)
    self._clear_caches(book_ids=book_ids, template_cache=False, search_cache=False)
    for cc in self.cover_caches:
        cc.invalidate(book_ids)
