mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Ready for alpha?
This commit is contained in:
0
__init__.py
Executable file → Normal file
0
__init__.py
Executable file → Normal file
1
data/shelf.json
Normal file
1
data/shelf.json
Normal file
File diff suppressed because one or more lines are too long
0
doxygen.conf
Executable file → Normal file
0
doxygen.conf
Executable file → Normal file
12
importBooks
Executable file
12
importBooks
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import pathlib
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from src.backend.pyShelf_ScanLibrary import execute_scan
|
||||||
|
|
||||||
|
PRG_PATH = pathlib.Path.cwd()
|
||||||
|
LIB_PATH = pathlib.Path.joinpath(PRG_PATH, "src", "backend", "lib")
|
||||||
|
sys.path.insert(0, PRG_PATH)
|
||||||
|
print("\n")
|
||||||
|
execute_scan(PRG_PATH)
|
||||||
2
pyproject.toml
Executable file → Normal file
2
pyproject.toml
Executable file → Normal file
@@ -7,4 +7,4 @@ use_parentheses = true
|
|||||||
# NOTE: the known_third_party setting is managed by
|
# NOTE: the known_third_party setting is managed by
|
||||||
# seed-isort-config and should not be modified directly.
|
# seed-isort-config and should not be modified directly.
|
||||||
# Any changes made to this setting will be overwritten.
|
# Any changes made to this setting will be overwritten.
|
||||||
known_third_party = ["PIL", "bs4", "django", "interface", "lib", "requests"]
|
known_third_party = ["bs4", "django", "interface", "requests"]
|
||||||
|
|||||||
0
requirements.txt
Executable file → Normal file
0
requirements.txt
Executable file → Normal file
0
src/__init__.py
Normal file
0
src/__init__.py
Normal file
2
src/backend/empty_bookshelf.sql
Normal file
2
src/backend/empty_bookshelf.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
delete from books;
|
||||||
|
delete from sqlite_sequence where name='books';
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
@@ -9,17 +10,17 @@ class Config:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
_fp = "config.json"
|
_fp = "config.json"
|
||||||
print(os.path)
|
|
||||||
|
|
||||||
def __init__(self, root=os.path.abspath("../../")):
|
def __init__(self, root):
|
||||||
_data = self.open_file(root)
|
_cp = pathlib.Path.joinpath(root, self._fp)
|
||||||
|
_data = self.open_file(_cp)
|
||||||
self.book_path = _data["BOOKPATH"]
|
self.book_path = _data["BOOKPATH"]
|
||||||
self.TITLE = _data["TITLE"]
|
self.TITLE = _data["TITLE"]
|
||||||
self.VERSION = _data["VERSION"]
|
self.VERSION = _data["VERSION"]
|
||||||
self.TITLE = self.TITLE + " ver " + self.VERSION
|
self.TITLE = self.TITLE + " ver " + self.VERSION
|
||||||
self.book_shelf = _data["BOOKSHELF"]
|
self.book_shelf = _data["BOOKSHELF"]
|
||||||
# self.catalogue_db = "data/catalogue.db"
|
# self.catalogue_db = "data/catalogue.db"
|
||||||
self.catalogue_db = root + "/" + _data["DATABASE"]
|
self.catalogue_db = str(root) + "/" + _data["DATABASE"]
|
||||||
self.file_array = [
|
self.file_array = [
|
||||||
self.book_shelf,
|
self.book_shelf,
|
||||||
self.catalogue_db,
|
self.catalogue_db,
|
||||||
@@ -27,7 +28,7 @@ class Config:
|
|||||||
self.root = root
|
self.root = root
|
||||||
self.auto_scan = True
|
self.auto_scan = True
|
||||||
|
|
||||||
def open_file(self, root):
|
def open_file(self, _cp):
|
||||||
with open(root + "/" + self._fp, "r") as read_file:
|
with open(str(_cp), "r") as read_file:
|
||||||
data = json.load(read_file)
|
data = json.load(read_file)
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
from .api_hooks import DuckDuckGo
|
from .api_hooks import DuckDuckGo
|
||||||
from .config import Config
|
from .config import Config
|
||||||
@@ -29,20 +29,21 @@ class Catalogue:
|
|||||||
self.book_shelf = config.book_shelf
|
self.book_shelf = config.book_shelf
|
||||||
self._book_list_expanded = None
|
self._book_list_expanded = None
|
||||||
self.books = None
|
self.books = None
|
||||||
|
self.db_pointer = config.catalogue_db
|
||||||
|
|
||||||
def scan_folder(self, _path=None):
|
def scan_folder(self, _path=None):
|
||||||
if _path is not None:
|
if _path is not None:
|
||||||
folder = _path
|
folder = _path
|
||||||
elif os.path.isdir(self.root_dir + "/" + self.book_folder):
|
elif os.path.isdir(str(self.root_dir) + "/" + self.book_folder):
|
||||||
folder = self.root_dir + "/" + self.book_folder
|
folder = str(self.root_dir) + "/" + self.book_folder
|
||||||
else:
|
else:
|
||||||
folder = self.book_folder
|
folder = self.book_folder
|
||||||
for f in os.listdir(folder):
|
for f in os.listdir(folder):
|
||||||
_path = os.path.abspath(folder + "/" + f)
|
_path = os.path.abspath(folder + "/" + f)
|
||||||
_is_dir = os.path.isdir(_path.strip() + "/")
|
if os.path.isdir(_path.strip() + "/"):
|
||||||
if _is_dir:
|
|
||||||
self.file_list.append(self.scan_folder(_path))
|
self.file_list.append(self.scan_folder(_path))
|
||||||
self.file_list.append(_path)
|
else:
|
||||||
|
self.file_list.append(_path)
|
||||||
|
|
||||||
def filter_books(self):
|
def filter_books(self):
|
||||||
"""
|
"""
|
||||||
@@ -125,7 +126,7 @@ class Catalogue:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def compare_shelf_current(self):
|
def compare_shelf_current(self):
|
||||||
db = Storage()
|
db = Storage(self.db_pointer)
|
||||||
stored = db.book_paths_list()
|
stored = db.book_paths_list()
|
||||||
closed = db.close()
|
closed = db.close()
|
||||||
if self.books is None:
|
if self.books is None:
|
||||||
@@ -141,7 +142,7 @@ class Catalogue:
|
|||||||
|
|
||||||
def import_books(self, list=None):
|
def import_books(self, list=None):
|
||||||
book_list = self.compare_shelf_current()
|
book_list = self.compare_shelf_current()
|
||||||
db = Storage()
|
db = Storage(self.db_pointer)
|
||||||
for book in book_list:
|
for book in book_list:
|
||||||
book = self.process_book(book)
|
book = self.process_book(book)
|
||||||
extracted = self.extract_metadata(book)
|
extracted = self.extract_metadata(book)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
from .config import Config
|
from .config import Config
|
||||||
from .storage import Storage
|
from .storage import Storage
|
||||||
@@ -12,11 +13,16 @@ class InitFiles:
|
|||||||
"""First run file creation operations"""
|
"""First run file creation operations"""
|
||||||
|
|
||||||
def __init__(self, file_array):
|
def __init__(self, file_array):
|
||||||
print("Begining creation of file structure")
|
print("Checking for program files")
|
||||||
for _pointer in file_array:
|
for _pointer in file_array:
|
||||||
|
time.sleep(1)
|
||||||
if not os.path.isfile(_pointer):
|
if not os.path.isfile(_pointer):
|
||||||
self.CreateFile(_pointer)
|
self.CreateFile(_pointer)
|
||||||
print("Concluded file creation")
|
print("%s created" % _pointer)
|
||||||
|
else:
|
||||||
|
print("%s present" % _pointer)
|
||||||
|
time.sleep(1)
|
||||||
|
print("File check complete.")
|
||||||
|
|
||||||
def CreateFile(self, _pointer):
|
def CreateFile(self, _pointer):
|
||||||
"""Create the file"""
|
"""Create the file"""
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from .config import Config
|
|||||||
class Storage:
|
class Storage:
|
||||||
"""Contains all methods for system storage"""
|
"""Contains all methods for system storage"""
|
||||||
|
|
||||||
def __init__(self, db_pointer=None):
|
def __init__(self, db_pointer):
|
||||||
# Optionaly pass db_file to specify another db or for testing
|
# Optionaly pass db_file to specify another db or for testing
|
||||||
if db_pointer is None:
|
if db_pointer is None:
|
||||||
db_pointer = Config().catalogue_db
|
db_pointer = Config().catalogue_db
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
from lib.config import Config
|
from .lib.config import Config
|
||||||
from lib.library import Catalogue
|
from .lib.library import Catalogue
|
||||||
from lib.pyShelf import InitFiles
|
from .lib.pyShelf import InitFiles
|
||||||
|
|
||||||
ROOT_DIR = os.path.abspath("../..")
|
sys.path.append(os.path.abspath("."))
|
||||||
sys.path.append(ROOT_DIR)
|
|
||||||
config = Config(ROOT_DIR) # Get configuration settings
|
|
||||||
InitFiles(config.file_array) # Initialize file system
|
def execute_scan(root):
|
||||||
Catalogue = Catalogue(config) # Open the Catalogue
|
_t1 = time.time()
|
||||||
Catalogue.import_books() # Filter Your books
|
config = Config(root) # Get configuration settings
|
||||||
|
InitFiles(config.file_array) # Initialize file system
|
||||||
|
catalogue = Catalogue(config) # Open the Catalogue
|
||||||
|
catalogue.import_books()
|
||||||
|
_t2 = time.time()
|
||||||
|
scan_time = round(_t2 - _t1)
|
||||||
|
print("Scan Completed.")
|
||||||
|
print("Scan Time %s seconds" % scan_time)
|
||||||
|
|||||||
BIN
src/db.sqlite3
BIN
src/db.sqlite3
Binary file not shown.
Reference in New Issue
Block a user