treewide: format

This commit is contained in:
2026-02-04 00:01:38 +09:00
parent b5b2706085
commit c2ee66c394
7 changed files with 29 additions and 19 deletions

View File

@@ -1,4 +1,3 @@
# import barcode
# from brother_ql.brother_ql_create import create_label
# from brother_ql.raster import BrotherQLRaster

View File

@@ -35,9 +35,9 @@ def main():
engine = create_engine(config_db_string())
sql_session = Session(
engine,
expire_on_commit=False,
autoflush=False,
engine,
expire_on_commit=False,
autoflush=False,
)
if args.subcommand == "loop":

View File

@@ -142,7 +142,8 @@ much money you're due in credits for the purchase when prompted.\n"""
ceil(float(value) / (max(product.stock, 0) + self.products[product][0])),
)
product.stock = max(
self.products[product][0], product.stock + self.products[product][0],
self.products[product][0],
product.stock + self.products[product][0],
)
product.hidden = False
print(

View File

@@ -162,7 +162,8 @@ When finished, write an empty line to confirm the purchase.\n"""
if thing is None:
if not self.complete_input():
if self.confirm(
"Not enough information entered. Abort purchase?", default=True,
"Not enough information entered. Abort purchase?",
default=True,
):
return False
continue
@@ -219,7 +220,10 @@ When finished, write an empty line to confirm the purchase.\n"""
string += "(empty)"
else:
string += ", ".join(
[t.user.name + ("*" if not self.credit_check(t.user) else "") for t in transactions],
[
t.user.name + ("*" if not self.credit_check(t.user) else "")
for t in transactions
],
)
string += "\n products: "
if len(entries) == 0:

View File

@@ -433,9 +433,10 @@ class Menu:
selection = selector.execute()
if selection == "create":
username = self.input_str(
"Username for new user (should be same as PVV username)",
User.name_re,
(1, 10),
prompt="Username for new user (should be same as PVV username)",
end_prompt=None,
regex=User.name_re,
length_range=(1, 10),
)
user = User(username, string)
self.sql_session.add(user)
@@ -625,7 +626,9 @@ class ConfirmMenu(Menu):
options = {True: "[y]/n", False: "y/[n]", None: "y/n"}[self.default]
while True:
result = self.input_str(
f"{self.prompt} ({options})", end_prompt=": ", timeout=self.timeout,
f"{self.prompt} ({options})",
end_prompt=": ",
timeout=self.timeout,
)
result = result.lower().strip()
if result in ["y", "yes"]:

View File

@@ -212,11 +212,15 @@ class ProductSearchMenu(Menu):
self.print_header()
self.set_context("Enter (part of) product name or bar code")
product = self.input_product()
print(", ".join([
f"Result: {product.name}",
f"price: {product.price} kr",
f"bar code: {product.bar_code}",
f"stock: {product.stock}",
f"hidden: {'Y' if product.hidden else 'N'}",
]))
print(
", ".join(
[
f"Result: {product.name}",
f"price: {product.price} kr",
f"bar code: {product.bar_code}",
f"stock: {product.stock}",
f"hidden: {'Y' if product.hidden else 'N'}",
]
)
)
# self.pause()

View File

@@ -1,4 +1,3 @@
from sqlalchemy.orm import Session
# from dibbler.lib.printer_helpers import print_bar_code, print_name_label