Skip to content

Commit

Permalink
add plugin template and bootloader
Browse files Browse the repository at this point in the history
  • Loading branch information
xlcnd committed Jan 13, 2016
1 parent 757723e commit f07863a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Binary file added PLUGIN.zip
Binary file not shown.
3 changes: 3 additions & 0 deletions isbnlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def emit(self, record):
# configuration
from . import config # <-- first import

# plugin bootloader
from . import _bootloader

# main modules
from ._core import (is_isbn10, is_isbn13, to_isbn10, to_isbn13, clean,
canonical, notisbn, get_isbnlike, get_canonical_isbn,
Expand Down
22 changes: 22 additions & 0 deletions isbnlib/_bootloader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
"""Bootloader for plugins."""

# <--- NOTE: THIS CODE RUNS ON IMPORT! --->

from pkg_resources import iter_entry_points

from . import registry

# get plugins from entry_points
try: # pragma: no cover
for entry in iter_entry_points(group='isbnlib.metadata'):
registry.add_service(entry.name, entry.load())
except: # pragma: no cover
pass

# get formatters from entry_points
try: # pragma: no cover
for entry in iter_entry_points(group='isbnlib.formatters'):
registry.add_bibformatter(entry.name, entry.load())
except: # pragma: no cover
pass

0 comments on commit f07863a

Please sign in to comment.