def __init__(self, db_file): self.db = Database(db_file) self.rwlock = ReadWriteLock()
dest="fortune", help="Write a new fortune to the database.") parser.add_argument("-i", "--interactive", action="store_true", dest="interactive", default=False, help="Interactive session with the fortune database.") opts = parser.parse_args() # ----------------------------------------------------------------------------- # The main program # ----------------------------------------------------------------------------- # Create the database object db = Database("dbs/fortune.db") if not opts.interactive: # Run in the normal mode if opts.fortune is not None: db.write(opts.fortune) else: print(db.read()) else: # Run in the interactive mode def menu(): print("""\ Choose one of the following commands: r :: read a random fortune from the database, w <FORTUNE> :: write a new fortune into the database,