def generate_cache(self): """generates the cache """ if not GutenbergCache.exists(): try: self.infoBox.setText( "The cache is being generated. This can take up to 10min.", "warning") GutenbergCache.create(refresh=True, download=True, unpack=True, parse=True, deleteTemp=True) self.infoBox.setText("Cache generated!") self.cacheGenerationButton.setDisabled(True) self.queryBox.setEnabled(True) except Exception as exc: print(exc) self.infoBox.setText( "An error occurred while building the cache", "error") else: self.infoBox.setText("The cache already exists.")
def generate_cache(self): GutenbergCache.create(refresh=True, download=True, unpack=True, parse=True, deleteTemp=True)
import gutenbergpy.textget from gutenbergpy.gutenbergcache import GutenbergCache # create cache from scratchfrom scratch GutenbergCache.create(refresh=True, download=True, unpack=True, parse=True, cache=True, deleteTemp=True) # get the default cache (SQLite) cache = GutenbergCache.get_cache() # For the query function you can use the following fields: languages authors types titles subjects publishers bookshelves print( cache.query(downloadtype=[ 'application/plain', 'text/plain', 'text/html; charset=utf-8' ])) # Print stripped text print( gutenbergpy.textget.strip_headers( gutenbergpy.textget.get_text_by_id(1000)))
from book_openers.gutenberg import main from gutenbergpy.gutenbergcache import GutenbergCache from sys import argv if __name__ == "__main__": if len(argv) == 1: main() elif argv[1] == "catalogue": GutenbergCache.create() else: try: id = int(argv[1]) except: print("invalid options") else: main(id)