isbnlib


Nameisbnlib JSON
Version 3.10.14 PyPI version JSON
download
home_pagehttps://github.com/xlcnd/isbnlib
SummaryExtract, clean, transform, hyphenate and metadata for ISBNs (International Standard Book Number).
upload_time2023-04-26 08:53:05
maintainer
docs_urlNone
authorAlexandre Lima Conde
requires_python
licenseLGPL v3
keywords isbn metadata world_catalogue google_books wikipedia open_library bibtex endnote refworks msword opf bibjson
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
.. image:: https://github.com/xlcnd/isbnlib/workflows/tests/badge.svg
    :target: https://github.com/xlcnd/isbnlib/actions
    :alt: Built Status

.. image:: https://img.shields.io/github/issues/xlcnd/isbnlib/bug.svg?label=bugs&style=flat
    :target: https://github.com/xlcnd/isbnlib/labels/bug
    :alt: Bugs

.. image:: https://img.shields.io/pypi/dm/isbnlib.svg?style=flat
    :target: https://pypi.org/project/isbnlib/
    :alt: PYPI Downloads



Info
====

``isbnlib`` is a (pure) python library that provides several
useful methods and functions to validate, clean, transform, hyphenate and
get metadata for ISBN strings.



Install
-------

From the command line, enter (in some cases you have to precede the
command with ``sudo``):


.. code-block:: bash

    $ pip install isbnlib


If you use linux systems, you can install using your distribution package
manager (all major distributions have packages ``python-isbnlib``
and ``python3-isbnlib``), however (usually) are **very old and don't work well anymore**!



ISBN
----

   The official form of an ISBN is something like ``ISBN 979-10-90636-07-1``. However for most
   applications only the numbers are important, you can always 'mask' them if you need (see below).
   This library works mainly with 'striped' ISBNs  (only digits and X) like '0826497527'. You can
   strip an ISBN-like string by using ``canonical(isbnlike)``. You can
   'mask' the ISBN by using ``mask(isbn)``. So in the examples below, when you see 'isbn'
   in the argument, it is a 'striped' ISBN, when the argument is an 'isbnlike' it is a string
   like ``ISBN 979-10-90636-07-1`` or even something dirty like ``asdf 979-10-90636-07-1 bla bla``.

   Two important concepts: **valid ISBN** should be an ISBN that was built according with the rules,
   this is distinct from **issued ISBN** that is an ISBN that was already issued to a publisher
   (this is the usage of the libraries and most of the web services).
   However *isbn.org*, probably by legal reasons, merges the two!
   So, according to *isbn-international.org*, '9786610326266' is not valid (because the block 978-66...
   has not been issued yet, however if you use ``is_isbn13('9786610326266')`` you will get ``True``
   (because '9786610326266' follows the rules of an ISBN). But the situation is even murkier,
   try ``meta('9786610326266')`` and you will see that this ISBN was already used!

   If possible, work with ISBNs in the isbn-13 format (since 2007, only are issued ISBNs
   in the isbn-13 format). You can always convert isbn-10 to isbn-13, but **not** the reverse (read this_).
   Read more about ISBN at isbn-international.org_ or wikipedia_.



Main Functions
--------------

``is_isbn10(isbn10like)``
    Validates as ISBN-10.

``is_isbn13(isbn13like)``
    Validates as ISBN-13.

``to_isbn10(isbn13)``
    Transforms isbn-13 to isbn-10.

``to_isbn13(isbn10)``
    Transforms isbn-10 to isbn-13.

``canonical(isbnlike)``
    Keeps only digits and X. You will get strings like `9780321534965` and `954430603X`.

``clean(isbnlike)``
    Cleans ISBN (only legal characters).

``notisbn(isbnlike, level='strict')``
    Check with the goal to invalidate isbn-like.

``get_isbnlike(text, level='normal')``
    Extracts all substrings that seem like ISBNs (very useful for scraping).

``get_canonical_isbn(isbnlike, output='bouth')``
    Extracts ISBNs and transform them to the canonical form.

``ean13(isbnlike)``
    Transforms an `isbnlike` string into an EAN13 number (validated canonical ISBN-13).

``doi(isbn)``
    Returns a DOI's ISBN-A from a ISBN-13.

``mask(isbn, separator='-')``
    `Mask` (hyphenate) a canonical ISBN.

``info(isbn)``
    Gets the language or country assigned to this ISBN.

``meta(isbn, service='default')``
    Gives you the main metadata associated with the ISBN. As `service` parameter you can use:
    ``'goob'`` uses the **Google Books service** (**no key is needed**)  and
    **is the default option**,
    ``'wiki'`` uses the **wikipedia.org** api (**no key is needed**),
    ``'openl'`` uses the **OpenLibrary.org** api (**no key is needed**).
    You can enter API keys
    with ``config.add_apikey(service, apikey)`` (see example below).
    The output can be formatted as ``bibtex``, ``csl`` (CSL-JSON), ``msword``, ``endnote``, ``refworks``,
    ``opf`` or ``json`` (BibJSON) bibliographic formats with ``registry.bibformatters``.
    Now, you can extend the functionality of this function by adding plugins, more metadata
    providers or new bibliographic formatters (check_ for available plugins).

``editions(isbn, service='merge')``
    Returns the list of ISBNs of editions related with this ISBN. By default
    uses 'merge' (merges 'openl', 'thingl' and 'wiki'), but other providers are available:
    'openl' (uses the search API from **Open Library**),
    'thingl' (uses the service ThingISBN from **LibraryThing**),
    'wiki' (uses the service Citation from **Wikipedia**)
    and 'any' (first tries 'wiki', if no data then 'openl').

``isbn_from_words(words)``
    Returns the most probable ISBN from a list of words (for your geographic area).

``goom(words)``
    Returns a list of references from **Google Books multiple references**.

``classify(isbn)``
    Returns a dictionary of **classifiers** for a canonical ISBN. For the meaning of these classifiers see OCLC_.
    Most of the data in the underlying service are for books in english.

``desc(isbn)``
    Returns a small description of the book.
    *Almost all data available are for US books!*

``cover(isbn)``
    Returns a dictionary with the url for cover.
    *Almost all data available are for US books!*

``doi2tex(DOI)``
    Returns metadata formatted as BibTeX for a given DOI.

``ren(filename)``
    Renames a file using metadata from an ISBN in his filename.


See files test_core_ and test_ext_ for **a lot of examples**.



Plugins
-------

You can extend the functionality of the library by adding plugins (for now, just
new metadata providers or new bibliographic formatters).

For available plugins check_ here.

After install, your plugin will blend transparently in ``isbnlib`` (you will have more options in ``meta`` and ``bibformatters``).




For Devs
========


API's Main Namespaces
---------------------

In the namespace ``isbnlib`` you have access to the **core functions**:
``is_isbn10``, ``is_isbn13``, ``to_isbn10``, ``to_isbn13``, ``canonical``,
``clean``, ``notisbn``, ``get_isbnlike``, ``get_canonical_isbn``, ``mask``,
``info``, ``check_digit10``, ``check_digit13``, ``doi`` and ``ean13``.

In addition, you have access to **metadata functions**, namely:
``meta``, ``editions``, ``ren``, ``desc``, ``cover``,
``goom``, ``classify``, ``doi2tex`` and ``isbn_from_words``.

The exceptions raised by these methods can all be caught using ``ISBNLibException``.


You can extend the lib by using the classes and functions exposed in
namespace ``isbnlib.dev``, namely:

* ``WEBService`` a class that handles the access to web
  services (just by passing an url) and supports ``gzip``.
  You can subclass it to extend the functionality... but
  probably you don't need to use it! It is used in the next class.

* ``WEBQuery`` a class that uses ``WEBService`` to retrieve and parse
  data from a web service. You can build a new provider of metadata
  by subclassing this class.
  His main methods allow passing custom
  functions (*handlers*) that specialize them to specific needs (``data_checker`` and
  ``parser``). It implements a **throttling mechanism** with a default rate of
  one call per second per service.

* ``Metadata`` a class that structures, cleans and 'validates' records of
  metadata. His method ``merge`` allows to implement a simple merging
  procedure for records from different sources. The main features of this class, can be
  implemented by a call to the ``stdmeta`` function instead!

* ``vias`` exposes several functions to put calls to services, just by passing the name and
  a pointer to the service's ``query`` function.
  ``vias.parallel`` allows to put threaded calls.
  You can use ``vias.serial`` to make serial calls and
  ``vias.multi`` to use several cores. The default is ``vias.serial``.

The exceptions raised by these methods can all be caught using ``ISBNLibDevException`` (or, more general, ``ISBNLibException``).
You **shouldn't raise** this exception in your code, only raise the specific exceptions
exposed in ``isbnlib.dev`` whose name ends in Error.


In ``isbnlib.dev.helpers`` you can find several methods, that we found very useful, some of then
are only used in ``isbntools`` (*an app and framework* that uses ``isbnlib``).


With ``isbnlib.config`` you can read and set configuration options:
change timeouts with ``seturlopentimeout`` and ``setthreadstimeout``,
access api keys with ``apikeys`` and add new one with ``add_apikey``,
access and set generic and user-defined options with ``options.get('OPTION1')`` and ``set_option``.


Finally, from ``isbnlib.registry`` you can change the metadata service to be used by default
(``setdefaultservice``),
add a new service (``add_service``), access bibliographic formatters for metadata (``bibformatters``),
set the default formatter (``setdefaultbibformatter``), add new formatters (``add_bibformatter``) and
set a new cache (``set_cache``) (e.g. to switch off the cache ``set_cache(None)``).
The cache only works for calls through metadata functions. These changes only work for the 'current session',
so should be done always before calling other methods.


Let us concretize these points with a small example.

Suppose you want a small script to get metadata using ``Open Library`` formatted in BibTeX.

A minimal script would be:


.. code-block:: python

    from isbnlib import meta
    from isbnlib.registry import bibformatters

    SERVICE = "openl"

    # now you can use the service
    isbn = "9780446310789"
    bibtex = bibformatters["bibtex"]
    print(bibtex(meta(isbn, SERVICE)))



Patterns of Usage
-----------------

The library implements a very simple API with sensible defaults, but there are cases
that need your attention (see case 3 below).



A. You only need **core functions**:


.. code-block:: python

    # import the core functions you need
    from isbnlib import canonical, is_isbn10, is_isbn13

    isbn = canonical("978-0446310789")
    if is_isbn13(isbn):
        ...
    ...


B. You need also **metadata functions**, with **default config**:


.. code-block:: python

    from isbnlib import canonical, meta, description

    isbn = canonical("978-0446310789")
    data = meta(isbn)
    ...

C. You need also **metadata functions**, with **special config**:

   *Lets suppose you need to add an api key for a metadata plugin
   and change the cache too*.


.. code-block:: python

    from myapp.utils import MyCache

    # import the functions you need, plus 'config' and 'registry'
    from isbnlib import canonical, config, meta, registry

    # you should use 'config' first
    config.add_apikey("isbndb", "kjshdfkjahsdflkjh")

    # then 'registry'
    registry.set_cache(MyCache())

    # Only now you should use metadata functions
    # (there are no adaptions for core functions,
    #  so they can be used at any moment)
    isbn = canonical("978-0446310789")
    data = meta(isbn, service="isbndb")
    ...


D. You want to build a **plugin** or use **isbnlib.dev** in your code:

   You should study very carefully the **public** methods in ``dir(isbnlib.dev)``, start with this template_
   and follow the instructions there. For inspiration take a look at goob_.

   Most of the public bibliographic catalog services return data in **SRU** or **Unimarc** format. It is very easy
   to write a customer **plugin** for these services, just use porbase_ (SRU) or sbn_ (Unimarc) as templates
   and consult this project_.



Caveats
-------


1. These classes are optimized for one-call to services and not for batch calls.

2. If you inspect the library, you will see that there are a lot of private modules
   (their name starts with '_'). These modules **should not** be accessed directly since,
   with high probability, your program will break with a further version of the library!



Projects using *isbnlib*
========================

**Open Library**   https://github.com/internetarchive/openlibrary

**NYPL Library Simplified**  https://github.com/NYPL-Simplified

**RERO ILS**  https://github.com/rero/rero-ils

**CERN CDS RDM** https://github.com/CERNDocumentServer/cds-rdm

**ResearchHub** https://github.com/ResearchHub/researchhub-backend

**Manubot**   https://github.com/manubot

**isbntools**      https://github.com/xlcnd/isbntools

**isbnsrv**        https://github.com/xlcnd/isbnsrv



See the full list here_.



Help
====


If you need help, please take a look at github_ or post a question on
stackoverflow_ .



.. _github: https://github.com/xlcnd/isbnlib/discussions

.. _range: https://www.isbn-international.org/range_file_generation

.. _isbntools: https://pypi.python.org/pypi/isbntools

.. _sourcegraph: http://bit.ly/ISBNLib_srcgraph

.. _readthedocs: http://bit.ly/ISBNLib_rtd

.. _stackoverflow: http://stackoverflow.com/search?tab=newest&q=isbnlib

.. _test_core: https://github.com/xlcnd/isbnlib/blob/master/isbnlib/test/test_core.py

.. _test_ext: https://github.com/xlcnd/isbnlib/blob/master/isbnlib/test/test_ext.py

.. _isbn-international.org: https://www.isbn-international.org/content/what-isbn

.. _wikipedia: http://en.wikipedia.org/wiki/International_Standard_Book_Number

.. _python-future.org: http://python-future.org/compatible_idioms.html

.. _issue: https://github.com/xlcnd/isbnlib/issues/28

.. _check: https://pypi.python.org/pypi?%3Aaction=search&term=isbnlib_&submit=search

.. _template: https://github.com/xlcnd/isbnlib/blob/dev/PLUGIN.zip

.. _goob: https://github.com/xlcnd/isbnlib/blob/dev/isbnlib/_goob.py

.. _search: https://pypi.python.org/pypi?%3Aaction=search&term=isbnlib&submit=search

.. _51: https://github.com/xlcnd/isbnlib/issues/51

.. _here: https://github.com/xlcnd/isbnlib/network/dependents?package_id=UGFja2FnZS01MjIyODAxMQ%3D%3D

.. _OCLC: http://classify.oclc.org/classify2/

.. _this: https://bisg.org/news/479346/New-979-ISBN-Prefixes-Expected-in-2020.htm

.. _sbn: https://github.com/arangb/isbnlib-sbn/blob/main/isbnlib_sbn/_sbn.py

.. _porbase: https://github.com/xlcnd/isbnlib-porbase/blob/dev/isbnlib_porbase/_porbase.py

.. _project: https://github.com/xlcnd/isbnlib/issues?q=is%3Aissue+is%3Aopen+label%3Aproject



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xlcnd/isbnlib",
    "name": "isbnlib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ISBN metadata World_Catalogue Google_Books Wikipedia Open_Library BibTeX EndNote RefWorks MSWord opf BibJSON",
    "author": "Alexandre Lima Conde",
    "author_email": "xlcnd@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/9e/6d/55b9ee89fdfb3aacb92b975a60357c7aa547db358817e16be3b6f8f5d781/isbnlib-3.10.14.tar.gz",
    "platform": "any",
    "description": "\n.. image:: https://github.com/xlcnd/isbnlib/workflows/tests/badge.svg\n    :target: https://github.com/xlcnd/isbnlib/actions\n    :alt: Built Status\n\n.. image:: https://img.shields.io/github/issues/xlcnd/isbnlib/bug.svg?label=bugs&style=flat\n    :target: https://github.com/xlcnd/isbnlib/labels/bug\n    :alt: Bugs\n\n.. image:: https://img.shields.io/pypi/dm/isbnlib.svg?style=flat\n    :target: https://pypi.org/project/isbnlib/\n    :alt: PYPI Downloads\n\n\n\nInfo\n====\n\n``isbnlib`` is a (pure) python library that provides several\nuseful methods and functions to validate, clean, transform, hyphenate and\nget metadata for ISBN strings.\n\n\n\nInstall\n-------\n\nFrom the command line, enter (in some cases you have to precede the\ncommand with ``sudo``):\n\n\n.. code-block:: bash\n\n    $ pip install isbnlib\n\n\nIf you use linux systems, you can install using your distribution package\nmanager (all major distributions have packages ``python-isbnlib``\nand ``python3-isbnlib``), however (usually) are **very old and don't work well anymore**!\n\n\n\nISBN\n----\n\n   The official form of an ISBN is something like ``ISBN 979-10-90636-07-1``. However for most\n   applications only the numbers are important, you can always 'mask' them if you need (see below).\n   This library works mainly with 'striped' ISBNs  (only digits and X) like '0826497527'. You can\n   strip an ISBN-like string by using ``canonical(isbnlike)``. You can\n   'mask' the ISBN by using ``mask(isbn)``. So in the examples below, when you see 'isbn'\n   in the argument, it is a 'striped' ISBN, when the argument is an 'isbnlike' it is a string\n   like ``ISBN 979-10-90636-07-1`` or even something dirty like ``asdf 979-10-90636-07-1 bla bla``.\n\n   Two important concepts: **valid ISBN** should be an ISBN that was built according with the rules,\n   this is distinct from **issued ISBN** that is an ISBN that was already issued to a publisher\n   (this is the usage of the libraries and most of the web services).\n   However *isbn.org*, probably by legal reasons, merges the two!\n   So, according to *isbn-international.org*, '9786610326266' is not valid (because the block 978-66...\n   has not been issued yet, however if you use ``is_isbn13('9786610326266')`` you will get ``True``\n   (because '9786610326266' follows the rules of an ISBN). But the situation is even murkier,\n   try ``meta('9786610326266')`` and you will see that this ISBN was already used!\n\n   If possible, work with ISBNs in the isbn-13 format (since 2007, only are issued ISBNs\n   in the isbn-13 format). You can always convert isbn-10 to isbn-13, but **not** the reverse (read this_).\n   Read more about ISBN at isbn-international.org_ or wikipedia_.\n\n\n\nMain Functions\n--------------\n\n``is_isbn10(isbn10like)``\n    Validates as ISBN-10.\n\n``is_isbn13(isbn13like)``\n    Validates as ISBN-13.\n\n``to_isbn10(isbn13)``\n    Transforms isbn-13 to isbn-10.\n\n``to_isbn13(isbn10)``\n    Transforms isbn-10 to isbn-13.\n\n``canonical(isbnlike)``\n    Keeps only digits and X. You will get strings like `9780321534965` and `954430603X`.\n\n``clean(isbnlike)``\n    Cleans ISBN (only legal characters).\n\n``notisbn(isbnlike, level='strict')``\n    Check with the goal to invalidate isbn-like.\n\n``get_isbnlike(text, level='normal')``\n    Extracts all substrings that seem like ISBNs (very useful for scraping).\n\n``get_canonical_isbn(isbnlike, output='bouth')``\n    Extracts ISBNs and transform them to the canonical form.\n\n``ean13(isbnlike)``\n    Transforms an `isbnlike` string into an EAN13 number (validated canonical ISBN-13).\n\n``doi(isbn)``\n    Returns a DOI's ISBN-A from a ISBN-13.\n\n``mask(isbn, separator='-')``\n    `Mask` (hyphenate) a canonical ISBN.\n\n``info(isbn)``\n    Gets the language or country assigned to this ISBN.\n\n``meta(isbn, service='default')``\n    Gives you the main metadata associated with the ISBN. As `service` parameter you can use:\n    ``'goob'`` uses the **Google Books service** (**no key is needed**)  and\n    **is the default option**,\n    ``'wiki'`` uses the **wikipedia.org** api (**no key is needed**),\n    ``'openl'`` uses the **OpenLibrary.org** api (**no key is needed**).\n    You can enter API keys\n    with ``config.add_apikey(service, apikey)`` (see example below).\n    The output can be formatted as ``bibtex``, ``csl`` (CSL-JSON), ``msword``, ``endnote``, ``refworks``,\n    ``opf`` or ``json`` (BibJSON) bibliographic formats with ``registry.bibformatters``.\n    Now, you can extend the functionality of this function by adding plugins, more metadata\n    providers or new bibliographic formatters (check_ for available plugins).\n\n``editions(isbn, service='merge')``\n    Returns the list of ISBNs of editions related with this ISBN. By default\n    uses 'merge' (merges 'openl', 'thingl' and 'wiki'), but other providers are available:\n    'openl' (uses the search API from **Open Library**),\n    'thingl' (uses the service ThingISBN from **LibraryThing**),\n    'wiki' (uses the service Citation from **Wikipedia**)\n    and 'any' (first tries 'wiki', if no data then 'openl').\n\n``isbn_from_words(words)``\n    Returns the most probable ISBN from a list of words (for your geographic area).\n\n``goom(words)``\n    Returns a list of references from **Google Books multiple references**.\n\n``classify(isbn)``\n    Returns a dictionary of **classifiers** for a canonical ISBN. For the meaning of these classifiers see OCLC_.\n    Most of the data in the underlying service are for books in english.\n\n``desc(isbn)``\n    Returns a small description of the book.\n    *Almost all data available are for US books!*\n\n``cover(isbn)``\n    Returns a dictionary with the url for cover.\n    *Almost all data available are for US books!*\n\n``doi2tex(DOI)``\n    Returns metadata formatted as BibTeX for a given DOI.\n\n``ren(filename)``\n    Renames a file using metadata from an ISBN in his filename.\n\n\nSee files test_core_ and test_ext_ for **a lot of examples**.\n\n\n\nPlugins\n-------\n\nYou can extend the functionality of the library by adding plugins (for now, just\nnew metadata providers or new bibliographic formatters).\n\nFor available plugins check_ here.\n\nAfter install, your plugin will blend transparently in ``isbnlib`` (you will have more options in ``meta`` and ``bibformatters``).\n\n\n\n\nFor Devs\n========\n\n\nAPI's Main Namespaces\n---------------------\n\nIn the namespace ``isbnlib`` you have access to the **core functions**:\n``is_isbn10``, ``is_isbn13``, ``to_isbn10``, ``to_isbn13``, ``canonical``,\n``clean``, ``notisbn``, ``get_isbnlike``, ``get_canonical_isbn``, ``mask``,\n``info``, ``check_digit10``, ``check_digit13``, ``doi`` and ``ean13``.\n\nIn addition, you have access to **metadata functions**, namely:\n``meta``, ``editions``, ``ren``, ``desc``, ``cover``,\n``goom``, ``classify``, ``doi2tex`` and ``isbn_from_words``.\n\nThe exceptions raised by these methods can all be caught using ``ISBNLibException``.\n\n\nYou can extend the lib by using the classes and functions exposed in\nnamespace ``isbnlib.dev``, namely:\n\n* ``WEBService`` a class that handles the access to web\n  services (just by passing an url) and supports ``gzip``.\n  You can subclass it to extend the functionality... but\n  probably you don't need to use it! It is used in the next class.\n\n* ``WEBQuery`` a class that uses ``WEBService`` to retrieve and parse\n  data from a web service. You can build a new provider of metadata\n  by subclassing this class.\n  His main methods allow passing custom\n  functions (*handlers*) that specialize them to specific needs (``data_checker`` and\n  ``parser``). It implements a **throttling mechanism** with a default rate of\n  one call per second per service.\n\n* ``Metadata`` a class that structures, cleans and 'validates' records of\n  metadata. His method ``merge`` allows to implement a simple merging\n  procedure for records from different sources. The main features of this class, can be\n  implemented by a call to the ``stdmeta`` function instead!\n\n* ``vias`` exposes several functions to put calls to services, just by passing the name and\n  a pointer to the service's ``query`` function.\n  ``vias.parallel`` allows to put threaded calls.\n  You can use ``vias.serial`` to make serial calls and\n  ``vias.multi`` to use several cores. The default is ``vias.serial``.\n\nThe exceptions raised by these methods can all be caught using ``ISBNLibDevException`` (or, more general, ``ISBNLibException``).\nYou **shouldn't raise** this exception in your code, only raise the specific exceptions\nexposed in ``isbnlib.dev`` whose name ends in Error.\n\n\nIn ``isbnlib.dev.helpers`` you can find several methods, that we found very useful, some of then\nare only used in ``isbntools`` (*an app and framework* that uses ``isbnlib``).\n\n\nWith ``isbnlib.config`` you can read and set configuration options:\nchange timeouts with ``seturlopentimeout`` and ``setthreadstimeout``,\naccess api keys with ``apikeys`` and add new one with ``add_apikey``,\naccess and set generic and user-defined options with ``options.get('OPTION1')`` and ``set_option``.\n\n\nFinally, from ``isbnlib.registry`` you can change the metadata service to be used by default\n(``setdefaultservice``),\nadd a new service (``add_service``), access bibliographic formatters for metadata (``bibformatters``),\nset the default formatter (``setdefaultbibformatter``), add new formatters (``add_bibformatter``) and\nset a new cache (``set_cache``) (e.g. to switch off the cache ``set_cache(None)``).\nThe cache only works for calls through metadata functions. These changes only work for the 'current session',\nso should be done always before calling other methods.\n\n\nLet us concretize these points with a small example.\n\nSuppose you want a small script to get metadata using ``Open Library`` formatted in BibTeX.\n\nA minimal script would be:\n\n\n.. code-block:: python\n\n    from isbnlib import meta\n    from isbnlib.registry import bibformatters\n\n    SERVICE = \"openl\"\n\n    # now you can use the service\n    isbn = \"9780446310789\"\n    bibtex = bibformatters[\"bibtex\"]\n    print(bibtex(meta(isbn, SERVICE)))\n\n\n\nPatterns of Usage\n-----------------\n\nThe library implements a very simple API with sensible defaults, but there are cases\nthat need your attention (see case 3 below).\n\n\n\nA. You only need **core functions**:\n\n\n.. code-block:: python\n\n    # import the core functions you need\n    from isbnlib import canonical, is_isbn10, is_isbn13\n\n    isbn = canonical(\"978-0446310789\")\n    if is_isbn13(isbn):\n        ...\n    ...\n\n\nB. You need also **metadata functions**, with **default config**:\n\n\n.. code-block:: python\n\n    from isbnlib import canonical, meta, description\n\n    isbn = canonical(\"978-0446310789\")\n    data = meta(isbn)\n    ...\n\nC. You need also **metadata functions**, with **special config**:\n\n   *Lets suppose you need to add an api key for a metadata plugin\n   and change the cache too*.\n\n\n.. code-block:: python\n\n    from myapp.utils import MyCache\n\n    # import the functions you need, plus 'config' and 'registry'\n    from isbnlib import canonical, config, meta, registry\n\n    # you should use 'config' first\n    config.add_apikey(\"isbndb\", \"kjshdfkjahsdflkjh\")\n\n    # then 'registry'\n    registry.set_cache(MyCache())\n\n    # Only now you should use metadata functions\n    # (there are no adaptions for core functions,\n    #  so they can be used at any moment)\n    isbn = canonical(\"978-0446310789\")\n    data = meta(isbn, service=\"isbndb\")\n    ...\n\n\nD. You want to build a **plugin** or use **isbnlib.dev** in your code:\n\n   You should study very carefully the **public** methods in ``dir(isbnlib.dev)``, start with this template_\n   and follow the instructions there. For inspiration take a look at goob_.\n\n   Most of the public bibliographic catalog services return data in **SRU** or **Unimarc** format. It is very easy\n   to write a customer **plugin** for these services, just use porbase_ (SRU) or sbn_ (Unimarc) as templates\n   and consult this project_.\n\n\n\nCaveats\n-------\n\n\n1. These classes are optimized for one-call to services and not for batch calls.\n\n2. If you inspect the library, you will see that there are a lot of private modules\n   (their name starts with '_'). These modules **should not** be accessed directly since,\n   with high probability, your program will break with a further version of the library!\n\n\n\nProjects using *isbnlib*\n========================\n\n**Open Library**   https://github.com/internetarchive/openlibrary\n\n**NYPL Library Simplified**  https://github.com/NYPL-Simplified\n\n**RERO ILS**  https://github.com/rero/rero-ils\n\n**CERN CDS RDM** https://github.com/CERNDocumentServer/cds-rdm\n\n**ResearchHub** https://github.com/ResearchHub/researchhub-backend\n\n**Manubot**   https://github.com/manubot\n\n**isbntools**      https://github.com/xlcnd/isbntools\n\n**isbnsrv**        https://github.com/xlcnd/isbnsrv\n\n\n\nSee the full list here_.\n\n\n\nHelp\n====\n\n\nIf you need help, please take a look at github_ or post a question on\nstackoverflow_ .\n\n\n\n.. _github: https://github.com/xlcnd/isbnlib/discussions\n\n.. _range: https://www.isbn-international.org/range_file_generation\n\n.. _isbntools: https://pypi.python.org/pypi/isbntools\n\n.. _sourcegraph: http://bit.ly/ISBNLib_srcgraph\n\n.. _readthedocs: http://bit.ly/ISBNLib_rtd\n\n.. _stackoverflow: http://stackoverflow.com/search?tab=newest&q=isbnlib\n\n.. _test_core: https://github.com/xlcnd/isbnlib/blob/master/isbnlib/test/test_core.py\n\n.. _test_ext: https://github.com/xlcnd/isbnlib/blob/master/isbnlib/test/test_ext.py\n\n.. _isbn-international.org: https://www.isbn-international.org/content/what-isbn\n\n.. _wikipedia: http://en.wikipedia.org/wiki/International_Standard_Book_Number\n\n.. _python-future.org: http://python-future.org/compatible_idioms.html\n\n.. _issue: https://github.com/xlcnd/isbnlib/issues/28\n\n.. _check: https://pypi.python.org/pypi?%3Aaction=search&term=isbnlib_&submit=search\n\n.. _template: https://github.com/xlcnd/isbnlib/blob/dev/PLUGIN.zip\n\n.. _goob: https://github.com/xlcnd/isbnlib/blob/dev/isbnlib/_goob.py\n\n.. _search: https://pypi.python.org/pypi?%3Aaction=search&term=isbnlib&submit=search\n\n.. _51: https://github.com/xlcnd/isbnlib/issues/51\n\n.. _here: https://github.com/xlcnd/isbnlib/network/dependents?package_id=UGFja2FnZS01MjIyODAxMQ%3D%3D\n\n.. _OCLC: http://classify.oclc.org/classify2/\n\n.. _this: https://bisg.org/news/479346/New-979-ISBN-Prefixes-Expected-in-2020.htm\n\n.. _sbn: https://github.com/arangb/isbnlib-sbn/blob/main/isbnlib_sbn/_sbn.py\n\n.. _porbase: https://github.com/xlcnd/isbnlib-porbase/blob/dev/isbnlib_porbase/_porbase.py\n\n.. _project: https://github.com/xlcnd/isbnlib/issues?q=is%3Aissue+is%3Aopen+label%3Aproject\n\n\n",
    "bugtrack_url": null,
    "license": "LGPL v3",
    "summary": "Extract, clean, transform, hyphenate and metadata for ISBNs (International Standard Book Number).",
    "version": "3.10.14",
    "split_keywords": [
        "isbn",
        "metadata",
        "world_catalogue",
        "google_books",
        "wikipedia",
        "open_library",
        "bibtex",
        "endnote",
        "refworks",
        "msword",
        "opf",
        "bibjson"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ddce1eb1e2afaca49add3185e202ce9c2c6d5779b7eecb20973e43ad804eb2a4",
                "md5": "8abd2724cde4d614691be8e157dfbd0b",
                "sha256": "f885b350fc8e600a919ed46e3b07253062cd604af69885455a25a299217b3fe2"
            },
            "downloads": -1,
            "filename": "isbnlib-3.10.14-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8abd2724cde4d614691be8e157dfbd0b",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 52535,
            "upload_time": "2023-04-26T08:53:03",
            "upload_time_iso_8601": "2023-04-26T08:53:03.024759Z",
            "url": "https://files.pythonhosted.org/packages/dd/ce/1eb1e2afaca49add3185e202ce9c2c6d5779b7eecb20973e43ad804eb2a4/isbnlib-3.10.14-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9e6d55b9ee89fdfb3aacb92b975a60357c7aa547db358817e16be3b6f8f5d781",
                "md5": "342db4e7295b2944ba52fdd85a22a138",
                "sha256": "96f90864c77b01f55fa11e5bfca9fd909501d9842f3bc710d4eab85195d90539"
            },
            "downloads": -1,
            "filename": "isbnlib-3.10.14.tar.gz",
            "has_sig": false,
            "md5_digest": "342db4e7295b2944ba52fdd85a22a138",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 48046,
            "upload_time": "2023-04-26T08:53:05",
            "upload_time_iso_8601": "2023-04-26T08:53:05.486578Z",
            "url": "https://files.pythonhosted.org/packages/9e/6d/55b9ee89fdfb3aacb92b975a60357c7aa547db358817e16be3b6f8f5d781/isbnlib-3.10.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-26 08:53:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "xlcnd",
    "github_project": "isbnlib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "isbnlib"
}
        
Elapsed time: 0.05901s