Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cairocffi = ">1.7.0"
libgutenberg = {file = ".", editable = true}

[dev-packages]
pytest = "*"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this Pipfile is only used for development I can move this to the non-dev dependency, let me know.


[requires]
python_version = ">=3.7"
115 changes: 113 additions & 2 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 28 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
# libgutenberg
Common files used by Project Gutenberg python projects.

# installation
# Installation

`pipenv install libgutenberg`
`pipenv install 'libgutenberg[covers]'` for cover generation
`pipenv install 'libgutenberg[postgres]'` for use with postgres
Install with the package manager of your choice -- `pipenv` or `pip`.

or
```bash
pip install libgutenberg
pip install 'libgutenberg[covers]' # for cover generation
pip install 'libgutenberg[postgres]' # for use with postgres
```

`pip install libgutenberg`
`pip install 'libgutenberg[covers]'` for cover generation
`pip install 'libgutenberg[postgres]'` for use with postgres
Depending on your system configuration, you might need to install `psycopg2-binary'.

Depending on your system configuration, you might need to use pip or pipenv to install
`pipenv install psycopg2-binary'
Cover generation with `cairocffi` may require some system packages, see:
https://doc.courtbouillon.org/cairocffi/stable/overview.html#installing-cffi

cover generation may require some system packages; see
`cffi` depends on `pycparser` which should be installed as a dependency, but if
it isn't for some reason: `pip install pycparser` will fix it.

<https://doc.courtbouillon.org/cairocffi/stable/overview.html#installing-cffi>
# Development

`pipenv` will install the package as an editable package and is the easiest
way to get it set up:

```bash
pipenv install --python $(which python3)
pipenv shell
```

To run tests:
```bash
pipenv shell
source test_env.sh
pytest
```
15 changes: 9 additions & 6 deletions libgutenberg/tests/test_files.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import unittest

from libgutenberg import GutenbergDatabase
from libgutenberg import GutenbergFiles
from libgutenberg.DublinCoreMapping import DublinCoreObject
from libgutenberg.DBUtils import check_session, ebook_exists
from libgutenberg.GutenbergFiles import store_file_in_database, PUBLIC, FILES, FTP
from libgutenberg.GutenbergFiles import store_file_in_database
from libgutenberg.Models import Book, File

global db_exists
Expand All @@ -31,10 +31,13 @@ def test_guess_filetype(self):

@unittest.skipIf(not db_exists, 'database not configured')
def test_file_save_and_read(self):
''' Make sure there's a file at /Users/Shared/Documents/pg/dev/html/files/99999/99999.txt
and that FILES is set in .env '''

self.assertEqual(FILES, '/Users/Shared/Documents/pg/dev/html/files/')
# TODO: get this file checked into the repo -- don't rely on it on
# the file system

filepath = '/Users/Shared/Documents/pg/dev/html/files/'
if not os.path.exists(filepath):
self.skipTest(f"{filepath} doesn't exist to load book from")

book = self.dc.load_or_create_book(99999)
store_file_in_database(99999,
'/Users/Shared/Documents/pg/dev/html/files/99999/99999.txt', None,
Expand Down
File renamed without changes.