@@ -36,7 +36,7 @@ def sort_data_by_priority(data: list[BookData]) -> list[BookData]:
|
||||
return sorted(data, key=lambda m: FETCHER_SOURCE_IDS.index(m.source))
|
||||
|
||||
|
||||
def fetch_book_data_from_multiple_sources(isbn: str, strict: bool=False) -> list[BookData]:
|
||||
def fetch_book_data_from_multiple_sources(isbn: str, strict: bool = False) -> list[BookData]:
|
||||
"""
|
||||
Returns a list of data fetched from multiple fetchers.
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ from worblehat.queries import (
|
||||
list_overdue_borrowings,
|
||||
)
|
||||
from worblehat.services import (
|
||||
Config,
|
||||
create_bookcase_item_from_isbn,
|
||||
is_valid_isbn,
|
||||
Config,
|
||||
)
|
||||
|
||||
from .subclis import (
|
||||
@@ -55,7 +55,7 @@ class WorblehatCli(NumberedCmd):
|
||||
while True:
|
||||
try:
|
||||
self.cmdloop()
|
||||
except KeyboardInterrupt:
|
||||
except KeyboardInterrupt:
|
||||
print("\n\n-----------------\n")
|
||||
self.do_exit("Exit")
|
||||
|
||||
|
||||
@@ -65,10 +65,7 @@ class AdvancedOptionsCli(NumberedCmd):
|
||||
continue
|
||||
break
|
||||
|
||||
if (
|
||||
find_bookcase_shelf(self.sql_session, bookcase, column, row)
|
||||
is not None
|
||||
):
|
||||
if find_bookcase_shelf(self.sql_session, bookcase, column, row) is not None:
|
||||
print(
|
||||
f"Error: a bookshelf in bookcase {bookcase.name} with position c{column}-r{row} already exists",
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ def select_bookcase_shelf(
|
||||
sql_session: Session,
|
||||
prompt: str = "Please select the shelf where the item is placed (col-row):",
|
||||
) -> BookcaseShelf:
|
||||
def __complete_bookshelf_selection(session: Session, cls: type, arg: str):
|
||||
def __complete_bookshelf_selection(session: Session, cls: type, arg: str) -> list[str]:
|
||||
args = arg.split("-")
|
||||
column = None
|
||||
row = None
|
||||
@@ -31,7 +31,7 @@ def select_bookcase_shelf(
|
||||
result = list_bookcase_shelf_positions(session, bookcase, column, row)
|
||||
return [f"{c}-{r}" for r, c in result]
|
||||
|
||||
def __execute_bookshelf_selection(session: Session, cls: type, arg: str):
|
||||
def __execute_bookshelf_selection(session: Session, cls: type, arg: str) -> list[BookcaseShelf]:
|
||||
shelf = find_bookcase_shelf(
|
||||
session,
|
||||
bookcase,
|
||||
|
||||
@@ -59,7 +59,9 @@ class SearchCli(NumberedCmd):
|
||||
else:
|
||||
selector = NumberedItemSelector(
|
||||
items=author,
|
||||
stringify=lambda author: f"{author.name} ({sum(item.amount for item in author.items)} items)",
|
||||
stringify=lambda author: (
|
||||
f"{author.name} ({sum(item.amount for item in author.items)} items)"
|
||||
),
|
||||
)
|
||||
selector.cmdloop()
|
||||
if selector.result is None:
|
||||
|
||||
@@ -18,10 +18,10 @@ from .services import (
|
||||
|
||||
|
||||
def _print_version() -> None:
|
||||
from ._version import commit_id, version
|
||||
from ._version import commit_id, version
|
||||
|
||||
print(f"Worblehat version {version}, commit {commit_id if commit_id else '<unknown>'}")
|
||||
return
|
||||
print(f"Worblehat version {version}, commit {commit_id if commit_id else '<unknown>'}")
|
||||
return
|
||||
|
||||
|
||||
def _connect_to_database(**engine_args) -> Session:
|
||||
|
||||
@@ -27,9 +27,7 @@ def search_bookcase_items_by_title(sql_session: Session, text: str) -> list[Book
|
||||
def search_bookcase_item_owners(sql_session: Session, text: str) -> list[str]:
|
||||
return list(
|
||||
sql_session.scalars(
|
||||
select(BookcaseItem.owner)
|
||||
.where(BookcaseItem.owner.ilike(f"%{text}%"))
|
||||
.distinct(),
|
||||
select(BookcaseItem.owner).where(BookcaseItem.owner.ilike(f"%{text}%")).distinct(),
|
||||
).all(),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user