diff --git a/docs/html/HTML/index.html b/docs/html/HTML/index.html index 1fc2c79..8ec77e1 100755 --- a/docs/html/HTML/index.html +++ b/docs/html/HTML/index.html @@ -1,16 +1,16 @@
-
1.8.16
diff --git a/requirements b/requirements
new file mode 100644
index 0000000..6815d6f
--- /dev/null
+++ b/requirements
@@ -0,0 +1,48 @@
+appdirs==1.4.3
+aspy.yaml==1.3.0
+astroid==2.3.3
+attrs==19.3.0
+beautifulsoup4==4.8.1
+black==19.10b0
+bs4==0.0.1
+certifi==2019.9.11
+cfgv==2.0.1
+chardet==3.0.4
+Click==7.0
+Django==2.2.7
+django-debug-toolbar==2.1
+greenlet==0.4.15
+identify==1.4.7
+idna==2.8
+isort==4.3.21
+lazy-object-proxy==1.4.3
+lxml==4.4.1
+mccabe==0.6.1
+msgpack==0.6.2
+nodeenv==1.3.3
+Paste==3.2.2
+pathspec==0.6.0
+Pillow==6.2.1
+pre-commit==1.20.0
+ptvsd==4.3.2
+pudb==2019.1
+Pygments==2.4.2
+pylint==2.4.4
+pynvim==0.4.0
+pytz==2019.3
+PyYAML==5.1.2
+regex==2019.11.1
+requests==2.22.0
+six==1.13.0
+soupsieve==1.9.5
+sqlparse==0.3.0
+toml==0.10.0
+typed-ast==1.4.0
+urllib3==1.25.7
+urwid==2.1.0
+uWSGI==2.0.18
+virtualenv==16.7.7
+w3lib==1.21.0
+websockets==8.1
+wrapt==1.11.2
+xsendfile==1.0rc2
diff --git a/src/backend/lib/config.py b/src/backend/lib/config.py
index 1faf0ac..76347df 100755
--- a/src/backend/lib/config.py
+++ b/src/backend/lib/config.py
@@ -32,6 +32,9 @@ class Config:
self.auto_scan = True
def open_file(self, _cp):
+ """
+ Opens config.json and reads in configuration options
+ """
with open(str(_cp), "r") as read_file:
data = json.load(read_file)
return data
diff --git a/src/backend/lib/library.py b/src/backend/lib/library.py
index 1af3262..a6c504a 100755
--- a/src/backend/lib/library.py
+++ b/src/backend/lib/library.py
@@ -15,9 +15,9 @@ from .storage import Storage
class Catalogue:
- """Decodes and stores book information"""
-
- """Step One: filter_books"""
+ """
+ Decodes book metadata for storage
+ """
def __init__(self, config):
self.file_list = []
@@ -33,6 +33,9 @@ class Catalogue:
self.config = config
def scan_folder(self, _path=None):
+ """
+ Scan folder by _path, allows recurisive scanning
+ """
if _path is not None:
folder = _path
elif os.path.isdir(str(self.root_dir) + "/" + self.book_folder):
@@ -48,11 +51,10 @@ class Catalogue:
def filter_books(self):
"""
- Scan book folder recursively for epub files
- filter_books(0) -> Catalogue.books
- filter_books(1) -> self.books[]
- :param ret: 0 -> create class property -> dump json
- :param ret: 1 -> create & return class property
+ Calls scan_folder and filters out book files
+ Proceeds to call process_book
+
+ :returns self._book_list_expanded: json string containing all book metadata
"""
self.scan_folder()
regx = re.compile(r"\.epub")
@@ -111,14 +113,23 @@ class Catalogue:
return book_details
def extract_content(self, book_zip, book):
+ """
+ Opens epub as zip file filters then stores as list any files matching opf_regx
+ """
content = book_zip.open(list(filter(self.opf_regx.search, book["files"]))[0])
return content
def extract_cover_html(self, book_zip, book):
+ """
+ Opens epub as zip file filters then stores as list any files matching html_regx
+ """
cover = book_zip.open(list(filter(self.html_regx.search, book["files"]))[0])
return cover
def extract_cover_image(self, book_zip, book):
+ """
+ Opens epub as zip file filters then stores as list any files matching cover_regx
+ """
cover = book_zip.open(list(filter(self.cover_regx.search, book["files"]))[0])
try:
cover = book_zip.read(cover.name)
@@ -127,6 +138,9 @@ class Catalogue:
return False
def compare_shelf_current(self):
+ """
+ Calls storage system, gets list of books stored and compares against files on disk
+ """
db = Storage(self.db_pointer, self.config)
stored = db.book_paths_list()
closed = db.close()
@@ -142,6 +156,11 @@ class Catalogue:
return c
def import_books(self, list=None):
+ """
+ Main entry point for import operations.
+ Gets a list of new files via compare_shelf_current.
+ Iterates over list and inserts new books into database.
+ """
book_list = self.compare_shelf_current()
db = Storage(self.db_pointer, self.config)
for book in book_list:
diff --git a/src/backend/lib/pyShelf.py b/src/backend/lib/pyShelf.py
index 3e41029..d19d3e5 100755
--- a/src/backend/lib/pyShelf.py
+++ b/src/backend/lib/pyShelf.py
@@ -25,7 +25,9 @@ class InitFiles:
print("File check complete.")
def CreateFile(self, _pointer):
- """Create the file"""
+ """
+ Checks if file exists and creates it if not
+ """
if not os.path.isdir(os.path.split(_pointer)[0]):
os.mkdir(os.path.split(_pointer)[0])
f = open(_pointer, "w+")
@@ -52,6 +54,7 @@ class BookDisplay:
def nextPage(self):
"""
+ ## TODO Remove me
Goto next book page
:return: new current_page
"""
@@ -60,6 +63,7 @@ class BookDisplay:
def previousPage(self):
"""
+ ## TODO Remove me
Goto previous book page
:return: new current_page
"""
@@ -68,8 +72,8 @@ class BookDisplay:
def booksPerPage(self, screen_size):
"""
+ ## TODO Remove me
Set books per page
-
:param screen_size: Array containing x,y pixel sizes
:return: self.books_per_page
"""
diff --git a/src/backend/lib/storage.py b/src/backend/lib/storage.py
index 26b42a2..51b33bf 100755
--- a/src/backend/lib/storage.py
+++ b/src/backend/lib/storage.py
@@ -69,6 +69,9 @@ class Storage:
return False
def book_paths_list(self):
+ """
+ Get file paths from database for comparison to system files
+ """
q = """SELECT file_name FROM books"""
x = self.cursor.execute(q)
try:
@@ -78,6 +81,9 @@ class Storage:
return x
def commit(self):
+ """
+ Commit database transactions
+ """
try:
self.db.commit()
return True
@@ -85,5 +91,8 @@ class Storage:
return e
def close(self):
+ """
+ Close database connection
+ """
self.db.close()
return True
diff --git a/src/backend/pyShelf_ScanLibrary.py b/src/backend/pyShelf_ScanLibrary.py
index 656626e..904ee3a 100755
--- a/src/backend/pyShelf_ScanLibrary.py
+++ b/src/backend/pyShelf_ScanLibrary.py
@@ -11,6 +11,10 @@ sys.path.append(os.path.abspath("."))
def execute_scan(root):
+ """
+ Main scan execution
+ :param root: Project root. Required to properly execute program. Sends to configuration.
+ """
_t1 = time.time()
config = Config(root) # Get configuration settings
InitFiles(config.file_array) # Initialize file system
diff --git a/src/db.sqlite3 b/src/db.sqlite3
index 5818d2b..e6964c4 100755
Binary files a/src/db.sqlite3 and b/src/db.sqlite3 differ
diff --git a/src/interface/migrations/0001_initial.py b/src/interface/migrations/0001_initial.py
index f9155d6..ab512f0 100644
--- a/src/interface/migrations/0001_initial.py
+++ b/src/interface/migrations/0001_initial.py
@@ -7,24 +7,29 @@ class Migration(migrations.Migration):
initial = True
- dependencies = [
- ]
+ dependencies = []
operations = [
migrations.CreateModel(
- name='Books',
+ name="Books",
fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('title', models.CharField(max_length=255)),
- ('author', models.CharField(max_length=255, null=True)),
- ('categories', models.CharField(max_length=255, null=True)),
- ('cover', models.BinaryField(editable=True, null=True)),
- ('pages', models.IntegerField(null=True)),
- ('progress', models.IntegerField(null=True)),
- ('file_name', models.CharField(max_length=255)),
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ ("title", models.CharField(max_length=255)),
+ ("author", models.CharField(max_length=255, null=True)),
+ ("categories", models.CharField(max_length=255, null=True)),
+ ("cover", models.BinaryField(editable=True, null=True)),
+ ("pages", models.IntegerField(null=True)),
+ ("progress", models.IntegerField(null=True)),
+ ("file_name", models.CharField(max_length=255)),
],
- options={
- 'db_table': 'books',
- },
+ options={"db_table": "books",},
),
]
diff --git a/src/interface/models.py b/src/interface/models.py
new file mode 100755
index 0000000..b2f5951
--- /dev/null
+++ b/src/interface/models.py
@@ -0,0 +1,34 @@
+from django.db import models
+
+# Create your models here.
+
+
+class Books(models.Model):
+ """
+ pyShelfs Book Database class
+ :param title: Book title
+ :param author: Author
+ :param categories: Categories <-- Not implemented
+ :param cover: Cover image BinaryField
+ :param pages: # of pages <-- Not implemented
+ :param progress: Reader percentage <-- Not implented
+ :param file_name: Path to book
+ """
+
+ class Meta:
+ db_table = "books"
+
+ def __str__(self):
+ return self.title
+
+ title = models.CharField(max_length=255)
+ author = models.CharField(max_length=255, null=True)
+ categories = models.CharField(max_length=255, null=True)
+ cover = models.BinaryField(null=True, editable=True)
+ pages = models.IntegerField(null=True)
+ progress = models.IntegerField(null=True)
+ file_name = models.CharField(max_length=255, null=False)
+
+ def get_absolute_url(self):
+ """Returns the url to access a particular instance of MyModelName."""
+ return reverse("model-detail-view", args=[str(self.id)])