<commit_before>#amara.lib

__all__ = ['IriError', 'inputsource']

from amara import Error
from gettext import gettext as _

class IriError(Error):
    """
    Exception related to URI/IRI processing
    """
    RESOURCE_ERROR = 1

    INVALID_BASE_URI = 100

    #RELATIVE_DOCUMENT_URI = 110
    RELATIVE_BASE_URI = 111
    OPAQUE_BASE_URI = 112

    NON_FILE_URI = 120
    UNIX_REMOTE_HOST_FILE_URI = 121

    RESOURCE_ERROR = 130

    SCHEME_REQUIRED = 200 # for SchemeRegistryResolver
    UNSUPPORTED_SCHEME = 201
    IDNA_UNSUPPORTED = 202

    INVALID_PUBLIC_ID_URN = 300

    UNSUPPORTED_PLATFORM = 1000

    def __init__(self, code, **kwds):
        if not error_messages: load_messages()
        Error.__init__(self, code, error_messages % kwds, kwds)
        return

error_messages = {}

def load_messages():
    """Lazy loading of error messages"""
    global error_messages
    error_messages = {
        # %r preferred for reporting URIs because the URI refs can be empty
        # strings or, if invalid, could contain characters unsafe for the error
        # message stream.
        IriError.INVALID_BASE_URI:
            _("Invalid base URI: %(base)r cannot be used to resolve reference %(ref)r"),
        IriError.RELATIVE_BASE_URI:
            _("Invalid base URI: %(base)r cannot be used to resolve reference %(ref)r;"
              " the base URI must be absolute, not relative."),<commit_msg>Fixed error message construction. The error message lookup was missing the suscript for error code, thus applying the keywords to the error message mapping directly.<commit_after>#amara.lib

__all__ = ['IriError', 'inputsource']

from amara import Error
from gettext import gettext as _

class IriError(Error):
    """
    Exception related to URI/IRI processing
    """
    RESOURCE_ERROR = 1

    INVALID_BASE_URI = 100

    #RELATIVE_DOCUMENT_URI = 110
    RELATIVE_BASE_URI = 111
    OPAQUE_BASE_URI = 112

    NON_FILE_URI = 120
    UNIX_REMOTE_HOST_FILE_URI = 121

    RESOURCE_ERROR = 130

    SCHEME_REQUIRED = 200 # for SchemeRegistryResolver
    UNSUPPORTED_SCHEME = 201
    IDNA_UNSUPPORTED = 202

    INVALID_PUBLIC_ID_URN = 300

    UNSUPPORTED_PLATFORM = 1000

    def __init__(self, code, **kwds):
        if not error_messages: load_messages()
        Error.__init__(self, code, error_messages[code] % kwds, kwds)
        return

error_messages = {}

def load_messages():
    """Lazy loading of error messages"""
    global error_messages
    error_messages = {
        # %r preferred for reporting URIs because the URI refs can be empty
        # strings or, if invalid, could contain characters unsafe for the error
        # message stream.
        IriError.INVALID_BASE_URI:
            _("Invalid base URI: %(base)r cannot be used to resolve reference %(ref)r"),
        IriError.RELATIVE_BASE_URI:
            _("Invalid base URI: %(base)r cannot be used to resolve reference %(ref)r;"
              " the base URI must be absolute, not relative."),
{'fraction_non_alphanumeric': 0.07473190348525469, 'fraction_numerical': 0.02546916890080429, 'mean_word_length': 3.0174966352624497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5861101', 'n_tokens_mistral': 1011, 'n_tokens_neox': 888, 'n_words': 287}