def createAuthor(): author = Author(authorName) for dirEntry in os.scandir('data'): _authorName = dirEntry.name.split('_-_')[0] if _authorName == authorName: try: with open(dirEntry.path) as file: author.loadBooks(file) except UnicodeDecodeError: pass author.calcProbability() return author