Add typing to database files

This commit is contained in:
Jan-Pieter Baert 2019-09-07 15:05:24 +02:00
parent 9459eb0f1e
commit 51edd1bdc1
No known key found for this signature in database
GPG key ID: B19186932178234A
7 changed files with 23 additions and 23 deletions

View file

@ -2,7 +2,7 @@ from app import db
from models import User
def add():
def add() -> None:
feli = User()
feli.configure("feliciaan", True, 0)
db.session.add(feli)

View file

@ -23,7 +23,7 @@ menuitems = [
pricedict = {"Small": 799, "Medium": 999, "Large": 1199}
def add():
def add() -> None:
simpizza = Location()
simpizza.configure("Fitchen", "?", "?", "https://www.fitchen.be/")
db.session.add(simpizza)

View file

@ -29,7 +29,7 @@ specials = [
]
def add():
def add() -> None:
chinees = Location()
chinees.configure(
"Oceans's Garden",
@ -39,12 +39,12 @@ def add():
)
db.session.add(chinees)
def chinees_create_entry(name):
def chinees_create_entry(name) -> None:
entry = Product()
entry.configure(chinees, name, 550)
db.session.add(entry)
def chinees_create_regulat(zetmeel, vlees="", saus=""):
def chinees_create_regulat(zetmeel, vlees="", saus="") -> None:
chinees_create_entry("{} {} {}".format(zetmeel, vlees, saus).rstrip())
for z, v, s in product(zetmelen, vlezen, sauzen):

View file

@ -46,7 +46,7 @@ pizzasTA = {
}
def addTA():
def addTA() -> None:
primadonna_takeaway = Location()
primadonna_takeaway.configure(
"Primadonna (takeaway laten bezorgen)",
@ -101,7 +101,7 @@ pizzasAfhalen = {
}
def addAfhalen():
def addAfhalen() -> None:
primadonna_afhalen = Location()
primadonna_afhalen.configure(
"Primadonna (bellen en afhalen)",

View file

@ -33,7 +33,7 @@ pizzas = [
]
def add():
def add() -> None:
simpizza = Location()
simpizza.configure(
"Sim-pizza",

View file

@ -11,7 +11,7 @@ bickies = {
"Bicky Veggie": 350,
}
saus = {
sauskes = {
"american": 70,
"andalouse": 70,
"bicky saus": 70,
@ -100,7 +100,7 @@ friet = {"Klein pak": 200, "Midden pak": 250, "Groot pak": 300}
data = [special_bickies, specials, vlezekes, friet]
def add():
def add() -> None:
stefanos = Location()
stefanos.configure(
"Stefano's Place",
@ -127,7 +127,7 @@ def add():
db.session.add(item)
# saus in een potteke bestellen is 10 cent extra
for name, price in saus.items():
for name, price in sauskes.items():
saus = Product()
saus.configure(stefanos, name, price)
db.session.add(saus)

View file

@ -15,23 +15,23 @@ no = ["no", "n", "N"]
# Commit all the things
def commit():
def commit() -> None:
db.session.commit()
print("Committing successful")
def check_if_overwrite():
def check_if_overwrite() -> bool:
answer = input("Do you want to overwrite the previous database? (y/N) ")
return answer in yes
def add_all():
def add_all() -> None:
for entry_set in entry_sets.keys():
print("Adding {}.".format(entry_set))
entry_sets[entry_set]()
def recreate_from_scratch():
def recreate_from_scratch() -> None:
confirmation = "Are you very very sure? (Will delete previous entries!) (y/N) "
check = "I acknowledge any repercussions!"
if input(confirmation) in yes and input("Type: '{}' ".format(check)) == check:
@ -41,10 +41,10 @@ def recreate_from_scratch():
add_to_current()
def add_to_current():
def add_to_current() -> None:
available = [entry_set for entry_set in entry_sets]
def add_numbers():
def add_numbers() -> str:
return " ".join(
["{}({}), ".format(loc, i) for i, loc in enumerate(available)]
).rstrip(", ")
@ -59,17 +59,17 @@ def add_to_current():
available = []
elif answer == "C":
pass
elif answer in [str(x) for x in range(len(available))]:
answer = int(answer)
print("Adding {}.".format(available[answer]))
entry_sets[str(available[answer])]()
del available[answer]
elif answer.isnumeric() and answer in [str(x) for x in range(len(available))]:
answer_index = int(answer)
print("Adding {}.".format(available[answer_index]))
entry_sets[str(available[answer_index])]()
del available[answer_index]
else:
print("Not a valid answer.")
print("Thank you for adding, come again!")
def init():
def init() -> None:
print("Database modification script!")
print("=============================\n\n")
if check_if_overwrite():