From 230ed709a0631c4bd539cf698e0172a260f3bafd Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Wed, 10 Jul 2024 20:46:08 -0400 Subject: prepare for reservations --- library_info_cli.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'library_info_cli.py') diff --git a/library_info_cli.py b/library_info_cli.py index 57b9188..b77e9f4 100755 --- a/library_info_cli.py +++ b/library_info_cli.py @@ -61,7 +61,7 @@ def serialize(item): eprint(f"WARNING: unknown type {type(item)} for json-serializing object {item}") return item -def html(items): +def html(checkouts): # Uses https://datatables.net/download/builder?dt/jq-3.7.0/dt-2.0.8/cr-2.0.3/fh-4.0.1 # with css corrected by having the utf-8 line at the top of the .min.css file. """ Make an html of the items """ @@ -78,7 +78,7 @@ def html(items): prn("\n") prn("\n") seen_accounts = [] - for i in items: + for i in checkouts: if i["patron"] not in seen_accounts: seen_accounts.append(i["patron"]) if seen_accounts: @@ -91,11 +91,12 @@ def html(items): except AttributeError: now = datetime.datetime.utcnow() prn("Last modified: " + now.strftime("%FT%TZ") + "\n") - if len(items): + prn("

Checkouts

\n") + if len(checkouts): prn("\n") prn(f"\n") prn("\n") - for i in items: + for i in checkouts: prn(f"") prn(f"") prn(f"") @@ -112,6 +113,8 @@ def html(items): prn(f"\n") prn(f"\n") prn(f"
PatronbarcodedueformatcoverTitle
{i['patron']}{i['barcode']}
\n") + else: + prn(f"No checkouts.\n") prn(f"\n") prn(f"\n") @@ -132,14 +135,14 @@ if "__main__" == __name__: if debuglevel >= 1: eprint(args) if single: - items = library_info_lib.get_single_checkouts(alias = single, full_images = full_images, verbose = debuglevel >= 5) + checkouts = library_info_lib.get_single_checkouts(alias = single, full_images = full_images, verbose = debuglevel >= 5) else: - items = library_info_lib.get_all_checkouts(full_images = full_images, verbose = debuglevel >= 5) + checkouts = library_info_lib.get_all_checkouts(full_images = full_images, verbose = debuglevel >= 5) if "raw" == output: - print(items) + print(checkouts) elif "json" == output: - print(json.dumps(items,default=serialize)) + print(json.dumps(checkouts,default=serialize)) elif "html" == output: - html(items) + html(checkouts) else: print(f"Error! Invalid choice for output format {output}.") -- cgit