feat(books): show completed books
This commit is contained in:
parent
797ab70d71
commit
e2a452914e
|
@ -14,7 +14,7 @@ if len(sys.argv) != 2:
|
|||
|
||||
base_path = os.path.abspath(sys.argv[1])
|
||||
ready_list_name = "ready.md"
|
||||
done_list_name = "all-done.md"
|
||||
completed_lists = ["2023.md", "2022.md", "202x.md"]
|
||||
|
||||
def get_path(list_name : str) -> str:
|
||||
return os.path.join(base_path, list_name)
|
||||
|
@ -55,9 +55,12 @@ class Book:
|
|||
return books
|
||||
|
||||
|
||||
def print_section(title : str, books : list[str]):
|
||||
def print_title(title : str, books : list[str]):
|
||||
print(f"# {title} ({len(books)})\n")
|
||||
|
||||
|
||||
def print_section(title : str, books : list[str]):
|
||||
print_title(title, books)
|
||||
longest_title = max([len(b.title) for b in books])
|
||||
title_column_width = longest_title + 2
|
||||
|
||||
|
@ -67,21 +70,49 @@ def print_section(title : str, books : list[str]):
|
|||
print(format_str.format(*row))
|
||||
print()
|
||||
|
||||
|
||||
def print_in_progress():
|
||||
books = [b for b in Book.get_list(ready_list_name, False) if b.mark]
|
||||
print_section("in progress", books)
|
||||
|
||||
|
||||
def print_completed():
|
||||
books = Book.get_list(done_list_name)
|
||||
print_section("up for borrowing", books)
|
||||
|
||||
completed_books = []
|
||||
summaries = []
|
||||
|
||||
for completed_list in completed_lists:
|
||||
books = [b for b in Book.get_list(completed_list)]
|
||||
year = completed_list.split(".")[0]
|
||||
completed_books += books
|
||||
summaries.append(f"{year} - {len(books)}")
|
||||
|
||||
print_title("completed", completed_books)
|
||||
|
||||
for s in summaries:
|
||||
print(s)
|
||||
|
||||
print()
|
||||
|
||||
|
||||
def print_available():
|
||||
books = []
|
||||
for completed_list in completed_lists:
|
||||
books += [b for b in Book.get_list(completed_list) if b.mark]
|
||||
print_section("available", books)
|
||||
|
||||
|
||||
def print_partial_metadata():
|
||||
books = Book.get_list(ready_list_name, False)
|
||||
books += Book.get_list(done_list_name, False)
|
||||
|
||||
for completed_list in completed_lists:
|
||||
books += Book.get_list(completed_list, False)
|
||||
|
||||
books = [b for b in books if not b.is_metadata_complete()]
|
||||
|
||||
print_section("metadata incomplete", books)
|
||||
|
||||
print_in_progress()
|
||||
print_completed()
|
||||
print_available()
|
||||
print_partial_metadata()
|
||||
|
|
Loading…
Reference in New Issue