X-Git-Url: https://us-delaporte.pagekite.me/gitweb/matrix-shop-bot.git/blobdiff_plain/1b1c92e88a56c85a184a4c6400052ce4b580fd8e..refs/heads/main:/matrix_shop_bot/tasks.py diff --git a/matrix_shop_bot/tasks.py b/matrix_shop_bot/tasks.py index 73f57e2..580eeba 100644 --- a/matrix_shop_bot/tasks.py +++ b/matrix_shop_bot/tasks.py @@ -1,7 +1,11 @@ from invoke import task +import logging from .db import Data +logging.getLogger('invoke').setLevel(logging.WARNING) +logging.basicConfig(filename=f'matrix-shop-bot.log', encoding='utf-8', level=logging.DEBUG) + @task def setup(c): result = Data().setup() @@ -29,28 +33,36 @@ def assign_to_store(c, item_id, store_id): result = Data().assign_store(store_id, item_id) print(result) +@task +def item_to_zone(c, item, zone): + result = Data().assign_zone(item, zone) + print(result) @task -def buy(c, item_id): - result = Data().purchase_item(item_id) +def buy(c, items): + result = Data().purchase_items(items) print(result) @task -def clear_all(c, store_id): - Data().clear_list(store_id, clear_all=True) +def list_bought(c, store): + result = Data().list_purchases(store) + for item in result: + print(str(item)) @task -def clear_list(c, store_id): - Data().clear_list(store_id) +def clear(c, store_name, clear_all=False): + results = Data().clear_list(store_name, clear_all) + for item in results: + print(str(item)) @task -def list_for_store(c, store_id): - items = Data().get_shopping_list_for_store(store_id) +def at(c, store_name): + '''Select store to shop at''' + items = Data().get_shopping_list(store_name) for item in items: print(item) - @task def list(c): '''Use previous store''' @@ -72,6 +84,14 @@ def list_unsorted(c): print(item) +@task +def rename_item(c, old, new): + Data().rename_item(old, new) + +@task +def rename_store(c, old, new): + Data().rename_store(old, new) + @task def remove_item(c, item_id): Data().remove_item(item_id) @@ -80,3 +100,9 @@ def remove_item(c, item_id): def remove_store(c, store_id): Data().remove_store(store_id) +@task +def list_purchases(c, store): + items = Data().list_purchases(store) + for item in items: + print(item) +