| 1 |
|
| 2 |
"""SQLAlchemy Store plugin for RDFLib.""" |
| 3 |
import logging |
| 4 |
from pkg_resources import get_distribution |
| 5 |
|
| 6 |
|
| 7 |
__version__ = get_distribution("rdflib_sqlalchemy").version |
| 8 |
|
| 9 |
|
| 10 |
class NullHandler(logging.Handler): |
| 11 |
""" |
| 12 |
Null handler. |
| 13 |
|
| 14 |
c.f. |
| 15 |
http://docs.python.org/howto/logging.html#library-config |
| 16 |
and |
| 17 |
http://docs.python.org/release/3.1.3/library/logging.\ |
| 18 |
html#configuring-logging-for-a-library |
| 19 |
""" |
| 20 |
|
| 21 |
def emit(self, record): |
| 22 |
"""Emit.""" |
| 23 |
pass |
| 24 |
|
| 25 |
|
| 26 |
hndlr = NullHandler() |
| 27 |
logging.getLogger("rdflib").addHandler(hndlr) |
| 28 |
|
| 29 |
|
| 30 |
def registerplugins(): |
| 31 |
""" |
| 32 |
Register plugins. |
| 33 |
|
| 34 |
If setuptools is used to install rdflib-sqlalchemy, all the provided |
| 35 |
plugins are registered through entry_points. This is strongly recommended. |
| 36 |
|
| 37 |
However, if only distutils is available, then the plugins must be |
| 38 |
registered manually. |
| 39 |
|
| 40 |
This method will register all of the rdflib-sqlalchemy Store plugins. |
| 41 |
|
| 42 |
""" |
| 43 |
from rdflib.store import Store |
| 44 |
from rdflib import plugin |
| 45 |
|
| 46 |
try: |
| 47 |
plugin.get("SQLAlchemy", Store) |
| 48 |
except plugin.PluginException: |
| 49 |
pass |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
plugin.register( |
| 54 |
"SQLAlchemy", |
| 55 |
Store, |
| 56 |
"rdflib_sqlalchemy.store", |
| 57 |
"SQLAlchemy", |
| 58 |
) |