mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Refactored collection pathing algorithm. Lessened verbosity of logging.
This commit is contained in:
9
src/backend/lib/storage.py
vendored
9
src/backend/lib/storage.py
vendored
@@ -101,7 +101,7 @@ class Storage:
|
|||||||
session.add(_book)
|
session.add(_book)
|
||||||
session.commit()
|
session.commit()
|
||||||
session.close()
|
session.close()
|
||||||
self.config.logger.info(book[0][0:80])
|
# self.config.logger.info(book[0][0:80])
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.config.logger.error(f"{book[0][0:80]} :: {e}")
|
self.config.logger.error(f"{book[0][0:80]} :: {e}")
|
||||||
@@ -158,12 +158,13 @@ class Storage:
|
|||||||
for book in _set:
|
for book in _set:
|
||||||
path = self.config.book_path + "/"
|
path = self.config.book_path + "/"
|
||||||
_collections = []
|
_collections = []
|
||||||
_pathing = book[1].split(path)[1].split("/")
|
|
||||||
try:
|
try:
|
||||||
|
_pathing = book[1].split(path)[1].split("/")
|
||||||
_pathing.pop(0)
|
_pathing.pop(0)
|
||||||
_pathing.pop(-1)
|
_pathing.pop(-1)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
continue
|
continue # Skip if path is invalid eg. a book with no con-
|
||||||
|
# taining folder
|
||||||
for _p in _pathing:
|
for _p in _pathing:
|
||||||
_s = _p.replace("'", "")
|
_s = _p.replace("'", "")
|
||||||
_x = re.sub(_title_regx, "", _s)
|
_x = re.sub(_title_regx, "", _s)
|
||||||
@@ -183,7 +184,7 @@ class Storage:
|
|||||||
_sess.add(_collection)
|
_sess.add(_collection)
|
||||||
_sess.commit()
|
_sess.commit()
|
||||||
_sess.close()
|
_sess.close()
|
||||||
self.config.logger.info(f"Collection {_s} added.")
|
# self.config.logger.info(f"Collection {_s} added.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.config.logger.error(f"Collection {_s} failed: {e}")
|
self.config.logger.error(f"Collection {_s} failed: {e}")
|
||||||
_collections.append(_p)
|
_collections.append(_p)
|
||||||
|
|||||||
Reference in New Issue
Block a user