From 684b84c78cf65c767ffcf077ed7f89106a1acf26 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Wed, 10 Jul 2024 23:07:49 -0400 Subject: use reservations in all get_ calls --- library_info_cli.py | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'library_info_cli.py') diff --git a/library_info_cli.py b/library_info_cli.py index b77e9f4..7dfd640 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(checkouts): +def html(checkouts, reservations): # 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 """ @@ -115,6 +115,28 @@ def html(checkouts): prn(f"\n") else: prn(f"No checkouts.\n") + prn("

Reservations

\n") + if len(reservations): + prn(f"\n") + prn(f"\n") + prn("\n") + for i in reservations: + prn(f"") + prn(f"") + prn(f"") + prn(f"") + prn(f"") + if "img" in i: + img_src = i["img"] + else: + img_src = "" + prn(f"") + prn(f"") + prn(f"\n") + prn(f"\n") + prn(f"
Date placedlocationpositionstatuscovertitle
{i['date_placed']}{i['location']}{i['position']}{i['status']}{i['title']}
\n") + else: + prn("No reservations.\n") prn(f"\n") prn(f"\n") @@ -124,8 +146,10 @@ def html(checkouts): prn(""" """) @@ -135,14 +159,15 @@ if "__main__" == __name__: if debuglevel >= 1: eprint(args) if single: - checkouts = library_info_lib.get_single_checkouts(alias = single, full_images = full_images, verbose = debuglevel >= 5) + checkouts, reservations = library_info_lib.get_single_configitem(alias = single, full_images = full_images, verbose = debuglevel >= 5) else: - checkouts = library_info_lib.get_all_checkouts(full_images = full_images, verbose = debuglevel >= 5) + checkouts, reservations = library_info_lib.get_all_configitems(full_images = full_images, verbose = debuglevel >= 5) if "raw" == output: print(checkouts) + print(reservations) elif "json" == output: print(json.dumps(checkouts,default=serialize)) elif "html" == output: - html(checkouts) + html(checkouts, reservations) else: print(f"Error! Invalid choice for output format {output}.") -- cgit