Hello community,
here is the log from the commit of package python-djvulibre for openSUSE:Factory checked in at 2018-06-29 22:24:02
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-djvulibre (Old)
and /work/SRC/openSUSE:Factory/.python-djvulibre.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-djvulibre"
Fri Jun 29 22:24:02 2018 rev:16 rq:615374 version:0.8.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-djvulibre/python-djvulibre.changes 2018-04-11 14:02:44.801165161 +0200
+++ /work/SRC/openSUSE:Factory/.python-djvulibre.new/python-djvulibre.changes 2018-06-29 22:24:05.322588024 +0200
@@ -1,0 +2,25 @@
+Tue Jun 5 16:18:37 UTC 2018 - lazy.kent@opensuse.org
+
+- Update to 0.8.1.
+ * Improve documentation:
+ + Add README, and move information about build requirements there.
+ + Apply minor wording and typographic fixes to API documentation.
+ + Don't include Sphinx version in HTML documentation.
+ + Don't include copyright information in HTML documentation.
+ * Improve examples:
+ + Make djvu-dump-text and djvu-crop-text compatible with Python 3.
+ + Make djvu2png render all layers by default.
+ + Unify command-line argument parsing.
+ * Explicitly set Cython's Python language level to 2.
+ This might fix build failures with future versions of Cython.
+ * Improve the build system:
+ + Declare build-dependencies (as per PEP-518).
+ + Add the bdist_wheel command.
+ + Use distutils644 to normalize tarball permissions etc.
+ + Fix Python version check.
+ * Improve the test suite.
+ + Be more tolerant about ps2ascii output.
+ Fixes some failures with Ghostscript 9.22.
+- Enable run tests (excluding failed).
+
+-------------------------------------------------------------------
Old:
----
python-djvulibre-0.8.tar.gz
python-djvulibre-0.8.tar.gz.asc
New:
----
python-djvulibre-0.8.1.tar.gz
python-djvulibre-0.8.1.tar.gz.asc
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-djvulibre.spec ++++++
--- /var/tmp/diff_new_pack.Hj7tVc/_old 2018-06-29 22:24:05.986587525 +0200
+++ /var/tmp/diff_new_pack.Hj7tVc/_new 2018-06-29 22:24:05.986587525 +0200
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-djvulibre
-Version: 0.8
+Version: 0.8.1
Release: 0
Summary: Python Support for the DjVu Image Format
License: GPL-2.0-only
@@ -74,14 +74,14 @@
rm build/sphinx/html/.buildinfo build/sphinx/html/objects.inv
%fdupes %{buildroot}%{_prefix}
-# %%check
-# cd tests/
-# ln -sf %%{buildroot}%%{python_sitearch}/djvu/ djvu
-# %%python_exec -m nose --verbose
+%check
+cd tests/
+PYTHONPATH=%{buildroot}%{$python_sitearch}
+%python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python -m nose --exclude='^test_export_ps$' --verbose
%files %{python_files}
%license doc/COPYING
-%doc doc/changelog doc/credits.txt
+%doc doc/changelog doc/credits.txt doc/todo.txt
%{python_sitearch}/*
%files -n %{name}-doc
++++++ python-djvulibre-0.8.tar.gz -> python-djvulibre-0.8.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/MANIFEST.in new/python-djvulibre-0.8.1/MANIFEST.in
--- old/python-djvulibre-0.8/MANIFEST.in 2016-06-08 23:34:06.000000000 +0200
+++ new/python-djvulibre-0.8.1/MANIFEST.in 2018-05-16 18:38:13.000000000 +0200
@@ -1,10 +1,13 @@
include MANIFEST.in
+include COPYING
+exclude README.rst
include doc/*.txt
include doc/COPYING
-include doc/changelog
+include doc/README
include doc/api/*.rst
include doc/api/conf.py
+include doc/changelog
include examples/*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/PKG-INFO new/python-djvulibre-0.8.1/PKG-INFO
--- old/python-djvulibre-0.8/PKG-INFO 2016-08-05 23:07:39.000000000 +0200
+++ new/python-djvulibre-0.8.1/PKG-INFO 2018-05-30 18:59:17.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: python-djvulibre
-Version: 0.8
+Version: 0.8.1
Summary: Python support for the DjVu image format
Home-page: http://jwilk.net/software/python-djvulibre
Author: Jakub Wilk
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/djvu/common.pxi new/python-djvulibre-0.8.1/djvu/common.pxi
--- old/python-djvulibre-0.8/djvu/common.pxi 2016-06-08 23:34:06.000000000 +0200
+++ new/python-djvulibre-0.8.1/djvu/common.pxi 2018-05-16 18:38:13.000000000 +0200
@@ -1,4 +1,4 @@
-# Copyright © 2008-2015 Jakub Wilk
+# Copyright © 2008-2018 Jakub Wilk
#
# This file is part of python-djvulibre.
#
@@ -131,8 +131,10 @@
# Python exceptions:
cdef void raise_instantiation_error(object cls) except *:
- raise TypeError, 'cannot create \'{tp}\' instances'.format(tp=get_type_name(cls))
+ raise TypeError('cannot create \'{tp}\' instances'.format(tp=get_type_name(cls)))
+# Cython before 0.25 didn't support cdef classes deriving from Exception out of
+# the box: https://github.com/cython/cython/issues/1416
cdef extern from 'pyerrors.h':
ctypedef class __builtin__.Exception [object PyBaseExceptionObject]:
pass
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/djvu/decode.pyx new/python-djvulibre-0.8.1/djvu/decode.pyx
--- old/python-djvulibre-0.8/djvu/decode.pyx 2016-08-01 22:16:19.000000000 +0200
+++ new/python-djvulibre-0.8.1/djvu/decode.pyx 2018-05-29 22:27:01.000000000 +0200
@@ -1,4 +1,4 @@
-# Copyright © 2007-2016 Jakub Wilk
+# Copyright © 2007-2018 Jakub Wilk
#
# This file is part of python-djvulibre.
#
@@ -12,6 +12,7 @@
# more details.
#cython: autotestdict=False
+#cython: language_level=2
'''
DjVuLibre bindings: module for efficiently decoding and displaying DjVu documents
@@ -529,7 +530,8 @@
'''
cdef PageJob job
cdef ddjvu_job_t* ddjvu_job
- with nogil: acquire_lock(loft_lock, WAIT_LOCK)
+ with nogil:
+ acquire_lock(loft_lock, WAIT_LOCK)
try:
ddjvu_job = ddjvu_page_create_by_pageno(self._document.ddjvu_document, self._n)
if ddjvu_job == NULL:
@@ -993,14 +995,15 @@
cdef object __init(self, Context context, ddjvu_document_t *ddjvu_document):
# Assumption: loft_lock is already acquired.
- assert context != None and ddjvu_document != NULL
+ assert (context is not None) and ddjvu_document != NULL
self.ddjvu_document = ddjvu_document
self._context = context
_document_loft.add(self)
_document_weak_loft[voidp_to_int(ddjvu_document)] = self
cdef object __clear(self):
- with nogil: acquire_lock(loft_lock, WAIT_LOCK)
+ with nogil:
+ acquire_lock(loft_lock, WAIT_LOCK)
try:
_document_loft.discard(self)
finally:
@@ -1126,7 +1129,8 @@
s2 = pages_to_opt(pages, 1)
optv[optc] = s2
optc = optc + 1
- with nogil: acquire_lock(loft_lock, WAIT_LOCK)
+ with nogil:
+ acquire_lock(loft_lock, WAIT_LOCK)
try:
job = SaveJob(sentinel = the_sentinel)
job.__init(self._context, ddjvu_document_save(self.ddjvu_document, output, optc, optv))
@@ -1327,7 +1331,8 @@
if is_unicode(option):
options[optc] = option = encode_utf8(option)
optv[optc] = option
- with nogil: acquire_lock(loft_lock, WAIT_LOCK)
+ with nogil:
+ acquire_lock(loft_lock, WAIT_LOCK)
try:
job = SaveJob(sentinel = the_sentinel)
job.__init(
@@ -1373,7 +1378,8 @@
if ddjvu_document == NULL:
result = None
else:
- with nogil: acquire_lock(loft_lock, WAIT_LOCK)
+ with nogil:
+ acquire_lock(loft_lock, WAIT_LOCK)
try:
result = _document_weak_loft.get(voidp_to_int(ddjvu_document))
finally:
@@ -1445,7 +1451,8 @@
argv0 = sys.argv[0]
if is_unicode(argv0):
argv0 = encode_utf8(argv0)
- with nogil: acquire_lock(loft_lock, WAIT_LOCK)
+ with nogil:
+ acquire_lock(loft_lock, WAIT_LOCK)
try:
self.ddjvu_context = ddjvu_context_create(argv0)
if self.ddjvu_context == NULL:
@@ -1548,7 +1555,8 @@
'''
cdef Document document
cdef ddjvu_document_t* ddjvu_document
- with nogil: acquire_lock(loft_lock, WAIT_LOCK)
+ with nogil:
+ acquire_lock(loft_lock, WAIT_LOCK)
try:
if typecheck(uri, FileUri):
IF PY3K:
@@ -1586,7 +1594,8 @@
if ddjvu_context == NULL:
result = None
else:
- with nogil: acquire_lock(loft_lock, WAIT_LOCK)
+ with nogil:
+ acquire_lock(loft_lock, WAIT_LOCK)
try:
try:
result = _context_loft[voidp_to_int(ddjvu_context)]
@@ -1761,7 +1770,7 @@
red_mask, green_mask and blue_mask are bit masks for color components
for each pixel. The resulting color is then xored with the xor_value.
- For example, PixelFormatRgbMask(0xf800, 0x07e0, 0x001f, bpp=16) is a
+ For example, PixelFormatRgbMask(0xF800, 0x07E0, 0x001F, bpp=16) is a
highcolor format with:
- 5 (most significant) bits for red,
@@ -1773,16 +1782,16 @@
cdef ddjvu_format_style_t _format
if bpp == 16:
_format = DDJVU_FORMAT_RGBMASK16
- red_mask = red_mask & 0xffff
- blue_mask = blue_mask & 0xffff
- green_mask = green_mask & 0xffff
- xor_value = xor_value & 0xffff
+ red_mask = red_mask & 0xFFFF
+ blue_mask = blue_mask & 0xFFFF
+ green_mask = green_mask & 0xFFFF
+ xor_value = xor_value & 0xFFFF
elif bpp == 32:
_format = DDJVU_FORMAT_RGBMASK32
- red_mask = red_mask & 0xffffffff
- blue_mask = blue_mask & 0xffffffff
- green_mask = green_mask & 0xffffffff
- xor_value = xor_value & 0xffffffff
+ red_mask = red_mask & 0xFFFFFFFF
+ blue_mask = blue_mask & 0xFFFFFFFF
+ green_mask = green_mask & 0xFFFFFFFF
+ xor_value = xor_value & 0xFFFFFFFF
else:
raise ValueError('bpp must be equal to 16 or 32')
self._bpp = self._dither_bpp = bpp
@@ -2189,14 +2198,15 @@
cdef object __init(self, Context context, ddjvu_job_t *ddjvu_job):
# Assumption: loft_lock is already acquired.
- assert context != None and ddjvu_job != NULL
+ assert (context is not None) and ddjvu_job != NULL
self._context = context
self.ddjvu_job = ddjvu_job
_job_loft.add(self)
_job_weak_loft[voidp_to_int(ddjvu_job)] = self
cdef object __clear(self):
- with nogil: acquire_lock(loft_lock, WAIT_LOCK)
+ with nogil:
+ acquire_lock(loft_lock, WAIT_LOCK)
try:
_job_loft.discard(self)
finally:
@@ -2285,7 +2295,8 @@
if ddjvu_job == NULL:
result = None
else:
- with nogil: acquire_lock(loft_lock, WAIT_LOCK)
+ with nogil:
+ acquire_lock(loft_lock, WAIT_LOCK)
try:
result = _job_weak_loft.get(voidp_to_int(ddjvu_job))
finally:
@@ -2319,7 +2330,7 @@
if n % 90:
raise ValueError('n must a multiple of 90')
else:
- ddjvu_rectmapper_modify(self.ddjvu_rectmapper, n/90, 0, 0)
+ ddjvu_rectmapper_modify(self.ddjvu_rectmapper, n // 90, 0, 0)
def __call__(self, value):
cdef ddjvu_rect_t rect
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/djvu/dllpath.py new/python-djvulibre-0.8.1/djvu/dllpath.py
--- old/python-djvulibre-0.8/djvu/dllpath.py 2016-08-03 19:57:43.000000000 +0200
+++ new/python-djvulibre-0.8.1/djvu/dllpath.py 2018-05-16 18:38:13.000000000 +0200
@@ -1,6 +1,6 @@
# encoding=UTF-8
-# Copyright © 2011-2016 Jakub Wilk
+# Copyright © 2011-2017 Jakub Wilk
#
# This file is part of python-djvulibre.
#
@@ -17,13 +17,12 @@
ease finding DjVuLibre DLLs in non-standard locations
'''
+import ctypes
import os
if os.name != 'nt':
raise ImportError('This module is for Windows only')
-import ctypes
-
try:
# Python 3.X
import winreg
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/djvu/sexpr.pyx new/python-djvulibre-0.8.1/djvu/sexpr.pyx
--- old/python-djvulibre-0.8/djvu/sexpr.pyx 2016-08-01 11:56:38.000000000 +0200
+++ new/python-djvulibre-0.8.1/djvu/sexpr.pyx 2018-05-29 22:27:02.000000000 +0200
@@ -1,4 +1,4 @@
-# Copyright © 2007-2015 Jakub Wilk
+# Copyright © 2007-2018 Jakub Wilk
#
# This file is part of python-djvulibre.
#
@@ -12,6 +12,7 @@
# more details.
#cython: autotestdict=False
+#cython: language_level=2
'''
DjVuLibre bindings: module for handling Lisp S-expressions
@@ -131,7 +132,8 @@
IF not HAVE_MINIEXP_IO_T:
global io_7bit, io_puts, io_getc, io_ungetc
global _myio
- with nogil: acquire_lock(_myio_lock, WAIT_LOCK)
+ with nogil:
+ acquire_lock(_myio_lock, WAIT_LOCK)
self.backup_io_7bit = io_7bit
self.backup_io_puts = io_puts
self.backup_io_getc = io_getc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/doc/README new/python-djvulibre-0.8.1/doc/README
--- old/python-djvulibre-0.8/doc/README 1970-01-01 01:00:00.000000000 +0100
+++ new/python-djvulibre-0.8.1/doc/README 2018-05-16 18:38:13.000000000 +0200
@@ -0,0 +1,39 @@
+Overview
+========
+
+**python-djvulibre** is a set of Python bindings for
+the DjVuLibre_ library, an open source implementation of DjVu_.
+
+.. _DjVuLibre:
+ http://djvu.sourceforge.net/
+.. _DjVu:
+ http://djvu.org/
+
+Prerequisites
+=============
+
+The following software is required to build python-djvulibre:
+
+* DjVuLibre (≥ 3.5.21)
+* Python_ (≥ 2.6 or 3.X)
+* Cython_ (≥ 0.19, or ≥ 0.20 for Python 3)
+* pkg-config_ (required on POSIX systems)
+
+Additionally, the following software is needed to run the tests:
+
+* nose_
+* DjVuLibre_ command-line tools
+* Ghostscript_
+
+.. _Python:
+ https://www.python.org/
+.. _Cython:
+ http://cython.org/
+.. _pkg-config:
+ https://wiki.freedesktop.org/www/Software/pkg-config/
+.. _nose:
+ https://nose.readthedocs.io/
+.. _Ghostscript:
+ https://www.ghostscript.com/
+
+.. vim:ft=rst ts=3 sts=3 sw=3 et
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/doc/api/conf.py new/python-djvulibre-0.8.1/doc/api/conf.py
--- old/python-djvulibre-0.8/doc/api/conf.py 2016-07-31 21:55:26.000000000 +0200
+++ new/python-djvulibre-0.8.1/doc/api/conf.py 2018-05-16 18:38:13.000000000 +0200
@@ -13,9 +13,6 @@
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
-import codecs
-import os
-
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
@@ -32,24 +29,14 @@
import setup as _setup
project = _setup.setup_params['name']
version = release = _setup.py_version
-_setup_file = codecs.open(
- os.path.splitext(_setup.__file__)[0] + '.py',
- 'r', encoding='UTF-8'
-)
-try:
- for line in _setup_file:
- if line.startswith(u'# Copyright © '):
- copyright = line[14:].strip()
- break
-finally:
- _setup_file.close()
-del _setup, _setup_file
pygments_style = 'sphinx'
html_theme = 'haiku'
html_use_modindex = True
html_use_index = False
+html_show_copyright = False
+html_show_sphinx = False
html_static_path = ['static']
rst_epilog = '''
@@ -68,6 +55,6 @@
import sphinx.writers.html
del sphinx.writers.html.HTMLTranslator.visit_math
def setup(app):
- app.add_stylesheet('docutils-math.css')
+ app.add_stylesheet('docutils-math.css')
# vim:ts=4 sts=4 sw=4 et
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/doc/api/files.rst new/python-djvulibre-0.8.1/doc/api/files.rst
--- old/python-djvulibre-0.8/doc/api/files.rst 2016-06-08 23:34:06.000000000 +0200
+++ new/python-djvulibre-0.8.1/doc/api/files.rst 2018-05-16 18:38:13.000000000 +0200
@@ -8,7 +8,7 @@
Use :attr:`Document.files` to obtain instances of this class.
- File indexing is zero-based, i.e. :attr:`~Document.files`\ ``[0]`` stands for the very first file.
+ File indexing is zero-based, i.e. :attr:`~Document.files`\ ``[0]`` stands for the first file.
``len(files)`` might raise :exc:`NotAvailable` when called before receiving
a :class:`DocInfoMessage`.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/doc/api/geometry.rst new/python-djvulibre-0.8.1/doc/api/geometry.rst
--- old/python-djvulibre-0.8/doc/api/geometry.rst 2016-06-08 23:34:06.000000000 +0200
+++ new/python-djvulibre-0.8.1/doc/api/geometry.rst 2018-05-16 18:38:13.000000000 +0200
@@ -106,7 +106,7 @@
`red_mask`, `green_mask` and `blue_mask` are bit masks for color components
for each pixel. The resulting color is then xored with the `xor_value`.
- For example, ``PixelFormatRgbMask(0xf800, 0x07e0, 0x001f, bpp=16)`` is a
+ For example, ``PixelFormatRgbMask(0xF800, 0x07E0, 0x001F, bpp=16)`` is a
highcolor format with:
- 5 (most significant) bits for red,
@@ -123,7 +123,7 @@
Palette pixel format.
- `palette` must be a dictionary which contains 216 (6 x 6 x 6)
+ `palette` must be a dictionary which contains 216 (6 × 6 × 6)
entries of a web color cube, such that:
- for each key ``(r, g, b)``: ``r in range(0, 6)``, ``g in range(0, 6)`` etc.;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/doc/api/messages.rst new/python-djvulibre-0.8.1/doc/api/messages.rst
--- old/python-djvulibre-0.8/doc/api/messages.rst 2016-06-08 23:34:06.000000000 +0200
+++ new/python-djvulibre-0.8.1/doc/api/messages.rst 2018-05-16 18:38:13.000000000 +0200
@@ -79,7 +79,7 @@
.. attribute:: name
The first :class:`NewStreamMessage` message always has :attr:`name` set
- to ``None``. It indicates that the decoder needs to access the data in
+ to ``None``. It indicates that the decoder needs to access the data in
the main DjVu file.
Further :class:`NewStreamMessage` messages are generated to access the
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/doc/api/pages.rst new/python-djvulibre-0.8.1/doc/api/pages.rst
--- old/python-djvulibre-0.8/doc/api/pages.rst 2016-06-08 23:34:06.000000000 +0200
+++ new/python-djvulibre-0.8.1/doc/api/pages.rst 2018-05-16 18:38:13.000000000 +0200
@@ -8,7 +8,7 @@
Use :attr:`Document.pages` to obtain instances of this class.
- Page indexing is zero-based, i.e. :attr:`~Document.pages`\ ``[0]`` stands for the very first page.
+ Page indexing is zero-based, i.e. :attr:`~Document.pages`\ ``[0]`` stands for the first page.
``len(pages)`` might return 1 when called before receiving a :class:`DocInfoMessage`.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/doc/build-reqs.txt new/python-djvulibre-0.8.1/doc/build-reqs.txt
--- old/python-djvulibre-0.8/doc/build-reqs.txt 2016-08-05 22:10:58.000000000 +0200
+++ new/python-djvulibre-0.8.1/doc/build-reqs.txt 1970-01-01 01:00:00.000000000 +0100
@@ -1,19 +0,0 @@
-The following software is required to build *python-djvulibre*:
-
- * DjVuLibre_ (≥ 3.5.21);
- * Python_ (≥ 2.6);
- * Cython_ (≥ 0.19, or ≥ 0.20 for Python 3);
- * pkg-config_ (required on POSIX systems).
-
-.. ---------------------------------------------------------------------
-
-.. _DjVuLibre:
- http://djvu.sourceforge.net/
-.. _Python:
- https://www.python.org/
-.. _Cython:
- http://cython.org/
-.. _pkg-config:
- https://wiki.freedesktop.org/www/Software/pkg-config/
-
-.. vim:ft=rst ts=3 sts=3 sw=3 et tw=72
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/doc/changelog new/python-djvulibre-0.8.1/doc/changelog
--- old/python-djvulibre-0.8/doc/changelog 2016-08-05 22:52:26.000000000 +0200
+++ new/python-djvulibre-0.8.1/doc/changelog 2018-05-30 18:48:53.000000000 +0200
@@ -1,3 +1,28 @@
+python-djvulibre (0.8.1) unstable; urgency=low
+
+ * Improve documentation:
+ + Add README, and move information about build requirements there.
+ + Apply minor wording and typographic fixes to API documentation.
+ + Don't include Sphinx version in HTML documentation.
+ + Don't include copyright information in HTML documentation.
+ * Improve examples:
+ + Make djvu-dump-text and djvu-crop-text compatible with Python 3.
+ + Make djvu2png render all layers by default.
+ + Unify command-line argument parsing.
+ * Explicitly set Cython's Python language level to 2.
+ This might fix build failures with future versions of Cython.
+ * Improve the build system:
+ + Declare build-dependencies (as per PEP-518).
+ + Add the bdist_wheel command.
+ + Use distutils644 to normalize tarball permissions etc.
+ + Fix Python version check.
+ * Improve the test suite.
+ + Be more tolerant about ps2ascii output.
+ Fixes some failures with Ghostscript 9.22.
+ https://github.com/jwilk/python-djvulibre/issues/6
+
+ -- Jakub Wilk Wed, 30 May 2018 18:48:50 +0200
+
python-djvulibre (0.8) unstable; urgency=low
* Fix Windows support. It is now possible to build the package using the
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/examples/djvu-crop-text new/python-djvulibre-0.8.1/examples/djvu-crop-text
--- old/python-djvulibre-0.8/examples/djvu-crop-text 2016-07-27 13:02:44.000000000 +0200
+++ new/python-djvulibre-0.8.1/examples/djvu-crop-text 2018-05-29 23:30:49.000000000 +0200
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# encoding=UTF-8
-# Copyright © 2008-2015 Jakub Wilk
+# Copyright © 2008-2018 Jakub Wilk
#
# This file is part of python-djvulibre.
#
@@ -31,19 +31,19 @@
def __init__(self):
argparse.ArgumentParser.__init__(self)
self.add_argument('-p', '--pages', dest='pages', action='store', help='pages to process')
- self.add_argument('path', metavar='FILE', action='store', help='DjVu file to process')
+ self.add_argument('path', metavar='DJVU-FILE', action='store', help='DjVu file to process')
def parse_args(self):
options = argparse.ArgumentParser.parse_args(self)
try:
if options.pages is not None:
pages = []
- for range in options.pages.split(','):
- if '-' in range:
+ for rng in options.pages.split(','):
+ if '-' in rng:
x, y = map(int, options.pages.split('-', 1))
- pages += xrange(x, y + 1)
+ pages += range(x, y + 1)
else:
- pages += int(range),
+ pages += [int(rng)]
options.pages = pages
except (TypeError, ValueError):
self.error('Unable to parse page numbers')
@@ -52,7 +52,7 @@
def crop_text(sexpr, width, height):
if isinstance(sexpr, djvu.sexpr.ListExpression) and len(sexpr) >= 5:
tp = sexpr[0]
- x0, y0, x1, y1 = (sexpr[i].value for i in xrange(1, 5))
+ x0, y0, x1, y1 = (sexpr[i].value for i in range(1, 5))
if x1 < 0 or y1 < 0 or x0 >= width or y0 >= height:
return
x0 = max(0, x0)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/examples/djvu-dump-text new/python-djvulibre-0.8.1/examples/djvu-dump-text
--- old/python-djvulibre-0.8/examples/djvu-dump-text 2016-07-15 11:06:49.000000000 +0200
+++ new/python-djvulibre-0.8.1/examples/djvu-dump-text 2018-05-29 23:30:49.000000000 +0200
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# encoding=UTF-8
-# Copyright © 2008-2015 Jakub Wilk
+# Copyright © 2008-2018 Jakub Wilk
#
# This file is part of python-djvulibre.
#
@@ -16,6 +16,7 @@
from __future__ import print_function
+import argparse
import os
import sys
@@ -27,7 +28,7 @@
if isinstance(sexpr, djvu.sexpr.ListExpression):
if len(sexpr) == 0:
return
- print(str(sexpr[0].value), [sexpr[i].value for i in xrange(1, 5)])
+ print(str(sexpr[0].value), [sexpr[i].value for i in range(1, 5)])
for child in sexpr[5:]:
print_text(child, level + 1)
else:
@@ -50,11 +51,11 @@
print_text(page.text.sexpr)
def main():
- if len(sys.argv) != 2:
- print('Usage: {prog} <djvu-file>'.format(prog=sys.argv[0]), file=sys.stderr)
- sys.exit(1)
+ ap = argparse.ArgumentParser()
+ ap.add_argument('path', metavar='DJVU-FILE')
+ options = ap.parse_args()
context = Context()
- context.process(sys.argv[1])
+ context.process(options.path)
if __name__ == '__main__':
main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/examples/djvu2png new/python-djvulibre-0.8.1/examples/djvu2png
--- old/python-djvulibre-0.8/examples/djvu2png 2016-07-15 11:06:52.000000000 +0200
+++ new/python-djvulibre-0.8.1/examples/djvu2png 2018-05-29 23:30:49.000000000 +0200
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# encoding=UTF-8
-# Copyright © 2010-2015 Jakub Wilk
+# Copyright © 2010-2018 Jakub Wilk
#
# This file is part of python-djvulibre.
#
@@ -25,7 +25,7 @@
import numpy
cairo_pixel_format = cairo.FORMAT_ARGB32
-djvu_pixel_format = djvu.decode.PixelFormatRgbMask(0xff0000, 0xff00, 0xff, bpp=32)
+djvu_pixel_format = djvu.decode.PixelFormatRgbMask(0xFF0000, 0xFF00, 0xFF, bpp=32)
djvu_pixel_format.rows_top_to_bottom = 1
djvu_pixel_format.y_top_to_bottom = 0
@@ -53,7 +53,7 @@
page_job.render(djvu.decode.RENDER_MASK_ONLY, rect, rect, djvu_pixel_format, row_alignment=bytes_per_line, buffer=mask_buffer)
mask_buffer <<= 24
color_buffer |= mask_buffer
- color_buffer ^= 0xff000000
+ color_buffer ^= 0xFF000000
surface = cairo.ImageSurface.create_for_data(color_buffer, cairo_pixel_format, width, height)
surface.write_to_png(png_path)
# Multi-page documents are not yet supported:
@@ -61,13 +61,13 @@
def main():
parser = argparse.ArgumentParser()
- parser.set_defaults(mode=djvu.decode.RENDER_COLOR_ONLY)
+ parser.set_defaults(mode=djvu.decode.RENDER_COLOR)
group = parser.add_mutually_exclusive_group()
group.add_argument('--foreground', dest='mode', action='store_const', const=djvu.decode.RENDER_FOREGROUND)
group.add_argument('--background', dest='mode', action='store_const', const=djvu.decode.RENDER_BACKGROUND)
group.add_argument('--mask', dest='mode', action='store_const', const=djvu.decode.RENDER_MASK_ONLY)
- parser.add_argument('djvu_path', metavar='<djvu-path>')
- parser.add_argument('png_path', metavar='<png-path>')
+ parser.add_argument('djvu_path', metavar='DJVU-FILE')
+ parser.add_argument('png_path', metavar='PNG-FILE')
options = parser.parse_args(sys.argv[1:])
context = Context()
context.process(options.djvu_path, options.png_path, options.mode)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/private/build-and-test new/python-djvulibre-0.8.1/private/build-and-test
--- old/python-djvulibre-0.8/private/build-and-test 2016-06-08 23:34:06.000000000 +0200
+++ new/python-djvulibre-0.8.1/private/build-and-test 2018-05-16 18:38:13.000000000 +0200
@@ -40,7 +40,7 @@
set -e
[ $# = 0 ] && set -- python
-[ -z $opt_build ] || \
+[ -z $opt_build ] ||
printf '%s\n' "$@" \
| xargs -P"$opt_jobs" -t -I'{python}' env '{python}' setup.py build --build-lib 'build/{python}'
cd tests
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/private/check-rst new/python-djvulibre-0.8.1/private/check-rst
--- old/python-djvulibre-0.8/private/check-rst 1970-01-01 01:00:00.000000000 +0100
+++ new/python-djvulibre-0.8.1/private/check-rst 2018-05-16 18:38:13.000000000 +0200
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# Copyright © 2016-2017 Jakub Wilk
+#
+# This file is part of python-djvulibre.
+#
+# python-djvulibre is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+#
+# python-djvulibre is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+
+here=$(dirname "$0")
+rst2xml=$(command -v rst2xml) \
+|| rst2xml=$(command -v rst2xml.py) \
+|| { printf 'rst2xml not found\n' >&2; exit 1; }
+options='--input-encoding=UTF-8 --output-encoding=UTF-8 --strict'
+if [ $# -eq 0 ]
+then
+ grep -r -w -l ft=rst doc/
+else
+ printf '%s\n' "$@"
+fi |
+xargs -L1 -t -I{} "$rst2xml" $options {} /dev/null
+
+# vim:ts=4 sts=4 sw=4 et
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/setup.cfg new/python-djvulibre-0.8.1/setup.cfg
--- old/python-djvulibre-0.8/setup.cfg 1970-01-01 01:00:00.000000000 +0100
+++ new/python-djvulibre-0.8.1/setup.cfg 2018-05-16 18:38:13.000000000 +0200
@@ -0,0 +1,4 @@
+[pycodestyle]
+filename = *.py,*.pyx,*.px[di]
+ignore = E12,E131,E2,E3,E4,E501,E722,W504
+show-source = true
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/setup.py new/python-djvulibre-0.8.1/setup.py
--- old/python-djvulibre-0.8/setup.py 2016-08-03 19:57:43.000000000 +0200
+++ new/python-djvulibre-0.8.1/setup.py 2018-05-16 18:38:13.000000000 +0200
@@ -1,6 +1,6 @@
# encoding=UTF-8
-# Copyright © 2007-2016 Jakub Wilk
+# Copyright © 2007-2018 Jakub Wilk
#
# This file is part of python-djvulibre.
#
@@ -19,25 +19,11 @@
an open source implementation of `DjVu http://djvu.org/`_.
'''
-classifiers = '''
-Development Status :: 4 - Beta
-Intended Audience :: Developers
-License :: OSI Approved :: GNU General Public License (GPL)
-Operating System :: POSIX
-Operating System :: Microsoft :: Windows
-Programming Language :: Cython
-Programming Language :: Python
-Programming Language :: Python :: 2
-Programming Language :: Python :: 3
-Topic :: Multimedia :: Graphics
-Topic :: Multimedia :: Graphics :: Graphics Conversion
-Topic :: Text Processing
-'''.strip().splitlines()
-
import glob
+import io
import os
-import subprocess as ipc
import re
+import subprocess as ipc
import sys
need_setuptools = False
@@ -52,6 +38,7 @@
import distutils.core
import distutils.ccompiler
import distutils.command.build_ext
+import distutils.command.sdist
import distutils.dep_util
import distutils.dir_util
import distutils.version
@@ -61,8 +48,19 @@
except ImportError:
sphinx_setup_command = None
-if sys.version_info < (2, 6):
- raise RuntimeError('Python >= 2.6 is required')
+try:
+ from wheel.bdist_wheel import bdist_wheel
+except ImportError:
+ bdist_wheel = None
+
+try:
+ import distutils644
+except ImportError:
+ pass
+else:
+ distutils644.install()
+
+b'' # Python >= 2.6 is required
def ext_modules():
for pyx_file in glob.iglob(os.path.join('djvu', '*.pyx')):
@@ -70,15 +68,9 @@
yield module
ext_modules = list(ext_modules())
-def uopen(path):
- if str != bytes:
- return open(path, 'rt', encoding='UTF-8')
- else:
- return open(path, 'rt')
-
def get_version():
path = os.path.join(os.path.dirname(__file__), 'doc', 'changelog')
- with uopen(path) as file:
+ with io.open(path, encoding='UTF-8') as file:
line = file.readline()
return line.split()[1].strip('()')
@@ -165,12 +157,12 @@
py_version = get_version()
cython_version = get_cython_version()
-if str != bytes:
- # Python 3.X
- req_cython_version = '0.20'
-else:
+if str is bytes:
# Python 2.X
req_cython_version = '0.19'
+else:
+ # Python 3.X
+ req_cython_version = '0.20'
# Work-around for https://bugs.python.org/issue969718:
os.environ.pop('CFLAGS', None)
@@ -251,8 +243,35 @@
else:
build_sphinx = None
+class sdist(distutils.command.sdist.sdist):
+
+ def maybe_move_file(self, base_dir, src, dst):
+ src = os.path.join(base_dir, src)
+ dst = os.path.join(base_dir, dst)
+ if os.path.exists(src):
+ self.move_file(src, dst)
+
+ def make_release_tree(self, base_dir, files):
+ distutils.command.sdist.sdist.make_release_tree(self, base_dir, files)
+ self.maybe_move_file(base_dir, 'COPYING', 'doc/COPYING')
+
compiler_flags = pkgconfig_build_flags('ddjvuapi')
+classifiers = '''
+Development Status :: 4 - Beta
+Intended Audience :: Developers
+License :: OSI Approved :: GNU General Public License (GPL)
+Operating System :: POSIX
+Operating System :: Microsoft :: Windows
+Programming Language :: Cython
+Programming Language :: Python
+Programming Language :: Python :: 2
+Programming Language :: Python :: 3
+Topic :: Multimedia :: Graphics
+Topic :: Multimedia :: Graphics :: Graphics Conversion
+Topic :: Text Processing
+'''.strip().splitlines()
+
meta = dict(
name='python-djvulibre',
version=py_version,
@@ -279,21 +298,21 @@
py_modules=['djvu.const'],
cmdclass=dict(
(cmd.__name__, cmd)
- for cmd in (build_ext, build_sphinx)
+ for cmd in (build_ext, build_sphinx, sdist, bdist_wheel)
if cmd is not None
),
**meta
)
if __name__ == '__main__':
- if 'setuptools' in sys.modules and sys.argv[1] == 'egg_info':
- # We wouldn't normally want setuptools; but pip forces it upon us anyway,
- # so let's abuse it to instruct pip to install Cython if it's missing.
+ egg_info_for_pip = ('setuptools' in sys.modules) and (sys.argv[1] == 'egg_info')
+ if (cython_version < req_cython_version) and egg_info_for_pip:
+ # This shouldn't happen with pip >= 10, thanks to PEP-518 support.
+ # For older versions, we use this hack to trick it into installing Cython:
distutils.core.setup(
install_requires=['Cython>={ver}'.format(ver=req_cython_version)],
# Conceptually, “setup_requires” would make more sense than
- # “install_requires”, but the former is not supported by pip:
- # https://github.com/pypa/pip/issues/1820
+ # “install_requires”, but the former is not supported by pip.
**meta
)
else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/tests/test_decode.py new/python-djvulibre-0.8.1/tests/test_decode.py
--- old/python-djvulibre-0.8/tests/test_decode.py 2016-08-02 12:52:42.000000000 +0200
+++ new/python-djvulibre-0.8.1/tests/test_decode.py 2018-05-30 11:45:41.000000000 +0200
@@ -1,6 +1,6 @@
# encoding=UTF-8
-# Copyright © 2007-2016 Jakub Wilk
+# Copyright © 2007-2018 Jakub Wilk
#
# This file is part of python-djvulibre.
#
@@ -16,6 +16,7 @@
import array
import errno
import os
+import re
import shutil
import subprocess
import sys
@@ -94,7 +95,6 @@
wildcard_import,
# Python 2/3 compat:
b,
- maxsize,
py3k,
u,
unicode,
@@ -135,9 +135,9 @@
file = tempfile.NamedTemporaryFile(prefix='test', suffix='djvu')
file.seek(0)
file.write(
- b'\x41\x54\x26\x54\x46\x4f\x52\x4d\x00\x00\x00\x22\x44\x4a\x56\x55'
- b'\x49\x4e\x46\x4f\x00\x00\x00\x0a\x00\x01\x00\x01\x18\x00\x2c\x01'
- b'\x16\x01\x53\x6a\x62\x7a\x00\x00\x00\x04\xbc\x73\x1b\xd7'
+ b'\x41\x54\x26\x54\x46\x4F\x52\x4D\x00\x00\x00\x22\x44\x4A\x56\x55'
+ b'\x49\x4E\x46\x4F\x00\x00\x00\x0A\x00\x01\x00\x01\x18\x00\x2C\x01'
+ b'\x16\x01\x53\x6A\x62\x7A\x00\x00\x00\x04\xBC\x73\x1B\xD7'
)
file.flush()
(stdout, stderr) = run('djvused', '-s', file.name, stdin=commands.encode(locale_encoding))
@@ -317,8 +317,8 @@
assert_equal(len(document.pages), 2)
assert_equal(len(document.files), 3)
(stdout0, stderr0) = run('djvudump', original_filename, LC_ALL='C')
- assert_equal(stderr0, b(''))
- stdout0 = stdout0.replace(b('\r\n'), b('\n'))
+ assert_equal(stderr0, b'')
+ stdout0 = stdout0.replace(b'\r\n', b'\n')
tmpdir = tempfile.mkdtemp()
try:
tmp = open(os.path.join(tmpdir, 'tmp.djvu'), 'wb')
@@ -328,8 +328,8 @@
assert_false(job.is_error)
tmp.close()
(stdout, stderr) = run('djvudump', tmp.name, LC_ALL='C')
- assert_equal(stderr, b(''))
- stdout = stdout.replace(b('\r\n'), b('\n'))
+ assert_equal(stderr, b'')
+ stdout = stdout.replace(b'\r\n', b'\n')
assert_equal(stdout, stdout0)
finally:
shutil.rmtree(tmpdir)
@@ -343,14 +343,14 @@
assert_false(job.is_error)
tmp.close()
stdout, stderr = run('djvudump', tmp.name, LC_ALL='C')
- assert_equal(stderr, b(''))
- stdout = stdout.replace(b('\r\n'), b('\n'))
- stdout0 = stdout0.split(b('\n'))
- stdout = stdout.split(b('\n'))
- stdout[4] = stdout[4].replace(b(' (1)'), b(''))
+ assert_equal(stderr, b'')
+ stdout = stdout.replace(b'\r\n', b'\n')
+ stdout0 = stdout0.split(b'\n')
+ stdout = stdout.split(b'\n')
+ stdout[4] = stdout[4].replace(b' (1)', b'')
assert_equal(len(stdout), 10)
assert_equal(stdout[3:-1], stdout0[4:10])
- assert_equal(stdout[-1], b(''))
+ assert_equal(stdout[-1], b'')
finally:
shutil.rmtree(tmpdir)
tmp = None
@@ -362,16 +362,16 @@
assert_true(job.is_done)
assert_false(job.is_error)
(stdout, stderr) = run('djvudump', tmpfname, LC_ALL='C')
- assert_equal(stderr, b(''))
- stdout = stdout.replace(b('\r\n'), b('\n'))
- stdout = stdout.split(b('\n'))
+ assert_equal(stderr, b'')
+ stdout = stdout.replace(b'\r\n', b'\n')
+ stdout = stdout.split(b'\n')
stdout0 = (
- [b(' shared_anno.iff -> shared_anno.iff')] +
+ [b' shared_anno.iff -> shared_anno.iff'] +
[b(' p{n:04}.djvu -> p{n:04}.djvu'.format(n=n)) for n in range(1, 3)]
)
assert_equal(len(stdout), 7)
assert_equal(stdout[2:-2], stdout0)
- assert_equal(stdout[-1], b(''))
+ assert_equal(stdout[-1], b'')
finally:
shutil.rmtree(tmpdir)
tmpdir = tempfile.mkdtemp()
@@ -382,13 +382,13 @@
assert_true(job.is_done)
assert_false(job.is_error)
(stdout, stderr) = run('djvudump', tmpfname, LC_ALL='C')
- stdout = stdout.replace(b('\r\n'), b('\n'))
- assert_equal(stderr, b(''))
- stdout = stdout.split(b('\n'))
+ stdout = stdout.replace(b'\r\n', b'\n')
+ assert_equal(stderr, b'')
+ stdout = stdout.split(b'\n')
assert_equal(len(stdout), 5)
- assert_equal(stdout[2], b(' shared_anno.iff -> shared_anno.iff'))
- assert_equal(stdout[3], b(' p0001.djvu -> p0001.djvu'))
- assert_equal(stdout[-1], b(''))
+ assert_equal(stdout[2], b' shared_anno.iff -> shared_anno.iff')
+ assert_equal(stdout[3], b' p0001.djvu -> p0001.djvu')
+ assert_equal(stdout[-1], b'')
finally:
shutil.rmtree(tmpdir)
@@ -404,40 +404,27 @@
assert_equal(document.type, DOCUMENT_TYPE_BUNDLED)
assert_equal(len(document.pages), 2)
assert_equal(len(document.files), 3)
- tmp = tempfile.NamedTemporaryFile()
- try:
+ with tempfile.NamedTemporaryFile() as tmp:
job = document.export_ps(tmp.file)
assert_equal(type(job), SaveJob)
assert_true(job.is_done)
assert_false(job.is_error)
stdout, stderr = run('ps2ascii', tmp.name, LC_ALL='C')
- assert_equal(stderr, b(''))
- assert_equal(stdout, b('\x0c') * 2)
- finally:
- tmp.close()
-
- tmp = tempfile.NamedTemporaryFile()
- try:
+ assert_equal(stderr, b'')
+ stdout = re.sub(br'[\x00\s]+', b' ', stdout)
+ assert_equal(stdout, b' ')
+ with tempfile.NamedTemporaryFile() as tmp:
job = document.export_ps(tmp.file, pages=(0,), text=True)
assert_equal(type(job), SaveJob)
assert_true(job.is_done)
assert_false(job.is_error)
stdout, stderr = run('ps2ascii', tmp.name, LC_ALL='C')
- assert_equal(stderr, b(''))
+ assert_equal(stderr, b'')
stdout = stdout.decode('ASCII')
- stdout = ' '.join(stdout.split())
- expected = '''
- 1 Lorem ipsum
- Optio reprehenderit molestias amet aliquam, similique doloremque fuga labore
- voluptatum voluptatem, commodi culpa voluptas, officia tenetur expedita quidem
- hic repellat molestiae quis accusamus dolores repudiandae, quidem in ad
- voluptas eligendi maiores placeat ex consectetur at tenetur amet.
- 1
- '''
- expected = ' '.join(expected.split())
+ stdout = re.sub(r'[\x00\s]+', ' ', stdout)
+ stdout = ' '.join(stdout.split()[:3])
+ expected = '1 Lorem ipsum'
assert_multi_line_equal(stdout, expected)
- finally:
- del tmp
class test_pixel_formats():
@@ -454,9 +441,9 @@
assert_repr(pf, "djvu.decode.PixelFormatRgb(byte_order = 'BGR', bpp = 24)")
def test_rgb_mask(self):
- pf = PixelFormatRgbMask(0xff, 0xf00, 0x1f000, 0, 16)
+ pf = PixelFormatRgbMask(0xFF, 0xF00, 0x1F000, 0, 16)
assert_repr(pf, "djvu.decode.PixelFormatRgbMask(red_mask = 0x00ff, green_mask = 0x0f00, blue_mask = 0xf000, xor_value = 0x0000, bpp = 16)")
- pf = PixelFormatRgbMask(0xff000000, 0xff0000, 0xff00, 0xff, 32)
+ pf = PixelFormatRgbMask(0xFF000000, 0xFF0000, 0xFF00, 0xFF, 32)
assert_repr(pf, "djvu.decode.PixelFormatRgbMask(red_mask = 0xff000000, green_mask = 0x00ff0000, blue_mask = 0x0000ff00, xor_value = 0x000000ff, bpp = 32)")
def test_grey(self):
@@ -533,11 +520,11 @@
page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 10, 10), PixelFormatRgb(), -1)
with assert_raises_regex(MemoryError, r'\AUnable to allocate [0-9]+ bytes for an image memory\Z'):
- x = int((maxsize // 2) ** 0.5)
+ x = int((sys.maxsize // 2) ** 0.5)
page_job.render(RENDER_COLOR, (0, 0, x, x), (0, 0, x, x), PixelFormatRgb(), 8)
s = page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 4, 4), PixelFormatGrey(), 1)
- assert_equal(s, b'\xff\xff\xff\xff\xff\xff\xff\xef\xff\xff\xff\xa4\xff\xff\xff\xb8')
+ assert_equal(s, b'\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xEF\xFF\xFF\xFF\xA4\xFF\xFF\xFF\xB8')
buffer = array.array('B', b'\0')
with assert_raises_str(ValueError, 'Image buffer is too small (16 > 1)'):
@@ -546,7 +533,7 @@
buffer = array.array('B', b'\0' * 16)
assert_is(page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 4, 4), PixelFormatGrey(), 1, buffer), buffer)
s = array_tobytes(buffer)
- assert_equal(s, b'\xff\xff\xff\xff\xff\xff\xff\xef\xff\xff\xff\xa4\xff\xff\xff\xb8')
+ assert_equal(s, b'\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xEF\xFF\xFF\xFF\xA4\xFF\xFF\xFF\xB8')
class test_thumbnails:
@@ -566,7 +553,7 @@
assert_is(pixels, None)
(w, h, r), pixels = thumbnail.render((5, 5), PixelFormatGrey())
assert_equal((w, h, r), (5, 3, 5))
- assert_equal(pixels[:15], b'\xff\xeb\xa7\xf2\xff\xff\xbf\x86\xbe\xff\xff\xe7\xd6\xe7\xff')
+ assert_equal(pixels[:15], b'\xFF\xEB\xA7\xF2\xFF\xFF\xBF\x86\xBE\xFF\xFF\xE7\xD6\xE7\xFF')
buffer = array.array('B', b'\0')
with assert_raises_str(ValueError, 'Image buffer is too small (25 > 1)'):
(w, h, r), pixels = thumbnail.render((5, 5), PixelFormatGrey(), buffer=buffer)
@@ -574,7 +561,7 @@
(w, h, r), pixels = thumbnail.render((5, 5), PixelFormatGrey(), buffer=buffer)
assert_is(pixels, buffer)
s = array_tobytes(buffer[:15])
- assert_equal(s, b'\xff\xeb\xa7\xf2\xff\xff\xbf\x86\xbe\xff\xff\xe7\xd6\xe7\xff')
+ assert_equal(s, b'\xFF\xEB\xA7\xF2\xFF\xFF\xBF\x86\xBE\xFF\xFF\xE7\xD6\xE7\xFF')
def test_jobs():
@@ -644,7 +631,7 @@
finally:
message.stream.close()
with assert_raises_str(IOError, 'I/O operation on closed file'):
- message.stream.write(b('eggs'))
+ message.stream.write(b'eggs')
message = document.get_message()
assert_equal(type(message), DocInfoMessage)
outline = document.outline
@@ -814,8 +801,8 @@
Expression(
[Symbol('page'), 0, 0, 2550, 3300,
'2 Hyperlinks \n'
- '2.1 local \n'
- + u('→1 \n') +
+ '2.1 local \n' +
+ u('→1 \n') +
'2.2 remote \nhttp://jwilk.net/ \n'
'2 \n'
]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/tests/test_sexpr.py new/python-djvulibre-0.8.1/tests/test_sexpr.py
--- old/python-djvulibre-0.8/tests/test_sexpr.py 2016-08-01 22:44:09.000000000 +0200
+++ new/python-djvulibre-0.8.1/tests/test_sexpr.py 2018-05-16 18:38:13.000000000 +0200
@@ -1,6 +1,6 @@
# encoding=UTF-8
-# Copyright © 2007-2016 Jakub Wilk
+# Copyright © 2007-2018 Jakub Wilk
#
# This file is part of python-djvulibre.
#
@@ -20,7 +20,6 @@
import io
import os
import shutil
-import sys
import tempfile
import pickle
@@ -129,7 +128,7 @@
def test_unpickle(self):
# pickle as generated by python-djvulibre 0.3.3:
- p = b("cdjvu.sexpr\n_expression_from_string\np0\n(S'42'\np1\ntp2\nRp3\n.")
+ p = b"cdjvu.sexpr\n_expression_from_string\np0\n(S'42'\np1\ntp2\nRp3\n."
x = pickle.loads(p)
self.t(42, x)
@@ -227,7 +226,7 @@
# __hash__():
assert_equal(
hash(x),
- hash(bname.strip(b('|')))
+ hash(bname.strip(b'|'))
)
# pickle:
assert_pickle_equal(x)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-djvulibre-0.8/tests/tools.py new/python-djvulibre-0.8.1/tests/tools.py
--- old/python-djvulibre-0.8/tests/tools.py 2016-08-05 22:52:11.000000000 +0200
+++ new/python-djvulibre-0.8.1/tests/tools.py 2018-05-16 18:38:13.000000000 +0200
@@ -1,6 +1,6 @@
# encoding=UTF-8
-# Copyright © 2010-2016 Jakub Wilk
+# Copyright © 2010-2018 Jakub Wilk
#
# This file is part of python-djvulibre.
#
@@ -122,7 +122,7 @@
@noseimport(2, 7, 'assert_regexp_matches')
@noseimport(3, 2)
def assert_regex(text, regex):
- if isinstance(regex, basestring):
+ if isinstance(regex, (bytes, str, unicode)):
regex = re.compile(regex)
if not regex.search(text):
message = "Regex didn't match: {0!r} not found in {1!r}".format(regex.pattern, text)
@@ -147,8 +147,7 @@
py3k = sys.version_info >= (3, 0)
if py3k:
- def u(s):
- return s
+ u = str
else:
def u(s):
return s.decode('UTF-8')
@@ -157,13 +156,9 @@
def b(s):
return s.encode('UTF-8')
else:
- def b(s):
- return s
+ b = bytes
-if py3k:
- long = int
-else:
- long = long
+long = type(1 << 999)
if py3k:
def cmp(x, y):
@@ -182,15 +177,7 @@
else:
from io import BytesIO as StringIO
-if py3k:
- unicode = str
-else:
- unicode = unicode
-
-if py3k:
- maxsize = sys.maxsize
-else:
- maxsize = sys.maxint
+unicode = type(u(''))
@contextlib.contextmanager
def interim(obj, **override):
@@ -256,7 +243,6 @@
'b',
'cmp',
'long',
- 'maxsize',
'py3k',
'u',
'unicode',