From 516263ea51350514571deafc70b14f9f19d760d8 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Tue, 9 Jul 2024 15:11:26 -0400 Subject: initial commit --- library_info_lib.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 library_info_lib.py (limited to 'library_info_lib.py') diff --git a/library_info_lib.py b/library_info_lib.py new file mode 100644 index 0000000..202ec71 --- /dev/null +++ b/library_info_lib.py @@ -0,0 +1,52 @@ +# File: library_info_lib.py +# Author: bgstack15 +# Startdate: 2024-07-06-7 08:04 +# SPDX-License-Identifier: GPL-3.0-only +# Title: Library for library_info +# Project: library_info +# Purpose: program library that pulls info from book library websites +# History: +# Usage: +# Reference: +# Improve: +# add library card expiration date +# add reserved item status +# Dependencies: + +import sys, os +import libraries +from config import config + +def get_all_checkouts(full_images = True, verbose = False): + # get all checked out items + checkouts = [] + for i in config: + #print(f"Found config entry {i}") + instance = i["class"](i) + checkouts += instance.get_checkouts(verbose = verbose) + if not full_images: + checkouts = trim_full_images(checkouts) + return checkouts + +def get_single_checkouts(alias = None, full_images = True, verbose = False): + checkouts = [] + this_config = [i for i in config if i["alias"] == alias] + if not this_config: + raise Exception(f"Alias not found: {alias}") + # so now we know we have this_config: + for i in this_config: + instance = i["class"](i) + checkouts += instance.get_checkouts(verbose=verbose) + if not full_images: + checkouts = trim_full_images(checkouts) + return checkouts + +def trim_full_images(checkouts = []): + output = [] + for i in checkouts: + try: + i.pop("img") + except: + pass + output.append(i) + return output -- cgit