mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Added close method, and finished compare_shelf_current
This commit is contained in:
@@ -123,14 +123,17 @@ class Catalogue:
|
|||||||
except KeyError: return False
|
except KeyError: return False
|
||||||
|
|
||||||
def compare_shelf_current(self):
|
def compare_shelf_current(self):
|
||||||
stored_books = Storage()
|
db = Storage()
|
||||||
stored_books = stored_books.book_paths_list()
|
stored = db.book_paths_list()
|
||||||
try:
|
closed = db.close()
|
||||||
self.books
|
try: self.books
|
||||||
except Exception:
|
except Exception: self.filter_books()
|
||||||
self.filter_books()
|
on_disk, in_storage = [], []
|
||||||
unique = set(self.books) - set(stored_books)
|
for _x in self.books: on_disk.append(_x)
|
||||||
return unique
|
for _y in stored: in_storage.append(_y[0])
|
||||||
|
a, b, = set(on_disk), set(in_storage)
|
||||||
|
c = set.difference(a, b)
|
||||||
|
return c
|
||||||
|
|
||||||
def import_books(self, list=None):
|
def import_books(self, list=None):
|
||||||
book_list = self.compare_shelf_current()
|
book_list = self.compare_shelf_current()
|
||||||
@@ -139,4 +142,7 @@ class Catalogue:
|
|||||||
book = self.process_book(book)
|
book = self.process_book(book)
|
||||||
extracted = self.extract_metadata(book)
|
extracted = self.extract_metadata(book)
|
||||||
db.insert_book(extracted)
|
db.insert_book(extracted)
|
||||||
db.commit()
|
inserted = db.commit()
|
||||||
|
if inserted != True:
|
||||||
|
print(inserted)
|
||||||
|
db.close()
|
||||||
Reference in New Issue
Block a user