Last active
August 25, 2016 16:55
-
-
Save afroisalreadyinu/63d7f839d93555d9e94a9b409319ec89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def build_book_inventory(book_ids, shops): | |
shop_labels = [shop['label'] for shop in shops] | |
book_list = Persistency.books_table.read( | |
shops=shop_labels, | |
books=book_ids) | |
inventory = {} | |
for book_item in book_list: | |
shop_label = book_item['shop_label'] | |
cell_label = book_item['cell_label'] | |
book_id = book_item['book_id'] | |
count = book_item['count'] | |
if shop_label not in inventory: | |
inventory[shop_label] = {} | |
if cell_label not in inventory[shop_label]: | |
inventory[shop_label][cell_label] = {} | |
inventory[shop_label][cell_label][book_id] = count | |
return inventory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment