'Remove books from the metadata list. This function must not communicate
with the device.
@param paths: paths to books on the device.
@param booklists:  A tuple containing the result of calls to
(L{books}(oncard=None), L{books}(oncard=\'carda\'),
L{books}(oncard=\'cardb\')).
NB: This will not find books that were added by a different installation of calibre
as uuids are different'

def remove_books_from_metadata(self, paths, booklists):

    if self.verbose:
        logger().info(('%s.remove_books_from_metadata()' % self.__class__.__name__))
    for path in paths:
        if self.verbose:
            self._dump_cached_book(self.cached_books[path], indent=2)
            if (False and self.verbose):
                logger().info(("        looking    for    '%s'    by    '%s'    uuid:%s" % (self.cached_books[path]['title'], self.cached_books[path]['author'], repr(self.cached_books[path]['uuid']))))
        for (i, bl_book) in enumerate(booklists[0]):
            if (False and self.verbose):
                logger().info(("        evaluating    '%s'    by    '%s'    uuid:%s" % (bl_book.title, bl_book.author, bl_book.uuid)))
            found = False
            if (bl_book.uuid and (bl_book.uuid == self.cached_books[path]['uuid'])):
                if (True and self.verbose):
                    logger().info('        --matched    uuid')
                found = True
            elif ((bl_book.title == self.cached_books[path]['title']) and (bl_book.author == self.cached_books[path]['author'])):
                if (True and self.verbose):
                    logger().info('        --matched    title    +    author')
                found = True
            if found:
                popped = booklists[0].pop(i)
                if (False and self.verbose):
                    logger().info(("        '%s'    removed    from    booklists[0]" % popped.title))
                if (False and self.verbose):
                    logger().info(('path:    %s' % path))
                for cb in self.cached_books:
                    if (False and self.verbose):
                        logger().info(("        evaluating    '%s'    by    '%s'    uuid:%s" % (self.cached_books[cb]['title'], self.cached_books[cb]['author'], self.cached_books[cb]['uuid'])))
                    if ((self.cached_books[cb]['uuid'] == self.cached_books[path]['uuid']) and (self.cached_books[cb]['author'] == self.cached_books[path]['author']) and (self.cached_books[cb]['title'] == self.cached_books[path]['title'])):
                        popped = self.cached_books.pop(cb)
                        if (False and self.verbose):
                            logger().info(("        '%s'    removed    from    self.cached_books" % popped['title']))
                        break
                else:
                    if self.verbose:
                        logger().info(("    '%s'    not    found    in    self.cached_books" % self.cached_books[path]['title']))
                from calibre.utils.zipfile import ZipFile
                thumb_path = (path.rpartition('.')[0] + '.jpg')
                zf = ZipFile(self.archive_path, 'a')
                fnames = zf.namelist()
                try:
                    thumb = [x for x in fnames if (thumb_path in x)][0]
                except:
                    thumb = None
                if thumb:
                    if self.verbose:
                        logger().info(("        deleting    '%s'    from    cover    cache" % thumb_path))
                    zf.delete(thumb_path)
                elif self.verbose:
                    logger().info(("        '%s'    not    found    in    cover    cache" % thumb_path))
                zf.close()
                break
        else:
            if self.verbose:
                logger().error(("        unable    to    find    '%s'    by    '%s'    (%s)" % (self.cached_books[path]['title'], self.cached_books[path]['author'], self.cached_books[path]['uuid'])))
    if (False and self.verbose):
        self._dump_booklist(booklists[0], indent=2)
        self._dump_cached_books(indent=2)
