aboutsummaryrefslogtreecommitdiff
path: root/library_info_cli.py
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-07-10 20:46:08 -0400
committerB. Stack <bgstack15@gmail.com>2024-07-10 20:46:08 -0400
commit230ed709a0631c4bd539cf698e0172a260f3bafd (patch)
treeb5759fa370a39cc56117098c2cb6f0c0efb38ae8 /library_info_cli.py
parentadd el8+py3.6 support (diff)
downloadlibrary-info-230ed709a0631c4bd539cf698e0172a260f3bafd.tar.gz
library-info-230ed709a0631c4bd539cf698e0172a260f3bafd.tar.bz2
library-info-230ed709a0631c4bd539cf698e0172a260f3bafd.zip
prepare for reservations
Diffstat (limited to 'library_info_cli.py')
-rwxr-xr-xlibrary_info_cli.py21
1 files changed, 12 insertions, 9 deletions
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("</head>\n")
prn("<body>\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("<span class='eighty'>Last modified: " + now.strftime("%FT%TZ") + "</span>\n")
- if len(items):
+ prn("<h2>Checkouts</h2>\n")
+ if len(checkouts):
prn("<table class='display' id='checkouts'>\n")
prn(f"<thead><tr><th>Patron</th><th>barcode</th><th>due</th><th>format</th><th>cover</th><th>Title</th></tr></thead>\n")
prn("<tbody>\n")
- for i in items:
+ for i in checkouts:
prn(f"<tr>")
prn(f"<td>{i['patron']}</td>")
prn(f"<td>{i['barcode']}</td>")
@@ -112,6 +113,8 @@ def html(items):
prn(f"</tr>\n")
prn(f"</tbody>\n")
prn(f"</table>\n")
+ else:
+ prn(f"No checkouts.\n")
prn(f"</body>\n")
prn(f"<footer>\n")
prn(f"</footer>\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}.")
bgstack15