Skip to content

Commit

Permalink
Merge branch '0.4-maintenance'
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Oct 22, 2016
2 parents c8582c3 + 30e8ba6 commit cb0ed86
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 18 deletions.
15 changes: 15 additions & 0 deletions docs/changes.rst
Expand Up @@ -4,6 +4,21 @@ Wand Changelog
0.4 series
~~~~~~~~~~

Version 0.4.4
~~~~~~~~~~~~~

To be released.

- Added :exc:`~wand.exceptions.BaseError`, :exc:`~wand.exceptions.BaseWarning`,
and :exc:`~wand.exceptions.BaseFatalError`, base classes for domains.
[:issue:`292`]
- Fixed :exc:`TypeError` during parsing version caused by format change of
ImageMagick version string (introduced by 6.9.6.2).
[:issue:`310`, `Debian bug report #841548`__]

__ https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=841548


Version 0.4.3
-------------

Expand Down
21 changes: 21 additions & 0 deletions tests/exceptions_test.py
@@ -0,0 +1,21 @@
from wand.exceptions import (BaseFatalError, BaseError, BaseWarning,
BlobFatalError, BlobError, BlobWarning,
WandFatalError, WandError, WandWarning)


def test_base_wand_error():
assert issubclass(WandError, BaseError)
assert issubclass(BlobError, BaseError)
assert not issubclass(BlobError, WandError)


def test_base_wand_warning():
assert issubclass(WandWarning, BaseWarning)
assert issubclass(BlobWarning, BaseWarning)
assert not issubclass(BlobWarning, WandWarning)


def test_base_wand_fatal_error():
assert issubclass(WandFatalError, BaseFatalError)
assert issubclass(BlobFatalError, BaseFatalError)
assert not issubclass(BlobFatalError, WandFatalError)
30 changes: 21 additions & 9 deletions wand/exceptions.py
Expand Up @@ -18,16 +18,28 @@ class WandException(Exception):
"""All Wand-related exceptions are derived from this class."""


class WandWarning(WandException, Warning):
"""Base class for Wand-related warnings."""
class BaseWarning(WandException, Warning):
"""Base class for Wand-related warnings.
.. versionadded:: 0.4.4
class WandError(WandException):
"""Base class for Wand-related errors."""
"""


class BaseError(WandException):
"""Base class for Wand-related errors.
.. versionadded:: 0.4.4
"""

class WandFatalError(WandException):
"""Base class for Wand-related fatal errors."""

class BaseFatalError(WandException):
"""Base class for Wand-related fatal errors.
.. versionadded:: 0.4.4
"""


class WandLibraryVersionError(WandException):
Expand Down Expand Up @@ -91,9 +103,9 @@ class WandLibraryVersionError(WandException):
#: (:class:`list`) The list of (base_class, suffix) pairs (for each code).
#: It would be zipped with :const:`DOMAIN_MAP` pairs' last element.
CODE_MAP = [
(WandWarning, 'Warning'),
(WandError, 'Error'),
(WandFatalError, 'FatalError')
(BaseWarning, 'Warning'),
(BaseError, 'Error'),
(BaseFatalError, 'FatalError')
]


Expand Down
18 changes: 9 additions & 9 deletions wand/version.py
Expand Up @@ -57,7 +57,7 @@
#:
#: .. versionchanged:: 0.1.9
#: Becomes :class:`tuple`. (It was string before.)
VERSION_INFO = (0, 4, 3)
VERSION_INFO = (0, 4, 4)

#: (:class:`basestring`) The version string e.g. ``'0.1.2'``.
#:
Expand Down Expand Up @@ -94,20 +94,20 @@
#: .. versionadded:: 0.2.1
MAGICK_VERSION_INFO = tuple(int(v or 0) for v in _match.groups())

#: (:class:`datetime.date`) The release date of the linked ImageMagick
#: library. The same to the result of :c:func:`GetMagickReleaseDate`
#: function.
#: (:class:`basestring`) The date string e.g. ``'2012-06-03'`` of
#: :const:`MAGICK_RELEASE_DATE_STRING`. This value is the exactly same
#: string to the result of :c:func:`GetMagickReleaseDate` function.
#:
#: .. versionadded:: 0.2.1
MAGICK_RELEASE_DATE_STRING = text(libmagick.GetMagickReleaseDate())

#: (:class:`basestring`) The date string e.g. ``'2012-06-03'`` of
#: :const:`MAGICK_RELEASE_DATE_STRING`. This value is the exactly same
#: string to the result of :c:func:`GetMagickReleaseDate` function.
_match = re.match(r'^(\d{4})-?(\d\d)-?(\d\d)$', MAGICK_RELEASE_DATE_STRING)
#: (:class:`datetime.date`) The release date of the linked ImageMagick
#: library. Equivalent to the result of :c:func:`GetMagickReleaseDate`
#: function.
#:
#: .. versionadded:: 0.2.1
MAGICK_RELEASE_DATE = datetime.date(
*map(int, MAGICK_RELEASE_DATE_STRING.split('-')))
MAGICK_RELEASE_DATE = datetime.date(*map(int, _match.groups()))

c_quantum_depth = ctypes.c_size_t()
libmagick.GetMagickQuantumDepth(ctypes.byref(c_quantum_depth))
Expand Down

0 comments on commit cb0ed86

Please sign in to comment.