ruff format
This commit is contained in:
parent
e69d04dcd0
commit
a654baba11
dibbler
@ -76,12 +76,8 @@ class Database:
|
||||
personDatoVerdi = defaultdict(list) # dict->array
|
||||
personUkedagVerdi = defaultdict(list)
|
||||
# for global
|
||||
personPosTransactions = (
|
||||
{}
|
||||
) # personPosTransactions[trygvrad] == 100 #trygvrad har lagt 100kr i boksen
|
||||
personNegTransactions = (
|
||||
{}
|
||||
) # personNegTransactions[trygvrad» == 70 #trygvrad har tatt 70kr fra boksen
|
||||
personPosTransactions = {} # personPosTransactions[trygvrad] == 100 #trygvrad har lagt 100kr i boksen
|
||||
personNegTransactions = {} # personNegTransactions[trygvrad» == 70 #trygvrad har tatt 70kr fra boksen
|
||||
globalVareAntall = {} # globalVareAntall[Oreo] == 3
|
||||
globalVareVerdi = {} # globalVareVerdi[Oreo] == 30 #[kr]
|
||||
globalPersonAntall = {} # globalPersonAntall[trygvrad] == 3
|
||||
|
@ -20,7 +20,7 @@ subparsers = parser.add_subparsers(
|
||||
subparsers.add_parser("loop", help="Run the dibbler loop")
|
||||
subparsers.add_parser("create-db", help="Create the database")
|
||||
subparsers.add_parser("slabbedasker", help="Find out who is slabbedasker")
|
||||
subparsers.add_parser("seed-data",help="Fill with mock data")
|
||||
subparsers.add_parser("seed-data", help="Fill with mock data")
|
||||
|
||||
|
||||
def main():
|
||||
@ -41,13 +41,12 @@ def main():
|
||||
import dibbler.subcommands.slabbedasker as slabbedasker
|
||||
|
||||
slabbedasker.main()
|
||||
|
||||
|
||||
elif args.subcommand == "seed-data":
|
||||
import dibbler.subcommands.seed_test_data as seed_test_data
|
||||
|
||||
seed_test_data.main()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -180,7 +180,7 @@ When finished, write an empty line to confirm the purchase.\n"""
|
||||
print(f"User {t.user.name}'s credit is now {t.user.credit:d} kr")
|
||||
if t.user.credit < config.getint("limits", "low_credit_warning_limit"):
|
||||
print(
|
||||
f'USER {t.user.name} HAS LOWER CREDIT THAN {config.getint("limits", "low_credit_warning_limit"):d},',
|
||||
f"USER {t.user.name} HAS LOWER CREDIT THAN {config.getint('limits', 'low_credit_warning_limit'):d},",
|
||||
"AND SHOULD CONSIDER PUTTING SOME MONEY IN THE BOX.",
|
||||
)
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
__all__ = [
|
||||
'Base',
|
||||
'Product',
|
||||
'Purchase',
|
||||
'PurchaseEntry',
|
||||
'Transaction',
|
||||
'User',
|
||||
'UserProducts',
|
||||
"Base",
|
||||
"Product",
|
||||
"Purchase",
|
||||
"PurchaseEntry",
|
||||
"Transaction",
|
||||
"User",
|
||||
"UserProducts",
|
||||
]
|
||||
|
||||
from .Base import Base
|
||||
|
@ -5,9 +5,9 @@ from pathlib import Path
|
||||
|
||||
from dibbler.models.Product import Product
|
||||
|
||||
from dibbler.models.User import User
|
||||
from dibbler.models.User import User
|
||||
|
||||
JSON_FILE = Path(__file__).parent.parent.parent/"mock_data.json"
|
||||
JSON_FILE = Path(__file__).parent.parent.parent / "mock_data.json"
|
||||
|
||||
|
||||
def clear_db(session):
|
||||
@ -16,7 +16,7 @@ def clear_db(session):
|
||||
session.commit()
|
||||
|
||||
|
||||
def main() :
|
||||
def main():
|
||||
session = Session()
|
||||
clear_db(session)
|
||||
product_items = []
|
||||
@ -26,11 +26,21 @@ def main() :
|
||||
json_obj = json.load(f)
|
||||
|
||||
for product in json_obj["products"]:
|
||||
product_item = Product(bar_code=product["bar_code"], name=product["name"], price=product["price"], stock=product["stock"])
|
||||
product_item = Product(
|
||||
bar_code=product["bar_code"],
|
||||
name=product["name"],
|
||||
price=product["price"],
|
||||
stock=product["stock"],
|
||||
)
|
||||
product_items.append(product_item)
|
||||
|
||||
for user in json_obj["users"]:
|
||||
user_item = User(name=user ["name"], card=user [ "card" ], rfid=user [ "rfid" ], credit=user ["credit"])
|
||||
user_item = User(
|
||||
name=user["name"],
|
||||
card=user["card"],
|
||||
rfid=user["rfid"],
|
||||
credit=user["credit"],
|
||||
)
|
||||
user_items.append(user_item)
|
||||
|
||||
session.add_all(product_items)
|
||||
|
Loading…
x
Reference in New Issue
Block a user