"""Last read books.""" import os import books lst = [] def add(book): if book in lst: lst.remove(book) lst.append(book) def compress(current_book): """Compress last book. (if not the same as passed book) """ if lst: b = lst[-1] if current_book != b: lst[-1].compress() def read(): if lst: lst[-1].read() else: print "No last book." def delete(): """Pick a local book to delete.""" book = books.choose(lst) if book: lst.remove(book) os.remove(book.l_fname) print "Deleted: ", book.title def choose(): """Display last read books.""" print "Latest books are on top.\n" nl = lst[:] nl.reverse() book = books.choose(nl) if book: book.read() # vim: sts=4:ts=8:et:sw=4