aboutsummaryrefslogtreecommitdiff
path: root/library_info_lib.py
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-07-09 15:11:26 -0400
committerB. Stack <bgstack15@gmail.com>2024-07-09 15:11:26 -0400
commit516263ea51350514571deafc70b14f9f19d760d8 (patch)
tree9da665d2e3eee383335c5f2ecc82dd649824ed66 /library_info_lib.py
downloadlibrary-info-516263ea51350514571deafc70b14f9f19d760d8.tar.gz
library-info-516263ea51350514571deafc70b14f9f19d760d8.tar.bz2
library-info-516263ea51350514571deafc70b14f9f19d760d8.zip
initial commit
Diffstat (limited to 'library_info_lib.py')
-rw-r--r--library_info_lib.py52
1 files changed, 52 insertions, 0 deletions
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
bgstack15