Skip to content

Commit

Permalink
Merge pull request #107 from goodmami/v0.6.1
Browse files Browse the repository at this point in the history
Fix #106: add wn.DatabaseError for schema changes
  • Loading branch information
goodmami authored Mar 5, 2021
2 parents 41148d2 + d25a74a commit 6d6b7c6
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 4 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
## [Unreleased]


## [v0.6.1]

**Release date: 2021-03-05**

### Added

* `wn.DatabaseError` as a more specific error type for schema changes
([#106])


## [v0.6.0]

**Release date: 2021-03-04**
Expand Down Expand Up @@ -292,6 +302,7 @@ the https://github.com/nltk/wordnet/ code which had been effectively
abandoned, but this is an entirely new codebase.


[v0.6.1]: ../../releases/tag/v0.6.1
[v0.6.0]: ../../releases/tag/v0.6.0
[v0.5.1]: ../../releases/tag/v0.5.1
[v0.5.0]: ../../releases/tag/v0.5.0
Expand Down Expand Up @@ -339,3 +350,4 @@ abandoned, but this is an entirely new codebase.
[#99]: https://github.com/goodmami/wn/issues/99
[#104]: https://github.com/goodmami/wn/issues/104
[#105]: https://github.com/goodmami/wn/issues/105
[#106]: https://github.com/goodmami/wn/issues/106
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@

---

**Notice for users upgrading to v0.6:** Version v0.6.0 introduced
changes to the database schema that require the user to rebuild their
database. Please [raise an
issue](https://github.com/goodmami/wn/issues/new) if you need help.

---

Wn is a Python library for exploring information in wordnets. Install
it from PyPI:

Expand Down
1 change: 1 addition & 0 deletions docs/api/wn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,5 @@ Exceptions
----------

.. autoexception:: Error
.. autoexception:: DatabaseError
.. autoexception:: WnWarning
3 changes: 2 additions & 1 deletion wn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
'ilis',
'ILI',
'Error',
'DatabaseError',
'WnWarning',
)

from wn._meta import __version__
from wn._exceptions import Error, WnWarning
from wn._exceptions import Error, DatabaseError, WnWarning
from wn._config import config # noqa: F401
from wn._add import add, remove
from wn._export import export
Expand Down
4 changes: 2 additions & 2 deletions wn/_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ def _check_schema_compatibility(conn: sqlite3.Connection, dbpath: Path) -> None:
try:
specs = conn.execute('SELECT id, version FROM lexicons').fetchall()
except sqlite3.OperationalError as exc:
raise wn.Error(msg) from exc
raise wn.DatabaseError(msg) from exc
else:
if specs:
installed = '\n '.join(f'{id}:{ver}' for id, ver in specs)
msg += f" Lexicons currently installed:\n {installed}"
else:
msg += ' No lexicons are currently installed.'
raise wn.Error(msg)
raise wn.DatabaseError(msg)


def schema_hash(conn: sqlite3.Connection) -> str:
Expand Down
6 changes: 6 additions & 0 deletions wn/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ class Error(Exception):
__module__ = 'wn'


class DatabaseError(Error):
"""Error class for issues with the database."""

__module__ = 'wn'


class WnWarning(Warning):
"""Generic warning class for dubious worndet operations."""

Expand Down
2 changes: 1 addition & 1 deletion wn/_meta.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

__version__ = '0.6.0'
__version__ = '0.6.1'

0 comments on commit 6d6b7c6

Please sign in to comment.