Contents¶
Introduction¶
The original EpubCheck is the standard Java based validation tool for EPUB maintained by DAISY Consortium on behalf of the W3C, originally developed by the IDPF.
This package provides a Python libary and command line tool for convenient validation of EPUB files by wrapping the original EpubCheck 4.2.2.
- Free software: BSD license
Installation¶
If you have Python on your system you can do the usual:
pip install epubcheck
You must have Python & Java installed on your system. The original Java EpubCheck command line client itself is bundled in the PyPi package.
This package is tested with Python 2.7, 3.4, 3.5, 3.6, 3.7 on Linux and Windows. It should also work with PyPy.
Quickstart¶
Command line usage examples¶
Validata all epub files in the current directory:
$ epubcheck
Validate a single EPUB file:
$ epubcheck /path/to/book.epub
Validate all files in /epubfolder and create a detailed Excel report:
$ epubcheck /path/epubfolder --xls report.xls
Show command line help:
$ epubcheck -h
Using epubcheck as a python library¶
>>> from epubcheck import EpubCheck
>>> result = EpubCheck('src/epubcheck/samples/invalid.epub')
>>> print(result.valid)
>>> print(result.messages)
Documentation¶
Development¶
To run the all tests run:
tox
Note, to combine the coverage data from all the tox environments run:
Windows | set PYTEST_ADDOPTS=--cov-append
tox
|
---|---|
Other | PYTEST_ADDOPTS=--cov-append tox
|
Credits¶
EpubCheck is a project coordinated by IDPF. Most of the EpubCheck functionality comes from the schema validation tool Jing and schemas that were developed by IDPF and DAISY. Initial EpubCheck development was largely done at Adobe Systems.
Reference¶
epubcheck¶
-
class
epubcheck.
EpubCheck
(infile, lang=u'en', profile=u'default', autorun=True)[source]¶ Wraps an epubcheck task and provides results as native python objects.
Parameters: - infile (str) – path to epubfile to be checked
- lang (str) – set language for generated messages
- profile (str) – name of epubcheck profule to use
- autorun (bool) – wether to run the checking process on instantiation.
-
class
epubcheck.models.
Checker
[source]¶ Checker related information from epubcheck json data.
Parameters: - path (str) – Relative path to checked epub
- filename (str) – Filename of checked epub
- checkerVersion (str) – Version string of epubcheck
- checkDate (str) – When the epub was checked
- elapsedTime (int) – processing time
- nFatal (int) – number of fatal errors
- nError (int) – number of errors
- nWarning (int) – number of warnings
- nUsage (int) – number of usage messages
-
class
epubcheck.models.
Meta
[source]¶ EPUB metadata from publication key in epubcheck json data.
Parameters: - publisher (str) – name of publisher
- title (str) – title of ebook
- creator (list[str]) – list of creators
- date (str) – date of ebook
- subject (list[str]) – list of ebook subjects
- description (str) – description of ebook
- rights (str) –
- identifier (str) –
- language (str) – language of ebook
- nSpines (int) –
- checkSum (int) –
- renditionLayout (str) –
- renditionSpread (str) –
- ePubVersion (str) –
- isScripted (bool) –
- hasFixedFormat (bool) –
- isBackwardCompatible (bool) –
- hasAudio (bool) –
- charsCount (int) –
- embeddedFonts (list[str]) –
- refFonts (list[str]) –
- hasEncryption (bool) –
- hasSignatures (bool) –
- contributors (list[str]) –
-
class
epubcheck.models.
Message
[source]¶ A Validation message representing a single error condition.
Parameters: - id (str) – Error type id (ex: “OPF-049”)
- level (str) – Severity of messeage (ex: “ERROR”)
- location (str) – Location of error (ex: <file>:<line>:<column>)
- message (str) – Description of the error condiction
- suggestion (str) – How to resolve error condition
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
Bug reports¶
When reporting a bug please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Documentation improvements¶
epubcheck could always use more documentation, whether as part of the official epubcheck docs, in docstrings, or even on the web in blog posts, articles, and such.
Feature requests and feedback¶
The best way to send feedback is to file an issue at https://github.com/titusz/epubcheck/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that code contributions are welcome :)
Development¶
To set up epubcheck for local development:
Fork epubcheck (look for the “Fork” button).
Clone your fork locally:
git clone git@github.com:your_name_here/epubcheck.git
Create a branch for local development:
git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, run all the checks, doc builder and spell checker with tox one command:
tox
Commit your changes and push your branch to GitHub:
git add . git commit -m "Your detailed description of your changes." git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
If you need some code review or feedback while you’re developing the code just make the pull request.
For merging, you should:
- Include passing tests (run
tox
) [1]. - Update documentation when there’s new API, functionality etc.
- Add a note to
CHANGELOG.rst
about the changes. - Add yourself to
AUTHORS.rst
.
[1] | If you don’t have all the necessary python versions available locally you can rely on Travis - it will run the tests for each change you add in the pull request. It will be slower though … |
Tips¶
To run a subset of tests:
tox -e envname -- py.test -k test_myfeature
To run all the test environments in parallel (you need to pip install detox
):
detox
Authors¶
- Titusz Pan - https://github.com/titusz
- Sean Quinn - https://github.com/swquinn
Changelog¶
0.4.2 (2019-08-07)¶
- Update the epubcheck.jar to v4.2.2 (see: https://github.com/w3c/epubcheck/releases/tag/v4.2.2)
0.3.1 (2016-04-20)¶
- Added custom PY2/PY3 compat module and removed dependancy on six
0.3.0 (2016-04-10)¶
- Add commandline support with Excel batch reporting
- Moved development status from Alpha to Beta
0.2.0 (2016-04-03)¶
- EpubCheck results as native python objects
- More documentation
0.1.0 (2016-04-01)¶
- First release on PyPI.