Fix pylint for database files

This commit is contained in:
Jan-Pieter Baert 2019-09-09 23:19:21 +02:00
parent bbbec95b92
commit d21f2d48f5
No known key found for this signature in database
GPG key ID: B19186932178234A
7 changed files with 37 additions and 18 deletions

View file

@ -1,8 +1,10 @@
"Script for adding users as admin to Haldis."
from app import db from app import db
from models import User from models import User
def add() -> None: def add() -> None:
"Add users as admin."
feli = User() feli = User()
feli.configure("feliciaan", True, 0) feli.configure("feliciaan", True, 0)
db.session.add(feli) db.session.add(feli)

View file

@ -1,3 +1,4 @@
"Script to add Fitchen to Haldis"
from app import db from app import db
from models import Location, Product from models import Location, Product
@ -23,14 +24,15 @@ pricedict = {"Small": 799, "Medium": 999, "Large": 1199}
def add() -> None: def add() -> None:
simpizza = Location() "Add Fitchen to the database"
simpizza.configure("Fitchen", "?", "?", "https://www.fitchen.be/") fitchen = Location()
db.session.add(simpizza) fitchen.configure("Fitchen", "?", "?", "https://www.fitchen.be/")
db.session.add(fitchen)
for menuitem in menuitems: for menuitem in menuitems:
for size, price in pricedict.items(): for size, price in pricedict.items():
for container in ["bowl", "wrap"]: for container in ["bowl", "wrap"]:
name = "%s %s in %s" % (size, menuitem, container) name = "%s %s in %s" % (size, menuitem, container)
entry = Product() entry = Product()
entry.configure(simpizza, name, price) entry.configure(fitchen, name, price)
db.session.add(entry) db.session.add(entry)

View file

@ -1,3 +1,4 @@
"Script to add Ocean Garden to Haldis"
from itertools import product from itertools import product
from app import db from app import db
@ -30,6 +31,7 @@ specials = [
def add() -> None: def add() -> None:
"Add Ocean Garden to the database"
chinees = Location() chinees = Location()
chinees.configure( chinees.configure(
"Oceans's Garden", "Oceans's Garden",

View file

@ -1,8 +1,10 @@
"Script to add Primadonna to Haldis"
from app import db from app import db
from models import Location, Product from models import Location, Product
def add(): def add():
"Add Primadonna to the database"
addTA() addTA()
addAfhalen() addAfhalen()
@ -47,6 +49,7 @@ pizzasTA = {
def addTA() -> None: def addTA() -> None:
"Add Primadonna on takeaway.com to the database"
primadonna_takeaway = Location() primadonna_takeaway = Location()
primadonna_takeaway.configure( primadonna_takeaway.configure(
"Primadonna (takeaway laten bezorgen)", "Primadonna (takeaway laten bezorgen)",
@ -102,6 +105,7 @@ pizzasAfhalen = {
def addAfhalen() -> None: def addAfhalen() -> None:
"Add Primadonna to takeaway to the database"
primadonna_afhalen = Location() primadonna_afhalen = Location()
primadonna_afhalen.configure( primadonna_afhalen.configure(
"Primadonna (bellen en afhalen)", "Primadonna (bellen en afhalen)",

View file

@ -1,3 +1,4 @@
"Script to add SimPizza to Haldis"
from app import db from app import db
from models import Location, Product from models import Location, Product
@ -19,7 +20,8 @@ pizzas = [
"Chicken bbq", "Chicken bbq",
"Funky chicken", "Funky chicken",
"Veggie", "Veggie",
"Meat lovers" "Scampi mampi", "Meat lovers",
"Scampi mampi",
"Tabasco", "Tabasco",
"Chicken time", "Chicken time",
"Meatballs", "Meatballs",
@ -33,6 +35,7 @@ pizzas = [
def add() -> None: def add() -> None:
"Add Simpizza to the database"
simpizza = Location() simpizza = Location()
simpizza.configure( simpizza.configure(
"Sim-pizza", "Sim-pizza",

View file

@ -1,3 +1,4 @@
"Script to add Stefanos to Haldis"
from app import db from app import db
from models import Location, Product from models import Location, Product
@ -101,12 +102,13 @@ data = [special_bickies, specials, vlezekes, friet]
def add() -> None: def add() -> None:
"Add Stefanos to the database"
stefanos = Location() stefanos = Location()
stefanos.configure( stefanos.configure(
"Stefano's Place", "Stefano's Place",
"Overpoortstraat 12 9000 Gent", "Overpoortstraat 12 9000 Gent",
"tel: geen", "tel: geen",
"https://www.facebook.com/pages/category/Fast-Food-Restaurant/Stefanos-Place-370774480004139/", "https://www.facebook.com/pages/category/Fast-Food-Restaurant/Stefanos-Place-370774480004139/", # pylint: disable=C0301
) )
db.session.add(stefanos) db.session.add(stefanos)
@ -120,8 +122,8 @@ def add() -> None:
bicky_cheese.configure(stefanos, name + " cheese", price + 30) bicky_cheese.configure(stefanos, name + " cheese", price + 30)
db.session.add(bicky_cheese) db.session.add(bicky_cheese)
for dict in data: for dictionary in data:
for name, price in dict.items(): for name, price in dictionary.items():
item = Product() item = Product()
item.configure(stefanos, name, price) item.configure(stefanos, name, price)
db.session.add(item) db.session.add(item)

View file

@ -1,3 +1,4 @@
"Script for interaction and changes to the database"
import add_admins import add_admins
import add_fitchen import add_fitchen
import add_oceans_garden import add_oceans_garden
@ -17,27 +18,30 @@ yes = ["yes", "y", "Y"]
no = ["no", "n", "N"] no = ["no", "n", "N"]
# Commit all the things
def commit() -> None: def commit() -> None:
"Commit all the things to the database"
db.session.commit() db.session.commit()
print("Committing successful") print("Committing successful")
def check_if_overwrite() -> bool: def check_if_overwrite() -> bool:
"Check if the user wants to overwrite the previous database"
answer = input("Do you want to overwrite the previous database? (y/N) ") answer = input("Do you want to overwrite the previous database? (y/N) ")
return answer in yes return answer in yes
def add_all() -> None: def add_all() -> None:
for entry_set in entry_sets.keys(): "Add all possible entries in the entry_sets to the database"
for entry_set, function in entry_sets.items():
print("Adding {}.".format(entry_set)) print("Adding {}.".format(entry_set))
entry_sets[entry_set]() function()
def recreate_from_scratch() -> None: def recreate_from_scratch() -> None:
confirmation = "Are you very very sure? (Will delete previous entries!) (y/N) " "Recreate a completely new database"
confirmation = "Are you very very sure? (Will delete previous entries!) (y/N) " # pylint: disable=C0301
check = "I acknowledge any repercussions!" check = "I acknowledge any repercussions!"
if input(confirmation) in yes and input("Type: '{}' ".format(check)) == check: if input(confirmation) in yes and input("Type: '{}' ".format(check)) == check: # pylint: disable=C0301
print("Resetting the database!") print("Resetting the database!")
db.drop_all() db.drop_all()
db.create_all() db.create_all()
@ -45,6 +49,7 @@ def recreate_from_scratch() -> None:
def add_to_current() -> None: def add_to_current() -> None:
"Add things to the current database"
available = [entry_set for entry_set in entry_sets] available = [entry_set for entry_set in entry_sets]
def add_numbers() -> str: def add_numbers() -> str:
@ -53,16 +58,14 @@ def add_to_current() -> None:
).rstrip(", ") ).rstrip(", ")
while input("Do you still want to add something? (Y/n) ") not in no: while input("Do you still want to add something? (Y/n) ") not in no:
print( print("What do you want to add? (Use numbers, or A for all, or C for cancel) ") # pylint: disable=C0301
"What do you want to add? (Use numbers, or A for all, or C for cancel) "
)
answer = input("Available: {} : ".format(add_numbers())) answer = input("Available: {} : ".format(add_numbers()))
if answer == "A": if answer == "A":
add_all() add_all()
available = [] available = []
elif answer == "C": elif answer == "C":
pass pass
elif answer.isnumeric() and answer in [str(x) for x in range(len(available))]: elif answer.isnumeric() and answer in [str(x) for x in range(len(available))]: # pylint: disable=C0301
answer_index = int(answer) answer_index = int(answer)
print("Adding {}.".format(available[answer_index])) print("Adding {}.".format(available[answer_index]))
entry_sets[str(available[answer_index])]() entry_sets[str(available[answer_index])]()
@ -74,7 +77,8 @@ def add_to_current() -> None:
manager = create_app() manager = create_app()
@manager.command @manager.command
def setup_database(): def setup_database(): #type: None
"Start the database interaction script"
print("Database modification script!") print("Database modification script!")
print("=============================\n\n") print("=============================\n\n")
if check_if_overwrite(): if check_if_overwrite():