def __init__( self, lib_name: str, ): """Initializes constructor""" if self._valid_string(lib_name, "library_name"): self._lib_name = lib_name.strip() self._catalog = list(Books.select()) + list(Multimedia.select())
def get_items_by_type(self, type_): """Returns items by type""" if self._valid_string(type_, "type"): items = [] if type_ == "books": return Books.select() elif type_ == "multimedia": return Multimedia.select() else: return items
def get_item_by_isbn(self, isbn): """Returns item in the catalog with matching ISBN""" if self._is_valid_isbn(isbn): try: item = (Books.select().where(Books.isbn == isbn) or Multimedia.select().where( Multimedia.isbn == isbn)).get() return item except: return None
def get_borrow_items(self): """Returns a list of borrowed items in the catalog""" items = [] items = list(Books.select().where(Books.is_borrowed)) + list( Multimedia.select().where(Multimedia.is_borrowed)) return items
def get_all_items(self): """Returns a list of all items in the catalog""" return list(Books.select()) + list(Multimedia.select())