def register_book(book): """Регистрация новой книги в магазине.""" BookStore.book_index.append(book) BookStore.log(str(book)) for edition in book.editions: if (BookStore.publisher_index.get(edition.publisher, False)): BookStore.publisher_index[edition.publisher].add(edition) else: from publisher import Publisher publisher = Publisher(edition.publisher) publisher.add(edition) BookStore.publisher_index[edition.publisher] = publisher if (BookStore.author_index.get(book.author, False)): BookStore.author_index[book.author].add(book) else: from author import Author author = Author(book.author) author.add(book) BookStore.author_index[book.author] = author return BookStore.book_index, BookStore.publisher_index, BookStore.author_index