mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Added basic documentation to all backend objects
This commit is contained in:
6
docs/html/HTML/index.html
vendored
6
docs/html/HTML/index.html
vendored
@@ -1,16 +1,16 @@
|
||||
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
|
||||
<html xmlns='http://www.w3.org/1999/xhtml'>
|
||||
<head>
|
||||
<title>pyShelf Open Source Ebook Server-0.2.0</title>
|
||||
<title>pyShelf Open Source Ebook Server-0.2.1</title>
|
||||
<meta name='robots' content='noindex,nofollow' />
|
||||
<meta name='generator' content='GLOBAL-6.6.3' />
|
||||
<meta http-equiv='Content-Style-Type' content='text/css' />
|
||||
<link rel='stylesheet' type='text/css' href='style.css' />
|
||||
</head>
|
||||
<body>
|
||||
<h1 class='title'>pyShelf Open Source Ebook Server-0.2.0</h1>
|
||||
<h1 class='title'>pyShelf Open Source Ebook Server-0.2.1</h1>
|
||||
<div class='poweredby'>
|
||||
Last updated Fri Nov 29 22:17:44 EST 2019<br />
|
||||
Last updated Sun Dec 01 12:33:10 EST 2019<br />
|
||||
Powered by <a href='http://www.gnu.org/software/global/' title='Go to the GLOBAL project page.'>GLOBAL-6.6.3</a>.<br />
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
6
docs/html/HTML/mains.html
vendored
6
docs/html/HTML/mains.html
vendored
@@ -1,16 +1,16 @@
|
||||
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
|
||||
<html xmlns='http://www.w3.org/1999/xhtml'>
|
||||
<head>
|
||||
<title>pyShelf Open Source Ebook Server-0.2.0</title>
|
||||
<title>pyShelf Open Source Ebook Server-0.2.1</title>
|
||||
<meta name='robots' content='noindex,nofollow' />
|
||||
<meta name='generator' content='GLOBAL-6.6.3' />
|
||||
<meta http-equiv='Content-Style-Type' content='text/css' />
|
||||
<link rel='stylesheet' type='text/css' href='style.css' />
|
||||
</head>
|
||||
<body>
|
||||
<h1 class='title'>pyShelf Open Source Ebook Server-0.2.0</h1>
|
||||
<h1 class='title'>pyShelf Open Source Ebook Server-0.2.1</h1>
|
||||
<div class='poweredby'>
|
||||
Last updated Fri Nov 29 22:17:44 EST 2019<br />
|
||||
Last updated Sun Dec 01 12:33:10 EST 2019<br />
|
||||
Powered by <a href='http://www.gnu.org/software/global/' title='Go to the GLOBAL project page.'>GLOBAL-6.6.3</a>.<br />
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
2
docs/html/HTML/rebuild.sh
vendored
2
docs/html/HTML/rebuild.sh
vendored
@@ -5,4 +5,4 @@
|
||||
# Usage:
|
||||
# % sh rebuild.sh
|
||||
#
|
||||
cd /home/raelon/Projects/pyShelf && GTAGSCONF=':langmap=c\:.c.h,yacc\:.y,asm\:.s.S,java\:.java,cpp\:.c++.cc.hh.cpp.cxx.hxx.hpp.C.H,php\:.php.php3.phtml:skip=HTML/,HTML.pub/,tags,TAGS,ID,y.tab.c,y.tab.h,gtags.files,cscope.files,cscope.out,cscope.po.out,cscope.in.out,SCCS/,RCS/,CVS/,CVSROOT/,{arch}/,autom4te.cache/,*.orig,*.rej,*.bak,*~,#*#,*.swp,*.tmp,*_flymake.*,*_flymake,*.o,*.a,*.so,*.lo,*.zip,*.gz,*.bz2,*.xz,*.lzh,*.Z,*.tgz,*.min.js,*min.css:' htags -g -s -a -n -v -w -t 'pyShelf Open Source Ebook Server-0.2.0' /home/raelon/Projects/pyShelf/docs/html
|
||||
cd /home/raelon/Projects/pyShelf && GTAGSCONF=':langmap=c\:.c.h,yacc\:.y,asm\:.s.S,java\:.java,cpp\:.c++.cc.hh.cpp.cxx.hxx.hpp.C.H,php\:.php.php3.phtml:skip=HTML/,HTML.pub/,tags,TAGS,ID,y.tab.c,y.tab.h,gtags.files,cscope.files,cscope.out,cscope.po.out,cscope.in.out,SCCS/,RCS/,CVS/,CVSROOT/,{arch}/,autom4te.cache/,*.orig,*.rej,*.bak,*~,#*#,*.swp,*.tmp,*_flymake.*,*_flymake,*.o,*.a,*.so,*.lo,*.zip,*.gz,*.bz2,*.xz,*.lzh,*.Z,*.tgz,*.min.js,*min.css:' htags -g -s -a -n -v -w -t 'pyShelf Open Source Ebook Server-0.2.1' /home/raelon/Projects/pyShelf/docs/html
|
||||
|
||||
4
docs/html/index.html
vendored
4
docs/html/index.html
vendored
@@ -19,7 +19,7 @@
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">pyShelf Open Source Ebook Server
|
||||
 <span id="projectnumber">0.2.0</span>
|
||||
 <span id="projectnumber">0.2.1</span>
|
||||
</div>
|
||||
<div id="projectbrief">Open source, console based E-book server</div>
|
||||
</td>
|
||||
@@ -47,7 +47,7 @@ $(function() {
|
||||
</div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated on Fri Nov 29 2019 22:17:44 for pyShelf Open Source Ebook Server by  <a href="http://www.doxygen.org/index.html">
|
||||
Generated on Sun Dec 1 2019 12:33:10 for pyShelf Open Source Ebook Server by  <a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
||||
</a> 1.8.16
|
||||
</small></address>
|
||||
|
||||
48
requirements
vendored
Normal file
48
requirements
vendored
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
BIN
src/db.sqlite3
vendored
BIN
src/db.sqlite3
vendored
Binary file not shown.
@@ -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",},
|
||||
),
|
||||
]
|
||||
|
||||
34
src/interface/models.py
Executable file
34
src/interface/models.py
Executable file
@@ -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)])
|
||||
Reference in New Issue
Block a user