Skip to content

python3 compatable re-write (rather than just 2to3) #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
529ed02
feat: re-write in progress
imgurbot12 Jun 21, 2020
ef3e6e1
fix: rename readme
imgurbot12 Jun 21, 2020
2704ea9
feat: v2 re-write of pypub library w/ tests
imgurbot12 Jun 21, 2020
cb0e9f2
feat: added debug logging, minor fixes/improvements
imgurbot12 Jun 21, 2020
22e4eaf
feat: doc upgrades to match py3 changes
imgurbot12 Jun 21, 2020
9963ed4
fix: template fixes, uuid/date modifed to valid inputs
imgurbot12 Jun 21, 2020
814f2c4
fix: updated requirements to match new library
imgurbot12 Jun 21, 2020
d1b0968
fix: src image reference fix
imgurbot12 Jun 22, 2020
c4a6371
fix: install-requires update for setup.py
imgurbot12 Jun 22, 2020
d87ab58
fix: tostring bytes fix
imgurbot12 Jun 22, 2020
67519a9
fix: bug in xmlprettify was deleting epub content
imgurbot12 Jul 1, 2020
14bc021
Fix pypub.tests.epub_test.EpubTests.test_create_epub
mcepl Jan 9, 2021
c653daa
Make documentation buildable.
mcepl Jan 9, 2021
93d7cbf
Fix location of templates
mcepl Jan 9, 2021
aa90014
fix: update epub test to use set rather than list
imgurbot12 Jan 11, 2021
69468e9
Merge pull request #1 from mcepl/devel
imgurbot12 Jan 11, 2021
719fe1c
fix: remove redundant set conversion after changes from earlier commit
imgurbot12 Jan 11, 2021
e5d971e
added dynamic cover generation to include title/author
imgurbot12 Jul 2, 2021
ac45193
fix: improved install-requires and package-data for pip install
imgurbot12 Jul 2, 2021
3a0560c
fix: package_data does not accept double star glob
imgurbot12 Jul 2, 2021
61c01de
feat: add dynamic font-size to better fix title onto generated cover
imgurbot12 Jul 9, 2021
68f706a
Fix bug of tags eating whitespace in tail
jenuk Sep 15, 2022
336f60d
Merge pull request #2 from jenuk/feat/py3
imgurbot12 Nov 13, 2022
00f92e1
chore: upgrade deprecated PIL functions
imgurbot12 Nov 13, 2022
685f6ed
feat: minor enhancements and fixes before release
imgurbot12 Nov 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions MANIFEST

This file was deleted.

23 changes: 13 additions & 10 deletions Readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@

Create epub's using python. Pypub is a python library to create epub files quickly without having to worry about the intricacies of the epub specification.

This package was orignally forked and re-writen based on WCember's [python2 version](https://github.com/wcember/pypub)
but due to lack of any response has been re-released as a new package to support python3

# Installation #
The current release of pypub is available through pip:

$ pip install pypub
$ pip install pypub3

Pypub is currently only compatible with Python 2.
Pypub is only compatible with Python <= 3.6.

# Quickstart #

```python
>>> import pypub
>>> my_first_epub = pypub.Epub('My First Epub')
>>> my_first_chapter = pypub.create_chapter_from_url('https://en.wikipedia.org/wiki/EPUB')
>>> my_first_epub.add_chapter(my_first_chapter)
>>> my_first_epub.create_epub('OUTPUT_DIRECTORY')
```python3
import pypub
my_first_epub = pypub.Epub('My First Epub')
my_first_chapter = pypub.create_chapter_from_url('https://en.wikipedia.org/wiki/EPUB')
my_first_epub.add_chapter(my_first_chapter)
my_first_epub.create_epub('OUTPUT_DIRECTORY')
```

# Features #
Expand All @@ -34,8 +37,8 @@ Documentation is available at [http://pypub.readthedocs.org/en/latest/developer_

# Copyright and License #

Copyright (c) 2020 William Cember
Copyright (c) 2022 Andrew Scott

[**Licensed**](https://github.com/wcember/pypub/blob/master/LICENSE) under the MIT License
[**Licensed**](https://github.com/imgurbot12/pypub/blob/master/LICENSE) under the MIT License

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5 changes: 4 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../..'))

# -- General configuration ------------------------------------------------

Expand All @@ -32,7 +33,9 @@
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.coverage',
'sphinxcontrib.napoleon',]
'sphinx.ext.napoleon',
'sphinx_autodoc_typehints',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down
8 changes: 3 additions & 5 deletions docs/source/developer_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Developer Interface
Functions
=========================

.. autofunction:: pypub.clean
.. autofunction:: pypub.create_chapter_from_string
.. autofunction:: pypub.create_chapter_from_file
.. autofunction:: pypub.create_chapter_from_url

Classes
=========================
Expand All @@ -13,7 +15,3 @@ Classes
:members: add_chapter, create_epub

.. autoclass:: pypub.Chapter
:members: write

.. autoclass:: pypub.ChapterFactory
:members: create_chapter_from_url, create_chapter_from_file, create_chapter_from_string
3 changes: 1 addition & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

pypub: Create epub files easily with python
==================================
============================================

Contents:

Expand All @@ -19,4 +19,3 @@ Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

12 changes: 6 additions & 6 deletions docs/source/tutorial_reddit.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Tutorial - create an epub from reddit stories
**********
*****************

Ready to get started? In this tutorial we will create an epub from the top stories currently on reddit.

Before you start, make sure the following is true

- Confirm that python 2 is installed on your machine and that you are using is. As of this writing, pypub is not compatible with python 3.
- Confirm that python 3 is installed on your machine and that you are using is.
- Make sure the most recent version of `pypub <http://pypub.readthedocs.io/en/latest/pypub.html#installation>`_ is installed
- In this tutorial, we are going to use the python package `praw <https://praw.readthedocs.io/en/stable/#installation>`_ to access reddit's api. Download that too. While praw is necessary for this tutorial, you do not need it to use pypub.
- (Optional) If you want to read your ebook on kindle, you'll need to convert it to a mobi file. Download `KindleGen <http://www.amazon.com/gp/feature.html?docId=1000765211>`_ to do this.
Expand All @@ -19,7 +19,7 @@ Let's begin by importing pypub as well as the other python libraries we're using

>>> import pypub
>>> import praw, os

Now let's get the current top ten stories from r/TrueReddit. The below code is necessary for this tutorial, but all we're returning here is a list of urls of stories we are interested in. Feel free to substitute here code to get whatever you are interested in (posts from your favorite blog, magazine articles, etc.)

>>> praw_object = praw.Reddit(user_agent='pypub/1.0')
Expand All @@ -32,7 +32,7 @@ top_submission_url_list is a python list of strings, where each string represent
Create the epub
****************
Now that we have a list of url strings, we can use pypub to download the content and create an epub from the stories. First let's create an Epub object called epub. The only information we need to provide is the title of the ebook we'll be creating, which we will call 'TrueReddit - Top Stories'.

>>> epub = pypub.Epub('TrueReddit - Top Stories')

With the Epub object we just created, let's add a chapter to it for every story we in our url list.
Expand All @@ -45,7 +45,7 @@ With the Epub object we just created, let's add a chapter to it for every story
... pass

Note in the above code that we try to create a chapter from every url, but don't if pypub raises a ValueError, which occurs if you try using pypub without an internet connection or if the url is invalid.

Finally, let's create our epub file. The below code saves it in the current working directory, but feel free to change that.

>>> epub.create_epub(os.getcwd())
Expand All @@ -60,7 +60,7 @@ If you're like me, then you like reading things on your kindle (which is why I c
Luckily, Amazon provided a tool, KindleGen to convert epubs (and other formats) to mobi so they can be viewed on kindle. Once it's downloaded, convert *TrueReddit - Top Stories.epub* by going to the command prompt and entering kindlegen's full file path (excluding .exe) followed by "TrueReddit - Top Stories.epub".

> <full directory of kindlegen>kindlegen "TrueReddit - Top Stories.epub"

If the kindlegen executable is saved in the same directory as *TrueReddit - Top Stories.epub*, this can simply be entered as

> kindlegen "TrueReddit - Top Stories.epub"
Expand Down
24 changes: 13 additions & 11 deletions pypub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
'epub.py functions and classes'
from epub import Epub
"""
epub library designed to build and generate ebooks in ePub format
"""

'chapter.py functions and classes'
from chapter import Chapter
from chapter import ChapterFactory
from chapter import create_chapter_from_url
from chapter import create_chapter_from_file
from chapter import create_chapter_from_string
from chapter import save_image
#** Variables **#
__all__ = [
'Epub',
'Chapter',

'clean.py functions and classes'
from clean import clean
'create_chapter_from_url',
'create_chapter_from_file',
'create_chapter_from_string'
]

from .epub import *
from .chapter import *
Loading