<commit_before># -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Name:        bookland
# Purpose:     International standard identifiers for books, book-like
#              publications, periodicals and notated music
#
# Author:      <NAME> (<EMAIL>)
#
# Copyright:   (c) 2016 <NAME>
# License:     This program is part of a larger application. For license
#              details please read the file LICENSE.TXT provided together
#              with the application.
# ---------------------------------------------------------------------------
# $Source$
# $Revision$


"""International standard identifiers for books, book-like publications,
periodicals and notated music
"""

import re
from .identifier import Identifier
from .gs1 import GTIN13
from .isbnutils import lookup_isbn_prefix
from .ismnutils import lookup_ismn_prefix

_pattern_1 = re.compile('^(\d+)-(\d+)-(\d+)-(\d+)(?:-(\d))?$')
_pattern_2 = re.compile('^(\d+) (\d+) (\d+) (\d+)(?: (\d))?$')


class _BooklandGTIN(GTIN13):
    """Base class for the "bookland" GTINs."""

    __slots__ = '_registrant_idx'

    @property
    def registration_group(self):
        """Return the Registration Group of the identifier."""
        return self._id[3:self._registrant_idx]

    @property
    def registrant(self):
        """Return the Registrant of the identifier."""
        return self._id[self._registrant_idx:self._ref_idx]

    publication = GTIN13.item_reference

    def __init__(self, *args):
        """An instance of {cls} can be created in two ways, by providing a
        Unicode string representation of an {cls} or by providing a GS1
        prefix, a registration group, a registrant, a publication number and,
        optionally, a check digit.<commit_msg>Silenced pep8 warning W605.<commit_after># -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Name:        bookland
# Purpose:     International standard identifiers for books, book-like
#              publications, periodicals and notated music
#
# Author:      <NAME> (<EMAIL>)
#
# Copyright:   (c) 2016 <NAME>
# License:     This program is part of a larger application. For license
#              details please read the file LICENSE.TXT provided together
#              with the application.
# ---------------------------------------------------------------------------
# $Source$
# $Revision$


r"""International standard identifiers for books, book-like publications,
periodicals and notated music
"""

import re

from .identifier import Identifier
from .gs1 import GTIN13
from .isbnutils import lookup_isbn_prefix
from .ismnutils import lookup_ismn_prefix


_pattern_1 = re.compile(r'^(\d+)-(\d+)-(\d+)-(\d+)(?:-(\d))?$')
_pattern_2 = re.compile(r'^(\d+) (\d+) (\d+) (\d+)(?: (\d))?$')


class _BooklandGTIN(GTIN13):
    """Base class for the "bookland" GTINs."""

    __slots__ = '_registrant_idx'

    @property
    def registration_group(self):
        """Return the Registration Group of the identifier."""
        return self._id[3:self._registrant_idx]

    @property
    def registrant(self):
        """Return the Registrant of the identifier."""
        return self._id[self._registrant_idx:self._ref_idx]

    publication = GTIN13.item_reference

    def __init__(self, *args):
        """An instance of {cls} can be created in two ways, by providing a
        Unicode string representation of an {cls} or by providing a GS1
        prefix, a registration group, a registrant, a publication number and,
        optionally, a check digit.
{'fraction_non_alphanumeric': 0.19565822432507654, 'fraction_numerical': 0.01001948232674645, 'mean_word_length': 2.3002754820936637, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2945788', 'n_tokens_mistral': 1020, 'n_tokens_neox': 966, 'n_words': 324}