X-Git-Url: https://apps.delaporte.us/gitweb/matrix-shop-bot.git/blobdiff_plain/d0f8d69f2d4aa2a1af67baae391663d9bb72c729..b0d59de8e794c84f2089515e3adf3a68703c96b8:/matrix_shop_bot/tasks.py?ds=sidebyside diff --git a/matrix_shop_bot/tasks.py b/matrix_shop_bot/tasks.py index 1fbc3fb..07ffb40 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() @@ -17,30 +21,61 @@ def add_store(c, name): result = Data().add_store(name) print(result) + @task -def buy(c, item_id): - result = Data().purchase_item(item_id) +def assign(c, item_id): + result = Data().assign_last_store(item_id) print(result) + @task -def list(c, store_id): - items = Data().get_shopping_list(store_id) +def assign_to_store(c, item_id, store_id): + result = Data().assign_store(store_id, item_id) + print(result) + +@task +def assign_to_zone(c, item, zone): + result = Data().assign_zone(item, zone) + print(result) + +@task +def buy(c, items): + result = Data().purchase_items(items) + print(result) + +@task +def list_bought(c, store): + result = Data().list_purchases(store) + for item in result: + print(str(item)) + +@task +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 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_stores(c): - items = Data().get_stores() +def list(c): + '''Use previous store''' + items = Data().get_last_shopping_list() for item in items: print(item) @task -def clear_list(c, store_id): - Data().clear_list(store_id) +def list_stores(c): + items = Data().get_stores() + for item in items: + print(item) -@task -def clear_all(c, store_id): - Data().clear_list(store_id, clear_all=True) @task def list_unsorted(c): @@ -48,9 +83,18 @@ def list_unsorted(c): for item in items: print(item) + @task -def assign(c, store_id, item_id): - result = Data().assign_store(store_id, item_id) - print(result) +def remove_item(c, item_id): + Data().remove_item(item_id) + +@task +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)