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