#!/usr/bin/env python3
# Copyright: 2018, Maximiliano Curia <maxy@debian.org>
#
# License: ISC
#  Permission to use, copy, modify, and/or distribute this software for any
#  purpose with or without fee is hereby granted, provided that the above
#  copyright notice and this permission notice appear in all copies.
#  .
#  THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
#  REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
#  AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
#  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
#  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
#  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
#  PERFORMANCE OF THIS SOFTWARE.

"""Regular expressions collections used by the matchers"""

from __future__ import annotations

# import the stdlib re, as re.sub is more efficient than regex.sub
import collections.abc as abc
import re as reo
from functools import partial

from ._regex import rex
from .license_parsers import (
    DetailMatch,
    caldera_detail,
    cc_at_detail,
    group_version,
    ijg_detail,
    libpng_detail,
    mackerras_detail,
    name_version,
    parse_artistic,
    parse_aswf,
    parse_boehm,
    parse_bsd,
    parse_cc_by,
    parse_cecill,
    parse_cmu_mach,
    parse_cnri,
    parse_ctan,
    parse_doc,
    parse_efl,
    parse_esa_pl,
    parse_font,
    parse_gfdl,
    parse_gpl,
    parse_hw,
    parse_lppl,
    parse_manpage,
    parse_mit,
    parse_mitre,
    parse_mulan,
    parse_osl_derived,
    parse_pd_misc,
    parse_srcavail,
    parse_ssh,
    parse_std,
    parse_tu_berlin,
    parse_uda,
    parse_usgov_pd,
    parse_zpl,
    python_detail,
)
from .license_subs import (
    APACHE_EXCEPTION_SUBS,
    BSD_EXCEPTION_SUBS,
    CC_BY_SA_EXCEPTION_SUBS,
    MIT_EXCEPTION_SUBS,
    QPL_EXCEPTION_SUBS,
)
from .re_types import ReLicense, ReSub, ReSubGroup
from .spdx import replace_spdx

# Characters that may appear in an SPDX licence id; a captured token with
# anything else (notably ':') is not an id but incidental text.
_SPDX_ID_BAD_CHAR = rex.compile(r"[^A-Za-z0-9.+-]")
_SPDX_OPERATORS = frozenset({"AND", "OR", "WITH"})
_MIN_SPDX_ID_LEN = 2


def _looks_like_spdx_id(token: str) -> bool:
    return len(token) >= _MIN_SPDX_ID_LEN and not _SPDX_ID_BAD_CHAR.search(token)


def _spdx_identifier_detail(
    _text: str, match: rex.Match[str] | reo.Match[str], _family: str
) -> str:
    """Convert an `SPDX-License-Identifier:` capture, or "" if it is not one.

    The regex grabs the `\\S+` after the marker; projects that merely mention the
    marker in code or fixtures (ruff handles SPDX itself) yield incidental text
    like `a`, `fmt:` or `SPDX-FileCopyrightText:`. Require at least one captured
    token to look like an SPDX id before trusting the capture; otherwise decline
    (return "") so no bogus licence is reported.
    """
    expr = match.group(1)
    ids = [
        tok.strip("()") for tok in expr.split() if tok.upper() not in _SPDX_OPERATORS
    ]
    if not any(_looks_like_spdx_id(tok) for tok in ids):
        return ""
    return replace_spdx(expr)


LICENSES_RES: tuple[ReLicense, ...] = (
    ReLicense(
        # Capture a full expression: a token followed by any number of
        # "OR/AND/WITH <token>" groups. clean_comments() has flattened line
        # breaks, so the operator-shaped capture (plus the parser) bounds the
        # expression rather than relying on an end-of-line.
        r"SPDX-License-Identifier: (\S+(?:\s+(?:AND|OR|WITH)\s+\S+)*)",
        "SPDX",
        _spdx_identifier_detail,
    ),
    # Community Specification License. NB: the document is itself published
    # under CC-BY-4.0, so the CC-BY / SPDX-tag matchers also fire CC-BY-4; the
    # duplicate goes away once find_licenses() de-duplicates result groups.
    ReLicense(r"Community Specification License 1\.0", "Community-Spec-1"),
    # public-domain
    # SAX is dedicated to the public domain; name it specifically before the
    # generic public-domain rule below.
    ReLicense(
        r"it's not possible to own a license to",
        "public-domain",
        lambda *_a: "SAX-PD",
    ),
    ReLicense(
        r"(:?This [^ ]+ is in|is (?:hereby |released )?"
        r"(?:in(?:to)|to|for)) "
        r"the public domain",
        "public-domain",
    ),
    ReLicense(r"This work is free of known copyright restrictions", "public-domain"),
    # Splitted to avoid having alternatives at the start of the regexp
    ReLicense(r"http:[/ ]{,2}creativecommons.org/publicdomain/mark/", "public-domain"),
    ReLicense(r"https:[/ ]{,2}creativecommons.org/publicdomain/mark/", "public-domain"),
    ReLicense(r"Public Domain, originally written by", "public-domain"),
    ReLicense(
        r"This [^ ]+ is put into the public domain, I claim "
        r"no copyright on that code",
        "public-domain",
    ),
    ReLicense(
        r" was written by(?: [^ ]+){,4}, and is placed in the "
        r"public domain\. The author hereby disclaims copyright to "
        r"this source code\.",
        "public-domain",
    ),
    ReLicense(
        r"These files[] ]+are hereby placed in the public domain without "
        r"restrictions",
        "public-domain",
    ),
    ReLicense(
        r"I hereby disclaim the copyright on this code and place it in "
        r"the public domain.",
        "public-domain",
    ),
    # Apache
    # Pixar - Apache 2.0 with one modification: Section 6 (Trademarks) is deleted
    # and replaced. That replaced clause ("Licensor and its affiliates, except as
    # required to comply with Section 4(c)") appears in both the full text and the
    # header, so this Apache-family rule fires ahead of the generic version rules
    # and names the modified licence "Pixar".
    ReLicense(
        r"Trademarks\. This License does not grant permission to use the trade "
        r"names, trademarks, service marks, or product names of the Licensor and "
        r"its affiliates, except as required to comply with Section 4\(c\) of the "
        r"License and to reproduce the content of the NOTICE file",
        "Apache",
        lambda *_a: "Pixar",
    ),
    ReLicense(r"under the Apache License, Version ([\d.]+)", "Apache", group_version),
    ReLicense(
        r"Licensed under the Apache License v([\d.]+) "
        r"https?[ :]/?/?www\.apache\.org/licenses/LICENSE-(?:[\d.]+)",
        "Apache",
        group_version,
    ),
    # "License: ... see <http://www.apache.org/licenses/LICENSE-X>" style headers
    # Allow up to ~2 lines of preamble or a preceding GPL line before the Apache URL
    ReLicense(
        r"License: (?:\S+ ){,15}see\s+https?[ :]/?/?(?:www\.)?apache\.org/licenses/LICENSE-([\d.]+)",  # noqa: E501
        "Apache",
        group_version,
    ),
    ReLicense(
        r"Apache License Version ([\d.]+), \w+ \d+ "
        r"https?[ :]/?/?www\.apache\.org/licenses/? "
        r"TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION",
        "Apache",
        group_version,
    ),
    ReLicense(
        r"Redistribution and use in source and binary forms, "
        r"with or without modification, are permitted provided "
        r"that the following conditions are met:? "
        r"(?:[^\s]+ ){,2}"
        r"Redistributions of source code must retain the "
        r"above copyright notice, this list of conditions "
        r"and the following disclaimer. "
        r"(?:[^\s]+ ){,2}"
        r"Redistributions in binary form must reproduce the "
        r"above copyright notice, this list of conditions "
        r"and the following disclaimer in the documentation "
        r"and[/ ]?or other materials provided with the "
        r"distribution. "
        r"(?:[^\s]+ ){,2}"
        r"All advertising materials mentioning features "
        r"or use of this software must display the following "
        r'acknowledgment:? "?This product includes software '
        r"developed by (?:[^\s]+ ){,32}"
        r"(?:[^\s]+ ){,2}"
        r"(?:[^\s]+ ){,32}must not be used to endorse or "
        r"promote products derived from this software without "
        r"prior written permission. For written permission, "
        r"please contact (?:[^\s]+ ){,8}"
        r"(?:[^\s]+ ){,2}"
        r"Products derived from this software may not be "
        r"called (?:[^\s]+ ){,8}nor may (?:[^\s]+ ){,8}"
        r"appear in their name, without prior written permission "
        r"of (?:[^\s]+ ){,8}"
        r"(?:[^\s]+ ){,2}"
        r"Redistributions of any form whatsoever must retain "
        r"the following acknowledgment:? "
        r'"?This product includes software developed by ',
        "Apache",
        lambda *_: "Apache-1",
    ),
    ReLicense(
        r"Redistribution and use in source and binary forms, "
        r"with or without modification, are permitted provided "
        r"that the following conditions are met:? "
        r"(?:[^\s]+ ){,2}"
        r"Redistributions of source code must retain the "
        r"above copyright notice, this list of conditions "
        r"and the following disclaimer. "
        r"(?:[^\s]+ ){,2}"
        r"Redistributions in binary form must reproduce the "
        r"above copyright notice, this list of conditions "
        r"and the following disclaimer in the documentation "
        r"and[/ ]?or other materials provided with the "
        r"distribution. "
        r"(?:[^\s]+ ){,2}"
        r"The end[- ]?user documentation included with the "
        r"redistribution, if any, must include the following "
        r"acknowledgment:? "
        r'"?This product includes software developed by .+."? '
        r"Alternately, this acknowledgment may appear in "
        r"the software itself, if and wherever such "
        r"third[- ]?party acknowledgments normally appear. "
        r"(?:[^\s]+ ){,2}"
        r"The .+ must not be used to endorse or promote "
        r"products derived from this software without prior "
        r"written permission. For written permission, please "
        r"contact .+ "
        r"(?:[^\s]+ ){,2}"
        r"Products derived from this software may not be "
        r"called .+ nor may .+ appear in their name, without "
        r"prior written permission of",
        "Apache",
        lambda *_: "Apache-1.1",
    ),
    # Artistic
    ReLicense(
        r"Released under the terms of the Artistic License "
        r"(?:v|version )?([\d.]+)",
        "Artistic",
        group_version,
    ),
    ReLicense(
        r"is distributed under the Artistic License "
        r"(?:v|version )?([\d.]+)",
        "Artistic",
        group_version,
    ),
    ReLicense(
        r"Preamble "
        r"The intent of this document is to state the conditions under "
        r"which a Package may be copied, such that the Copyright Holder "
        r"maintains some semblance of artistic control over the "
        r"development of the package, while giving the users of the "
        r"package the right to use and distribute the Package in a "
        r"more[- ]or[- ]less customary fashion, plus the right to make "
        r"reasonable modifications.",
        "Artistic",
    ),
    ReLicense(
        r'"?Artistic License"? 2\.0'
        r".+"
        r"Everyone is permitted to copy and distribute "
        r"verbatim copies of this license document, but "
        r"changing it is not allowed.",
        "Artistic",
        lambda *_: "Artistic-2",
    ),
    ReLicense(
        r"you can (?:re)?distribute (?:it and/or modify "
        r"it )?under the terms of.* the Artistic License",
        "Artistic",
    ),
    ReLicense(
        r"you may (?:re)?distribute (?:it and/or modify "
        r"it )?under the terms of.* the Artistic License",
        "Artistic",
    ),
    ReLicense(r"is free software under the Artistic License", "Artistic"),
    # The OpenSSL licence is the OpenSSL grant *and* the embedded SSLeay grant
    # (the latter is BSD-style and would otherwise be reported separately, giving
    # "OpenSSL or SSLeay"). Suppress the BSD family here so the combined file is
    # reported as the single OpenSSL id; standalone SSLeay (no OpenSSL Project
    # marker) is unaffected. Must precede the BSD rules below.
    ReLicense(
        r"developed by the OpenSSL Project for use in the OpenSSL Toolkit",
        "BSD",
        lambda *_a: None,
    ),
    # BSD-2-clause BSD-3-clause BSD-4-clause
    ReLicense(
        r"licensed under the (?:[^ ]+ ){,3}"
        r"\(?https?[ :]/?/?(?:www\.)?opensource\.org/licenses/BSD-([23])-Clause\)?",
        "BSD",
        lambda _t, m, _: f"BSD-{m.group(1)}-clause",
    ),
    # Family-entry trigger for the Sun/Oracle BSD variants, whose disclaimer
    # ("... ARE HEREBY EXCLUDED") differs from the standard BSD one below. This
    # only routes them into parse_bsd; BSD_SUBS tells the variants apart.
    ReLicense(
        r"WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, "
        r"FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY "
        r"EXCLUDED",
        "BSD",
    ),
    # Permission-style notices that do not reach the generic ISC rule (which
    # requires the "provided that ... all copies" retention clause).
    ReLicense(
        # 0BSD is ISC without the retention clause: "granted." runs straight into
        # the warranty disclaimer (ISC has "granted, provided that ... copies.").
        r"hereby granted\.\s*THE SOFTWARE IS PROVIDED",
        "ISC",
        lambda *_a: "0BSD",
    ),
    ReLicense(
        r"this software is freely granted, provided that this notice is "
        r"preserved",
        "ISC",
        lambda *_a: "SunPro",
    ),
    ReLicense(
        r"MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF THE "
        r"SOFTWARE",
        "ISC",
        lambda *_a: "Sun-PPP-2000",
    ),
    ReLicense(r"NTP No Attribution", "ISC", lambda *_a: "NTP-0"),
    # Standalone permissive notices whose own disclaimer never triggers the BSD
    # or ISC family, so each carries its own distinctive-clause anchor.
    ReLicense(
        r"the following disclaimer in the documentation provided with the "
        r"distribution\.\s*This software is provided as is and without any "
        r"warranty",
        "BSD",
        lambda *_a: "BSD-2-clause-pkgconf-disclaimer",
    ),
    ReLicense(
        # A mandatory "mark modified files with the change date" clause numbered
        # 4; the clause-4 prefix separates it from the otherwise-identical ZPL.
        r"permission from the copyright holders\. 4\. If any files are modified",
        "BSD",
        lambda *_a: "BSD-3-clause-modification",
    ),
    ReLicense(
        # Both the advertising acknowledgment (clause 3) and the "any form
        # whatsoever" acknowledgment (clause 4) appear together.
        r"display the following acknowledg(?:e)?ment:.{0,160}4\. "
        r"Redistributions of any form whatsoever must retain the following "
        r"acknowledg",
        "BSD",
        lambda *_a: "BSD-advertising-acknowledgement",
    ),
    ReLicense(
        # Permits redistribution if the notice is kept and credit is given; the
        # follow-on "name ... may not be used" clause keeps it off look-alikes.
        r"this notice is preserved and that due credit is given to the "
        r".{0,40}\. The name of the University may not be used",
        "BSD",
        lambda *_a: "BSD-4.3RENO",
    ),
    ReLicense(
        # Distinctive 4-clause endorsement wording naming the "development group".
        r"Neither the names of the development group, the copyright holders, "
        r"nor the names of contributors",
        "BSD",
        lambda *_a: "UCAR",
    ),
    ReLicense(
        r"The redistribution and use of this software \(with or without "
        r"changes\) is allowed without the payment of fees or royalties",
        "BSD",
        lambda *_a: "Brian-Gladman-2-clause",
    ),
    ReLicense(
        # The GPL re-licensing alternative is unique to the convertible variant.
        r"ALTERNATIVELY, provided that this notice is retained in full, this "
        r"product may be distributed under the terms of the GNU General "
        r"Public License",
        "BSD",
        lambda *_a: "Brian-Gladman-3-clause",
    ),
    ReLicense(
        # The non-convertible variant has the disclaimer right after the clauses.
        r"built using this software without specific written permission\. "
        r"DISCLAIMER",
        "BSD",
        lambda *_a: "Brian-Gladman-3-clause-no-conversion",
    ),
    ReLicense(
        r"copied, distributed, and sold, in both source and binary form "
        r"provided that the copyright and these terms are retained",
        "Cronyx",
    ),
    ReLicense(
        r"Redistribution and use in source \(SGML DocBook\) and .{0,4}compiled"
        r".{0,4} forms \(SGML, HTML, PDF, PostScript, RTF",
        "FreeBSD-DOC",
    ),
    ReLicense(
        r"Non-exclusive rights to redistribute, modify, translate, and use "
        r"this software",
        "Sun-PPP",
    ),
    ReLicense(
        r"Distribute freely, except: don't remove my name from the source "
        r"or documentation",
        "Vixie-Cron",
    ),
    ReLicense(
        r"Redistribution of this program in any form, with or without "
        r"modifications, is permitted, provided that the above copyright is "
        r"retained",
        "checkmk",
    ),
    ReLicense(
        r'THIS FREE SOFTWARE IS PROVIDED .*"?AS IS(?:\'\'|")? '
        r"AND ANY "
        r"EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "
        r"LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY",
        "BSD",
    ),
    ReLicense(
        r'THIS SOFTWARE IS PROVIDED .*"?AS IS(?:\'\'|")? '
        r"AND ANY "
        r"EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "
        r"LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY",
        "BSD",
    ),
    ReLicense(
        # MERCHANT[AI]BILITY tolerates the "MERCHANTIBILITY" misspelling.
        r"""THIS SOFTWARE IS PROVIDED (?:``|")?AS IS(?:''|")? AND """
        r"WITHOUT ANY EXPRESS OR "
        r"IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE "
        r"IMPLIED WARRANTIES OF MERCHANT[AI]BILITY",
        "BSD",
    ),
    ReLicense(r"licensed under (?:[^ ]+ ){,10}the BSD license", "BSD"),
    ReLicense(
        r"Redistribution and use in source and binary forms, with "
        r"or without modification, are permitted provided that "
        r"the following conditions are met.{,32}"
        r"Redistributions of source code must retain the above "
        r"copyright notice, this list of conditions and the "
        r"following disclaimer.{,32}"
        r"Redistributions in binary form must reproduce the above "
        r"copyright notice, this list of conditions and the "
        r"following disclaimer in the documentation and/or other "
        r"materials provided with the distribution.{,32}"
        r'The name "?Carnegie Mellon University"? must not be used '
        r"to endorse or promote products derived from this "
        r"software without prior written permission. For "
        r"permission or any other legal details, please contact "
        r"Office of Technology Transfer Carnegie Mellon "
        r"University.{,256}"
        r"Redistributions of any form whatsoever must retain the "
        r'following acknowledgment:? "?This product includes '
        r"software developed by Computing Services at Carnegie "
        r'Mellon University \(https?[: ]/?/?www.cmu.edu/?computing/?\)."?',
        "BSD",
        lambda *_a: "BSD-Attribution-HPND-disclaimer",
    ),
    ReLicense(
        r"Redistribution and use is allowed according to the terms of "
        r"the 2-clause BSD license.",
        "BSD",
        lambda *_a: "BSD-2-clause",
    ),
    ReLicense(
        r"Redistribution and use is allowed according to the terms of the "
        r"(?:new )?BSD license.? ([^ ]+ ){,10}COPYING-CMAKE-SCRIPTS",
        "BSD",
        lambda *_a: "BSD-3-clause",
    ),
    ReLicense(
        r"Redistribution and use is allowed according to the terms of the "
        r"BSD license.?",
        "BSD",
    ),
    ReLicense(
        r"Distributed under the OSI-approved BSD License \(the "
        r'"?License[" ]?\)',
        "BSD",
    ),
    # TODO (maxy): learn about references to named files
    ReLicense(
        r"Use of this source code is governed by a BSD-style license "
        r"that can be found in the [^ ]+ file\.",
        "BSD",
    ),
    # ISC
    ReLicense(
        r"Permission to use, copy, modify, and(?:\/or)? distribute "
        r"this (?:[^ ]+ ){,4}for any purpose with or without fee is "
        r"hereby granted.*ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER",
        "ISC",
        lambda *_a: "ISC-Veillard",
    ),
    ReLicense(
        r"Permission to use, copy, modify, and(?:\/or)? distribute "
        r"this (?:[^ ]+ ){,4}for any purpose with or without fee is "
        r"hereby granted, provided.*copyright notice.*permission "
        r"notice.*all copies"
        r".+"
        r"Except as contained in this notice, the "
        r"name of a copyright holder shall not be "
        r"used in advertising or otherwise to promote "
        r"the sale, use or other dealings in this "
        r"Software without prior written authorization "
        r"of the copyright holder",
        "ISC",
        lambda *_a: "curl",
    ),
    ReLicense(
        r"Permission to use, copy, modify, and(?:\/or)? distribute "
        r"this (?:[^ ]+ ){,4}for any purpose with or without fee is "
        r"hereby granted, provided.*copyright notice.*permission "
        r"notice.*all copies",
        "ISC",
    ),
    # Documentation / open-government / open-data licences. One cheap gate (an
    # alternation of their distinctive titles) fires the group so the per-licence
    # DOC_SUBS rules run only for matching files rather than adding a dozen-plus
    # entries to this hot scan. DOC_SUBS also requires a body clause, so a file
    # that merely *references* one of these titles is not mislabelled.
    ReLicense(
        r"Open Government Licence|Open Parliament Licence"
        r"|Norwegian Licence for Open Government Data"
        r"|Non-Commercial Government Licence|LICENCE OUVERTE"
        r"|Common Documentation License|Community Data License Agreement"
        r"|ODC Attribution License|Datenlizenz Deutschland"
        r"|Open Publication License",
        "DocLicense",
    ),
    # Font licences - one cheap gate (distinctive font-licence markers) fires the
    # group so the per-licence FONT_SUBS rules run only for matching files.
    ReLicense(
        r"ARPHIC PUBLIC LICENSE|UBUNTU FONT LICENCE|ParaType Free Font"
        r"|Bitstream propriety rights|fonts accompanying this license"
        r"|Lucida fonts from Bigelow Holmes|These fonts are free softwares"
        r"|Any use of the code is permitted as long as this copyright notice "
        r"is preserved|distribute this font is hereby granted",
        "FontLicense",
    ),
    # Open-hardware licences - one gate (the three licence-family titles) fires
    # the group so the per-licence HW_SUBS rules run only for matching files.
    ReLicense(
        r"CERN Open Hardware Licence|SOLDERPAD HARDWARE LICENSE"
        r"|TAPR Open Hardware License",
        "HardwareLicense",
    ),
    # US-Government / agency public-domain notices - one gate (the agency names /
    # distinctive markers) fires the group; parse_usgov_pd names the variant.
    ReLicense(
        r"National Institute of Standards and Technology"
        r"|National Telecommunications and Information Administration"
        r"|National Center for Biotechnology Information"
        r"|This library \(libselinux\) is public domain"
        r"|NIST-developed software is provided by NIST",
        "USGovPD",
    ),
    # Miscellaneous unrelated public-domain / "do as you wish" notices - one gate
    # of their distinctive dedication clauses fires the group; parse_pd_misc names
    # the specific id (the SAX fragment is the v2-only "SAX2 is Free" opener).
    ReLicense(
        r"here is a blessing"
        r"|attempt to disclaim copyright and place the software in the public "
        r"domain is deemed null and void"
        r"|SAX2 is Free I hereby abandon"
        r"|There is no license associated with the code"
        r"|pre-dates the open source licensing fad"
        r"|DO WHAT THE FUCK YOU WANT TO BUT IT'S NOT MY FAULT"
        r"|dedicate any and all copyright interest in this code to the public "
        r"domain"
        r"|LZMA SDK is written and placed in the public domain by Igor Pavlov",
        "PdMisc",
    ),
    # Linux man-pages licences - one gate (the FSF manual permission / the page
    # header clause) fires the group; parse_manpage names the variant and skips
    # the Latex2e family (which shares the two-paragraph permission).
    ReLicense(
        r"make and distribute verbatim copies of this manual provided the "
        r"copyright notice and this permission notice are preserved"
        r"|distribute possibly modified copies of this page provided the "
        r"header is included verbatim",
        "ManPage",
    ),
    # man2html: a one-line permission notice (not man-pages-family).
    ReLicense(
        r"Permission is granted to distribute, modify and use this program as "
        r"long as this comment is not removed or changed",
        "man2html",
    ),
    # hyphen-bulgarian: BSD-style notice whose disclaimer typo ("PROVIDES")
    # keeps it off the generic BSD warranty rule.
    ReLicense(
        r"may be used, modified, copied, distributed, and sold, both in source "
        r"and binary form provided that the above copyright notice and these "
        r"terms are retained",
        "hyphen-bulgarian",
    ),
    # CTAN / TeX licences - one gate of their distinctive clauses fires the
    # group; parse_ctan names the variant.
    ReLicense(
        r"Unlimited copying and redistribution of this package"
        r"|All users are asked to help keep"
        r"|except that this permission notice may be stated in a translation "
        r"approved by the Foundation"
        r"|freely used, transmitted, reproduced, or modified provided that the "
        r"copyright notice and this permission is retained"
        r"|The style package is copyrighted but may be used and extended in any "
        r"way"
        r"|used in other works with just one restriction"
        r"|freely transmitted, reproduced, or modified for any purpose provided "
        r"that this copyright notice is left intact"
        r"|THE TTYP0 LICENSE",
        "CtanTex",
    ),
    # Standards-body licences (Unicode + W3C-derived) - one gate of their titles
    # / the W3C-2015 "obtaining and/or copying" opener (which excludes the older
    # W3C "obtaining, using and/or copying") fires the group; parse_std names it.
    ReLicense(
        r"UNICODE LICENSE V3"
        r"|UNICODE, INC\. LICENSE AGREEMENT - DATA FILES AND SOFTWARE"
        r"|OGC Software License, Version 1\.0|WordNet Release 3\.0"
        r"|By obtaining and/?or copying this work, you \(the licensee\) agree",
        "StandardsBody",
    ),
    # Source-available / business copyleft licences - one gate of their
    # distinctive title lines fires the group; parse_srcavail names the variant.
    ReLicense(
        r"copyleft-next 0\.3"
        r"|The Parity Public License"
        r"|PolyForm Noncommercial License"
        r"|PolyForm Small Business License"
        r"|Server Side Public License"
        r"|Business Source License"
        r"|Elastic License 2\.0"
        r"|Sustainable Use License Version 1\.0",
        "SrcAvailable",
    ),
    # European Space Agency Public License - the family name fires the gate;
    # parse_esa_pl names the copyleft strength (permissive / weak / strong).
    ReLicense(
        r"European Space Agency Public License \(ESA-PL\)",
        "EsaPl",
    ),
    # TU-Berlin (GSM 06.10) notice - the shared "no representations" clause fires
    # the gate; parse_tu_berlin tells v1.0 from the v2.0 appended grant.
    ReLicense(
        r"neither the authors nor the Technische Universitaet Berlin are deemed "
        r"to have made any representations",
        "TuBerlin",
    ),
    # Open Logistics Foundation License - title-and-version line paired with the
    # opening of its definitions clause, so a bare name reference declines.
    ReLicense(
        r"Open Logistics Foundation License Version 1\.3.{0,200}Subject Matter "
        r"of the License shall mean",
        "OLFL-1.3",
    ),
    # Mulan Permissive Software License - the Chinese family title or the English
    # application notice fires the gate; parse_mulan names the version (v1/v2).
    ReLicense(
        r"木兰宽松许可证|Mulan PSL v[12]\. You can use this software",
        "MulanPsl",
    ),
    # OSL-template derivatives (TGPPL, UCL) - one gate of their distinct titles
    # fires the group; parse_osl_derived names the variant. Anchoring on the
    # titles (not the shared OSL body clause) keeps the gate off OSL/AFL/NPOSL.
    ReLicense(
        r"Transitive Grace Period Public Licence \( ?TGPPL ?\) v\. 1\.0"
        r"|Upstream Compatibility License v\. 1\.0 \(UCL-1\.0\)"
        r"|Licensed under the Transitive Grace Period Public Licence version 1\.0"
        r"|Licensed under the Upstream Compatibility License 1\.0",
        "OslDerived",
    ),
    # OSC-1.0 - a German translation of the Expat/MIT grant with a distinctive
    # German liability clause ("Kardinalpflicht"); paired so a bare grant is not
    # enough on its own.
    ReLicense(
        r"Jedem, der eine Kopie dieser Software und der zugehörigen "
        r"Dokumentationsdateien \(die Software ?\) erhält, wird hiermit "
        r"kostenlos die Erlaubnis erteilt.{0,1200}KARDINALPFLICHT",
        "OSC-1",
    ),
    # MVT-1.1 - an MPL-2.0-template derivative; the distinctive title (full text)
    # or the MPL-style header notice keeps it off the generic Mozilla rules
    # (which it does not trigger).
    ReLicense(
        r"MVT License 1\.1 1\. Definitions 1\.1\. Contributor means each "
        r"individual"
        r"|subject to the terms of the MVT License, v\. 1\.1",
        "MVT-1.1",
    ),
    # TPL-1.0 (THOR Public Licence) - an MPL derivative; its "Notes of Origin"
    # preamble (full text) or the MPL-style header notice is distinctive.
    ReLicense(
        r"THOR Public Licence \(TPL\) 0\. Notes of Origin"
        r"|subject to the THOR Public License Version 1\.0",
        "TPL-1",
    ),
    # MMPL-1.0.1 (Minecraft Mod Public License) - distinctive title-and-version.
    ReLicense(r"Minecraft Mod Public License Version 1\.0\.1", "MMPL-1.0.1"),
    # SMAIL-GPL - a clarified GPL variant; the dated title keeps it off the
    # generic GPL rules (which it does not trigger).
    ReLicense(
        r"SMAIL GENERAL PUBLIC LICENSE \(Clarified 11 Feb 1988\)",
        "SMAIL-GPL",
    ),
    # (The deprecated wxWindows id carries only the LGPL exception notice, not a
    # standalone licence; it stays undetected here and the exception is covered
    # as WxWindows-3.1 via the GPL/LGPL exception machinery.)
    # Microsoft Use of Data Agreements - the shared title clause fires the gate;
    # parse_uda names the Computational (C-UDA) / Open (O-UDA) variant.
    ReLicense(r"Use of Data Agreement, Version 1\.0 \(the", "UdaData"),
    # ASWF Digital Assets License - the distinctive "digital assets"
    # redistribution clause fires the gate; parse_aswf names the version.
    ReLicense(r"Redistribution and use of these digital assets", "AswfAssets"),
    # MITRE terms-of-use grants (CAPEC, CVE) - the shared reproduce-our-copyright
    # condition fires the gate; parse_mitre names the dataset.
    ReLicense(
        r"Any copy you make for such purposes is authorized provided that you "
        r"reproduce",
        "MitreTou",
    ),
    # OGDL-Taiwan (Open Government Data License, Chinese) - title-and-version
    # line paired with the promulgation date.
    ReLicense(
        r"政府資料開放授權條款 第1版 中華民國104年7月27日訂定",
        "OGDL-Taiwan-1",
    ),
    # UK Advanced Cryptics Dictionary - the distinctive redistribution
    # restriction on the publication.
    ReLicense(
        r"if The UK Advanced Cryptics Dictionary is used in a software package "
        r"or redistributed in any form, the copyright notice must be prominently "
        r"displayed",
        "Advanced-Cryptics-Dictionary",
    ),
    # NCL (NCAR Command Language) - a BSD-3-style notice that puts the
    # endorsement clause first; this reordered opener keeps it off the generic
    # BSD rules (which it does not trigger).
    ReLicense(
        r"Redistribution and use of the Software in source and binary forms, "
        r"with or without modification, is permitted provided that the following "
        r"conditions are met: Neither the names of",
        "NCL",
    ),
    # CMU/Mach permission notice - the shared "AS IS CONDITION" disclaimer fires
    # the gate; parse_cmu_mach names the documentation / no-doc variant.
    ReLicense(r"ALLOWS FREE USE OF THIS SOFTWARE IN ITS AS IS CONDITION", "CmuMach"),
    # SSH (Tatu Ylonen) permission notice - the shared grant clause fires the
    # gate; parse_ssh tells the full OpenSSH notice from the short form.
    ReLicense(
        r"the code I have written for this software can be used freely "
        r"for any purpose",
        "Ssh",
    ),
    # Boehm GC permission notice - the shared modified-code clause fires the gate;
    # parse_boehm names the without-fee / base variant.
    ReLicense(
        r"a notice that the code was modified is included with the above "
        r"copyright notice",
        "BoehmGc",
    ),
    # Adobe Display PostScript - the trademark-licence clause is unique to it.
    ReLicense(
        r"No trademark license to use the Adobe trademarks is hereby granted",
        "Adobe-Display-PostScript",
    ),
    # Adobe Utopia typefaces - the distinctive typeface grant clause.
    ReLicense(
        r"reproduce, display and distribute the listed typefaces", "Adobe-Utopia"
    ),
    # ssh-keyscan (David Mazieres / OpenBSD) - the due-credit redistribution
    # clause; name-free and unique.
    ReLicense(
        r"due credit is given to the author and the OpenBSD project by leaving "
        r"this",
        "ssh-keyscan",
    ),
    # OpenVision (Kerberos) - the substantive free-use grant clause; name-free.
    ReLicense(
        r"You may freely use and distribute the Source Code and Object Code "
        r"compiled from it",
        "OpenVision",
    ),
    # Documentation / book-code permission notices. Each is a standalone grant
    # with no shared structure; anchor on a substantive, mostly name-free clause.
    # AdaCore documentation - copy/alter grant requiring marked alterations.
    ReLicense(r"in any form or by any means, as is or with alterations", "AdaCore-doc"),
    # GnuCash / GCR docs - reproduce-and-redistribute grant, no more-restrictive
    # terms.
    ReLicense(
        r"This work may be reproduced and distributed in whole or in part, "
        r"in any medium",
        "GCR-docs",
    ),
    # L. Peter Deutsch document licence - copy/distribute incl. translations.
    ReLicense(
        r"including translations into other languages and incorporation "
        r"into compilations",
        "LPD-document",
    ),
    # Scheme report - the community grant-to-copy clause.
    ReLicense(
        r"We intend this report to belong to the entire Scheme community",
        "SchemeReport",
    ),
    # ALGLIB Reference Manual - a BSD-style document grant. Anchored on the
    # distinctive "first (or last) lines of this file" retention clause: the bare
    # "Redistribution and use of this document" opener collides with the Enthought
    # docs licence (verified against codesearch.debian.net).
    ReLicense(r"as the first \(or last\) lines of this file", "ALGLIB-Documentation"),
    # Graphics Gems - the distinctive "don't be a jerk" EULA clause.
    ReLicense(
        r"don't be a jerk, and remember that anything free comes with no "
        r"guarantee",
        "Graphics-Gems",
    ),
    # Game Programming Gems - copy/compile-into-applications grant.
    ReLicense(
        r"freely copy and compile this source into applications you distribute",
        "Game-Programming-Gems",
    ),
    # gtkbook (Syd Logan) - republish-in-original-form condition.
    ReLicense(
        r"republished or redistributed in its original form, as hardcopy "
        r"or electronically",
        "gtkbook",
    ),
    # McPhee slideshow macros - copy-for-other-macro-sets grant.
    ReLicense(
        r"to copy it in whole or in part for use in other macro sets",
        "McPhee-slideshow",
    ),
    # ISO permission notice - SGML-systems grant tied to ISO 8879.
    ReLicense(
        r"granted for use with conforming SGML systems and applications "
        r"as defined",
        "ISO-permission",
    ),
    # EULA / proprietary / restricted + permissive oddballs. Standalone rules
    # anchored on each licence's distinctive title or grant clause. Several are
    # non-free EULAs, detected so non-free/contrib source trees are classified too.
    # 3D Slicer Contribution and Software License Agreement.
    ReLicense(r"3D Slicer Contribution and Software License Agreement", "3D-Slicer-1"),
    # Fraunhofer FDK AAC codec library licence.
    ReLicense(r"Software License for The Fraunhofer FDK AAC Codec Library", "FDK-AAC"),
    # IEC Code Components end-user licence agreement.
    ReLicense(
        r"IEC Code Components End-user licence agreement",
        "IEC-Code-Components-EULA",
    ),
    # JPL image use policy (Caltech/NASA).
    ReLicense(r"images and video on JPL public web sites", "JPL-image"),
    # UnRAR licence - source freeware, no RAR-compatible archiver clause.
    ReLicense(r"The source code of UnRAR utility is freeware", "UnRAR"),
    # Hippocratic License 2.1 (ethical-use; non-free).
    ReLicense(r"Hippocratic License Version Number: 2\.1", "Hippocratic-2.1"),
    # OpenMDW model-materials licence.
    ReLicense(r"OpenMDW License Agreement, version 1\.0", "OpenMDW-1"),
    # Microsoft Limited Public License.
    ReLicense(r"Limited Public License \(Ms-LPL\)", "MS-LPL"),
    # GLWT(Good Luck With That) Public License.
    ReLicense(r"Good Luck With That\) Public License", "GLWTPL"),
    # SL - the "unless you try to pretend that you wrote it" grant.
    ReLicense(r"unless you try to pretend that you wrote it", "SL"),
    # BOLA - Buena Onda License Agreement.
    ReLicense(r"Buena Onda License Agreement", "BOLA-1.1"),
    # Copyfree Open Innovation License.
    ReLicense(r"Copyfree Open Innovation License", "COIL-1"),
    # Blue Oak Model License (the versioned title; "Blue Oak Model License" alone
    # is also referenced by Parity-7).
    ReLicense(r"Blue Oak Model License Version 1\.0\.0", "BlueOak-1"),
    # Assorted single-file permissive notices. Standalone rules, each on a
    # distinctive grant/title clause.
    # AMD newlib notice.
    ReLicense(
        r"grants the user the right to modify, use and distribute this software "
        r"provided this notice is not removed",
        "AMD-newlib",
    ),
    # AML / glslang (NVIDIA) notice.
    ReLicense(
        r"installation, modification or redistribution of this NVIDIA software "
        r"constitutes acceptance",
        "AML-glslang",
    ),
    # any-OSI (pick your favourite OSI licence).
    ReLicense(r"Pick your favourite OSI approved license", "any-OSI"),
    # any-OSI-perl-modules (GPL/LGPL/BSD/Artistic/any OSI licence).
    ReLicense(
        r"modified BSD, or Artistic license, or any of the other OSI",
        "any-OSI-perl-modules",
    ),
    # App::s2p - do-anything-but-do-not-claim-authorship grant.
    ReLicense(r"provided you do not restrict others from doing the same", "App-s2p"),
    # GNU Aspell Russian dictionary - patch-form redistribution grant.
    ReLicense(
        r"Permission to redistribute modifications in patch form is granted",
        "Aspell-RU",
    ),
    # Buddy (Jorn Lind-Nielsen) - the substantial-modifications clause.
    ReLicense(
        r"Substantial modifications to this software may be copyrighted by "
        r"their authors",
        "Buddy",
    ),
    # (Caldera-no-preamble is detected by the Caldera-family rule above, which
    # shares its BSD-4-clause body; see caldera_detail.)
    # Catharon Open Source License (title).
    ReLicense(r"The Catharon Open Source LICENSE", "Catharon"),
    # CFITSIO (NASA) - the full "freely use ... without fee ... disclaimer of
    # warranty appears in all copies" grant sentence; the trailing clause alone is
    # a generic permissive construction, and the warranty disclaimer is shared
    # with NIST-PD-fallback.
    ReLicense(
        r"Permission to freely use, copy, modify, and distribute this software "
        r"and its documentation without fee is hereby granted, provided that "
        r"this copyright notice and disclaimer of warranty appears in all copies",
        "CFITSIO",
    ),
    # More single-file permissive notices. Standalone rules, each on a distinctive
    # grant/title clause.
    # check-cvs - copy-and-distribute-this-file grant.
    ReLicense(
        r"Permission is granted to copy and/or distribute this file, with or "
        r"without modifications, provided this notice is preserved",
        "check-cvs",
    ),
    # Cornell lossless JPEG - the without-written-agreement + two-paragraphs grant.
    ReLicense(
        r"without written agreement is hereby granted, provided that the above "
        r"copyright notice and the following two paragraphs appear in all copies "
        r"of this software",
        "Cornell-Lossless-JPEG",
    ),
    # CryptoSwift - a zlib variant ("or binary" + a 4th acknowledgment clause).
    ReLicense(
        r"from any source or binary distribution\. Redistributions of any form "
        r"whatsoever must retain the following",
        "CryptoSwift",
    ),
    # DEC 3-clause - furnished-under-license terms.
    ReLicense(
        r"furnished under license and may be used and copied only in accordance "
        r"with the following terms and conditions",
        "DEC-3-Clause",
    ),
    # Detection Rule License - one family rule reads the version
    # (1.0 -> DRL-1, 1.1 -> DRL-1.1).
    ReLicense(r"Detection Rule License \(DRL\) ([\d.]+)", "DRL", group_version),
    # EPICS Open License (title).
    ReLicense(r"EPICS Open License", "EPICS"),
    # FBM (Michael Mauldin) - educational/recreational/commercial grant.
    ReLicense(
        r"use this file in whole or in part for any purpose, educational, "
        r"recreational or commercial",
        "FBM",
    ),
    # Ferguson Twofish - perpetual-license-to-everybody grant.
    ReLicense(
        r"grants a perpetual license to everybody to use this code for any "
        r"purpose as long as the copyright message is included",
        "Ferguson-Twofish",
    ),
    # Furuseth (OpenLDAP-style) - notice-preserved + names-not-used clause.
    ReLicense(
        r"permitted provided that this notice is preserved\. The names of the "
        r"copyright holders may not be used to endorse",
        "Furuseth",
    ),
    # Further single-file permissive notices. Standalone rules, each on a
    # distinctive grant/title clause. (IJG-short is detected by the IJG family
    # rule above, which shares its README clause.)
    # fwlw (Donald Arseneau) - freely-used-if-notice-intact grant.
    ReLicense(
        r"freely used, transmitted, reproduced, or modified provided that this "
        r"notice is left intact",
        "fwlw",
    ),
    # GD graphics library - the combined-authorship copyright statement.
    ReLicense(
        r"regarding the authorship of gd, the following copyright statement "
        r"covers all of the authors",
        "GD",
    ),
    # generic-xts (Damien Miller) - the "freer than GPL" contribute-back grant.
    ReLicense(
        r"Please contribute changes back to the authors under this freer than "
        r"GPL license",
        "generic-xts",
    ),
    # Gutmann - use-in-whatever-way-but-do-not-claim-authorship grant.
    ReLicense(
        r"You can use this code in whatever way you want, as long as you don't "
        r"try to claim you wrote it",
        "Gutmann",
    ),
    # HDF5 - a BSD-style grant "for any purpose (including commercial purposes)".
    ReLicense(
        r"permitted for any purpose \(including commercial purposes\) provided "
        r"that the following conditions are met",
        "HDF5",
    ),
    # hdparm (Mark Lord) - freely use/modify/redistribute the program.
    ReLicense(
        r"freely use, modify, and redistribute the hdparm program, as either "
        r"binary or source, or both",
        "hdparm",
    ),
    # HIDAPI - used-by-anyone-for-any-reason grant.
    ReLicense(
        r"This software may be used by anyone for any reason so long as the "
        r"copyright notice in the source files remains intact",
        "HIDAPI",
    ),
    # HTML Tidy - the distribute-source-or-portions grant.
    ReLicense(
        r"distribute this source code, or portions hereof, documentation and ex",
        "HTMLTIDY",
    ),
    # Inno Setup (Jordan Russell) - zlib-style retain-all-copyright-notices clause.
    ReLicense(
        r"All redistributions of source code files must retain all copyright "
        r"notices that are currently in place",
        "InnoSetup",
    ),
    # Yet more single-file permissive notices.
    # Jam (Perforce) - use-and-distribute-freely grant.
    ReLicense(
        r"License is hereby granted to use this software and distribute it "
        r"freely, as long as this copyright notice is retained and modifications "
        r"are clearly marked",
        "Jam",
    ),
    # JOVE editor - the "Jonathan and Jovehacks" grant.
    ReLicense(
        r"provided by Jonathan and Jovehacks without charge and without warranty",
        "jove",
    ),
    # Kazlib (Kaz Kylheku) - translate-into-proprietary-without-notice clause.
    ReLicense(
        r"This source code may be translated into executable form and "
        r"incorporated into proprietary software; there is no requirement",
        "Kazlib",
    ),
    # PNG Reference Library License - one family rule reads the major version
    # (v1 -> libpng-1.6.35, v2 -> libpng-2).
    ReLicense(
        r"PNG Reference Library License version ([\d]+)",
        "libpng",
        libpng_detail,
    ),
    # libutil (David Nugent) - the expressly-for-FreeBSD clause.
    ReLicense(
        r"This work was done expressly for inclusion into FreeBSD\. Other use is "
        r"permitted provided this notation is included",
        "libutil-David-Nugent",
    ),
    # Linux-OpenIB - BSD-2-clause body followed by the MIT NONINFRINGEMENT
    # disclaimer.
    ReLicense(
        r"provided with the distribution\. THE SOFTWARE IS PROVIDED .?AS IS.?, "
        r"WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT "
        r"LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR "
        r"PURPOSE AND NONINFRINGEMENT",
        "Linux-OpenIB",
    ),
    # lsof (Victor Abell / Purdue) - the not-subject-to-AT&T/Regents notice.
    ReLicense(
        r"This software is not subject to any license of the American Telephone "
        r"and Telegraph Company or the Regents of the University of California",
        "lsof",
    ),
    # Mackerras BSD-3-clause - one family rule; the acknowledgment variant adds a
    # "developed by Paul Mackerras" clause.
    ReLicense(
        r"THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO "
        r"THIS SOFTWARE",
        "Mackerras-3-Clause",
        mackerras_detail,
    ),
    # Still more single-file permissive notices.
    # mailprio (Tony Sanders) - download/use/modify/sell/copy grant.
    ReLicense(
        r"Rights are hereby granted to download, use, modify, sell, copy, and "
        r"redistribute this software so long as the original copyright notice",
        "mailprio",
    ),
    # Martin Birgmeier - redistribute-unmodified-or-modified grant.
    ReLicense(
        r"You may redistribute unmodified or modified versions of this source "
        r"code provided that the above copyright notice and this and the "
        r"following conditions are retained",
        "Martin-Birgmeier",
    ),
    # Minpack (University of Chicago / Argonne) - the Argonne acknowledgment.
    ReLicense(
        r"software developed by the University of Chicago, as Operator of "
        r"Argonne National Laboratory",
        "Minpack",
    ),
    # MIPS Computer Systems - reproduction/use grant if the comment is kept.
    ReLicense(
        r"MIPS Computer Systems, Inc\. grants reproduction and use rights to "
        r"all parties",
        "MIPS",
    ),
    # MIT-Festival (University of Edinburgh) - MIT-style with a 4-condition list.
    ReLicense(
        r"Any modifications must be clearly marked as such\. 3\. Original "
        r"authors. names are not deleted",
        "MIT-Festival",
    ),
    # MIT-testregex (AT&T) - MIT grant on "THIS SOFTWARE FILE" with a BSD-style
    # disclaimer.
    ReLicense(r"to any person obtaining a copy of THIS SOFTWARE FILE", "MIT-testregex"),
    # MPEG Software Simulation Group - available-without-licence-fee notice.
    ReLicense(
        r"These software programs are available to the user without any license "
        r"fee or royalty on an",
        "MPEG-SSG",
    ),
    # mpi-permissive (Etnus) - DOE-style grant; the Etnus disclaimer keeps it off
    # the shared DOE template used by DSDP/mpich.
    ReLicense(
        r"Neither Etnus, nor any of their employees, makes any warranty",
        "mpi-permissive",
    ),
    # NAIST (Nara Institute of Science and Technology) 2003.
    ReLicense(
        r"Use, reproduction, and distribution of this software is permitted\. "
        r"Any copy of this software, whether in its original form or modified, "
        r"must include both the above copyright notice",
        "NAIST-2003",
    ),
    # NICTA Public Software Licence (title).
    ReLicense(r"NICTA Public Software Licence Version 1\.0", "NICTA-1"),
    # And more single-file permissive notices.
    # OAR (On-Line Applications Research, RTEMS) - the grant clause is shared with
    # dtoa, so anchor on the OAR org name.
    ReLicense(r"On-Line Applications Research Corporation \(OAR\)", "OAR"),
    # OFFIS - free-access license grant.
    ReLicense(
        r"free access is hereby granted as a license to use this software, copy "
        r"this software and prepare",
        "OFFIS",
    ),
    # OpenPBS v2.3 (Veridian) - title.
    ReLicense(
        r"OpenPBS \(Portable Batch System\) v2\.3 Software License", "OpenPBS-2.3"
    ),
    # PADL Software - due-credit redistribution grant.
    ReLicense(r"due credit is given to PADL Software Pty Ltd", "PADL"),
    # pnmstitch (Mark Salyzyn) - source-form-only BSD variant.
    ReLicense(
        r"Redistribution and use in source form, with or without modification, "
        r"are permitted provided that redistributions of source code must retain",
        "pnmstitch",
    ),
    # python-ldap - Python-style license notice.
    ReLicense(
        r"The python-ldap package is distributed under Python-style license",
        "python-ldap",
    ),
    # Ruby-pty (Akinori Ito) - redistribute-freely grant.
    ReLicense(
        r"This software may be redistributed freely for this purpose, in full or "
        r"in part, provided that this entire copyright notice is included",
        "Ruby-pty",
    ),
    # Sendmail Open Source License (distinct from the BSD-ish Sendmail licence).
    ReLicense(r"SENDMAIL OPEN SOURCE LICENSE", "Sendmail-Open-Source-1.1"),
    # SGML Users' Group Parser Materials.
    ReLicense(r"SGMLUG hereby grants to any user", "SGMLUG-PM"),
    # snprintf (Patrick Powell) - use-for-any-purpose-if-notice-intact grant.
    ReLicense(r"This code is based on code written by Patrick Powell", "snprintf"),
    # Further single-file permissive notices.
    # SOFA (IAU Standards of Fundamental Astronomy) - use-for-any-purpose grant.
    ReLicense(
        r"Permission is granted to anyone to use the SOFA software for any "
        r"purpose, including commercial applications",
        "SOFA",
    ),
    # softSurfer - freely-used-and-modified grant.
    ReLicense(
        r"This code may be freely used and modified for any purpose providing "
        r"that this copyright notice is included with it",
        "softSurfer",
    ),
    # Soundex (Mark Mielke) - credit-where-due grant.
    ReLicense(
        r"Freedom to use these sources for whatever you want, as long as credit "
        r"is given where credit is due",
        "Soundex",
    ),
    # TCP-wrappers (Wietse Venema) - duplicate-entire-notice condition.
    ReLicense(
        r"permitted provided that this entire copyright notice is duplicated in "
        r"all such copies",
        "TCP-wrappers",
    ),
    # TekHVC (Tektronix) - the TekHVC color-space clause.
    ReLicense(r"The term .?TekHVC.? designates a particular color space", "TekHVC"),
    # TermReadKey - unlimited-distribution grant.
    ReLicense(
        r"Unlimited distribution and/or modification is allowed as long as this "
        r"copyright notice remains intact",
        "TermReadKey",
    ),
    # Third Eye Software - reproduction/use grant (org-specific: the bare grant
    # template is shared with MIPS).
    ReLicense(
        r"Third Eye Software, Inc\. grants reproduction and use rights to all "
        r"parties",
        "ThirdEye",
    ),
    # TPDL (David Muir Sharnoff) - use/modify/redistribute-at-own-risk grant.
    ReLicense(
        r"License hereby granted for anyone to use, modify or redistribute this "
        r"module at their own risk",
        "TPDL",
    ),
    # TrustedQSL (ARRL) - BSD variant referencing its Paragraph 5 disclaimer.
    ReLicense(r"disclaimer shown in Paragraph 5 \(below\)", "TrustedQSL"),
    # TTWL (Text::Tabs, David Muir Sharnoff) - the Text::Tabs name restriction.
    ReLicense(
        r"do not publicly redistribute modified versions of this code with the "
        r"name .?Text::Tabs.?",
        "TTWL",
    ),
    # Final batch of single-file permissive notices.
    # UnixCrypt (Aki Yoshida) - non-commercial-or-commercial-without-fee grant.
    ReLicense(
        r"for non-commercial or commercial purposes and without fee is hereby "
        r"granted provided that this copyright notice appears in all copies",
        "UnixCrypt",
    ),
    # URT-RLE (Utah Raster Toolkit) - the supply-the-source condition.
    ReLicense(
        r"You may not include this software in a program or other software "
        r"product without supplying the source",
        "URT-RLE",
    ),
    # w3m (Akinori Ito et al.) - use/modify/redistribute grant.
    ReLicense(
        r"Use, modification and redistribution of this software is hereby "
        r"granted, provided that this entire copyright notice is included on "
        r"any copies of this software and applications",
        "w3m",
    ),
    # Widget Workshop - non-commercial-or-commercial grant (kept-intact notice).
    ReLicense(
        r"NON-COMMERCIAL or COMMERCIAL purposes and without fee is hereby "
        r"granted, provided that this copyright notice is kept intact",
        "Widget-Workshop",
    ),
    # wwl (Diane Bruce) - do-whatever-but-not-under-GPL grant.
    ReLicense(
        r"As long as you retain this notice you can do whatever you want with "
        r"this code, except you may not license it under any form of the GPL",
        "wwl",
    ),
    # Xdebug License 1.03 (PHP-License-derived) - title.
    ReLicense(r"The Xdebug License, version 1\.03", "Xdebug-1.03"),
    # Xfig - the only-requirement-notice-remains-intact grant.
    ReLicense(
        r"with the only requirement being that this copyright notice remain "
        r"intact",
        "Xfig",
    ),
    # xkeyboard-config (Anton Zinoviev) - summarize-the-changes-in-header clause.
    ReLicense(
        r"provided that the above copyright notice is left intact and the author "
        r"of the modification summarizes the changes in this header",
        "xkeyboard-config-Zinoviev",
    ),
    # xzoom (Itai Nahshon) - the fix-the-man-page modification condition.
    ReLicense(r"The man page is fixed to reflect the change", "xzoom"),
    # Zeeff (Jon Zeeff) - use-in-any-manner grant.
    ReLicense(
        r"You can use this code in any manner, as long as you leave my name on "
        r"it and don't hold me responsible",
        "Zeeff",
    ),
    # CC-BY, CC-BY-SA, CC-BY-ND, CC-BY-NC, CC-BY-NC-SA, CC-BY-NC-ND
    ReLicense(r"http:[/ ]{,2}creativecommons.org/licenses/by", "CC-BY"),
    ReLicense(r"https:[/ ]{,2}creativecommons.org/licenses/by", "CC-BY"),
    ReLicense(
        r"is licensed under .*Creative Commons Attribution"
        r".*License",
        "CC-BY",
    ),
    ReLicense(
        r"THE WORK \(?AS DEFINED BELOW\)? IS PROVIDED UNDER THE TERMS "
        r'OF THIS CREATIVE COMMONS PUBLIC LICENSE \(?[" ]?CCPL[" ]? OR '
        r'[" ]?LICENSE[" ]?\)?\. THE WORK IS PROTECTED BY COPYRIGHT '
        r"AND/OR OTHER "
        r"APPLICABLE LAW\. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED "
        r"UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED\.",
        "CC-BY",
    ),
    ReLicense(r"License:? (?:Creative Commons|CC) Attribution", "CC-BY"),
    # English CC legal codes (versions 1.0 to 4.0 + ports) open with an Attribution
    # title shortly followed by this disclaimer; this lets parse_cc_by read the
    # title for version/variant. Requiring "Attribution" near the disclaimer
    # excludes CC0 (no Attribution) and files that merely reference CC-BY (CAL,
    # Community-Spec - they lack the disclaimer).
    ReLicense(
        r"Attribution.{0,200}is not a law firm and does not provide legal "
        r"services",
        "CC-BY",
    ),
    # Localized (non-English) CC legal codes. The German/Dutch/French ports open
    # with a "Creative Commons <localized-Attribution>" title, which carries the
    # version in Arabic numerals for parse_cc_by/CC_BY_SUBS to read; the Japanese
    # port has no Latin title, so anchor it on its "is not a law firm" disclaimer.
    # Title-anchoring the DE/NL/FR ports deliberately skips the two Austrian (-AT)
    # legal codes, which have no deed title and - for CC-BY-3.0-AT - no version
    # string anywhere in the text; firing there would emit a bare "CC-BY" and so
    # mislabel CC-BY-SA-3.0-AT (dropping its ShareAlike), which is worse than
    # leaving them undetected.
    ReLicense(
        r"Creative Commons (?:Namensnennung|Naamsvermelding|Paternité)"
        r"|法律事務所ではありません",
        "CC-BY",
    ),
    # The Austrian (-AT) 3.0 ports have no deed title, so the generic CC_BY_SUBS
    # path cannot read their version/variant; match them directly and emit the
    # full id (see cc_at_detail). Anchored on the licence's Austrian choice-of-law
    # clause, not the bare word "Österreich" (which matches any German text
    # mentioning Austria — verified against codesearch.debian.net).
    ReLicense(
        r"diesen Lizenzvertrag das Recht der Republik Österreich",
        "CC-BY",
        cc_at_detail,
    ),
    # Other CC ids that are not Attribution licences.
    ReLicense(r"Creative Commons Legal Code ShareAlike", "CC-SA-1"),
    ReLicense(r"the Dedicator or Certifier", "CC-PDDC"),
    ReLicense(
        r"has been identified as being free of known restrictions under "
        r"copyright law",
        "CC-PDM-1.0",
    ),
    # CC0
    ReLicense(r"http:[/ ]{,2}creativecommons.org/publicdomain/zero", "CC0"),
    ReLicense(r"https:[/ ]{,2}creativecommons.org/publicdomain/zero", "CC0"),
    ReLicense(
        r"To the extent possible under law, .*the person who "
        r"associated CC0 .*with this work has waived all copyright "
        r"and related or neighboring rights to this work",
        "CC0",
    ),
    ReLicense(r"person\s+associating CC0 with a Work", "CC0"),
    ReLicense(r"license:? CC0-1\.0 ", "CC0"),
    ReLicense(r"Creative Commons CC0 1\.0 ", "CC0"),
    # CDDL
    ReLicense(
        r"terms of the Common Development and Distribution License"
        r'(, Version ([^( ]+))? \(the[" ]*License[" ]?\)',
        "CDDL",
        lambda _t, m, _: "CDDL{}".format(f"-{m.group(2)}" if m.groups()[1] else ""),
    ),
    ReLicense(
        r"COMMON DEVELOPMENT AND DISTRIBUTION LICENSE "
        r"\(CDDL\) "
        r"Version ([\d.]+)",
        "CDDL",
        group_version,
    ),
    # CPL
    ReLicense(
        r"under the terms of "
        r".*(the|this) Common Public License",
        "CPL",
        lambda *_a: "CPL-1",
    ),
    ReLicense(
        r"(?:licensed|released) under the "
        r".*(the|this) Common Public License",
        "CPL",
        lambda *_a: "CPL-1",
    ),
    # EFL
    ReLicense(
        r"Permission is hereby granted to use, copy, modify and(?:/or) "
        r"distribute this [^ ]+ provided that:?"
        r"[-,.+* ]*copyright notices are retained unchanged"
        r"[-,.+* ]*any distribution of this [^ ]+ whether modified or "
        r"not, includes this (?:file|license text)[-,.+* \d]*"
        r"Permission is hereby also granted to distribute binary programs "
        r"which depend on this [^ ]+(?:provided that:)?"
        r"[-,.+* ]*if the binary program depends on a modified version of "
        r"this [^ ]+ you (must|are encouraged to) publicly release the "
        r"modified version of this",
        "EFL",
        lambda _t, m, _: "EFL-{}".format("1" if m.group(1).lower() == "must" else "2"),
    ),
    # Expat
    ReLicense(
        r"MIT license:? "
        r"\(?https?[: ]/?/?www\.opensource\.org/licenses/mit-license\.php\)?",
        "MIT/X11",
        lambda *_a: "Expat",
    ),
    ReLicense(
        r"licensed under the (?:terms of either the ?)?MIT.* "
        r"\(?https?[: ]/?/?www\.opensource\.org/licenses/mit-license\.php\)?",
        "MIT/X11",
        lambda *_a: "Expat",
    ),
    ReLicense(
        r"Some rights reserved:? "
        r"\(?https?[: ]/?/?www\.opensource\.org/licenses/mit-license\.php\)?",
        "MIT/X11",
        lambda *_a: "Expat",
    ),
    ReLicense(
        r"License(?: name)?:? MIT url:? "
        r"\(?https?[: ]/?/?www\.opensource\.org/licenses/mit-license\.php\)?",
        "MIT/X11",
        lambda *_a: "Expat",
    ),
    # as used by bluez-alsa
    ReLicense(
        r"This project is licensed under the terms of the MIT license",
        "MIT/X11",
        lambda *_a: "Expat",
    ),
    # as used by sddm
    ReLicense(
        r"SPDX-License-Identifier:? MIT "
        r"\(?https?://spdx\.org/licenses/MIT\.html\)",
        "MIT/X11",
        lambda *_a: "Expat",
    ),
    ReLicense(
        r"The above copyright notice and this permission notice "
        r"shall be included in all copies or substantial portions "
        r"of the (?:Software|Materials?)\. "
        r"The Software shall be used for Good, not Evil\.",
        "MIT/X11",
        lambda *_a: "JSON",
    ),
    # MIT/Expat-grant variants with a distinctive extra clause: match before the
    # plain X11/Expat rules below so they keep their own SPDX name.
    ReLicense(
        r"This license is an MIT license, plus a clause",
        "MIT/X11",
        lambda *_a: "MIT-Click",
    ),
    ReLicense(
        r"All redistributions must retain an intact copy of this "
        r"copyright notice and disclaimer",
        "MIT/X11",
        lambda *_a: "MIT-Wu",
    ),
    ReLicense(
        r"Permission is hereby granted, free of charge, to any "
        r"person obtaining a copy of this software and(?:/or)? "
        r'associated documentation files \(the[" ]*'
        r'(?:Software|Materials)[" ]?\), to deal in the '
        r"(?:Software|Materials) without restriction, including "
        r"without limitation the rights to use, copy, modify, "
        r"merge, publish, distribute, sublicense, and(?:/or)? "
        r"sell copies of the (?:Software|Materials?), and to "
        r"permit persons to whom the (?:Software|Materials?) "
        r"(?:is|are) furnished to do so, subject to the following "
        r"conditions:? "
        r"The above copyright notice and this permission notice "
        r"shall be included in all copies or substantial portions "
        r"of the (?:Software|Materials?)\. "
        r"THE "
        r"(?:[^ ]+ ){,256}"
        r"Except as contained in this notice, the name "
        r"(?:[^ ]+ ){,8}"
        r"shall not be used in advertising or otherwise to promote the "
        r"sale, use or other dealings in this Software without prior "
        r"written authorization from (?:[^ ]+ ){,4}.",
        "MIT/X11",
        lambda *_a: "X11",
    ),
    ReLicense(
        r"Permission is hereby granted, free of charge, to any "
        r"person obtaining a copy of this software and(?:/or)? "
        r'associated documentation files \(the[" ]*'
        r'(?:Software|Materials)[" ]?\), to deal in the '
        r"(?:Software|Materials) without restriction, including "
        r"without limitation the rights to use, copy, modify, "
        r"merge, publish, distribute, sublicense, and(?:/or)? "
        r"sell copies of the (?:Software|Materials?), and to "
        r"permit persons to whom the (?:Software|Materials?) "
        r"(?:is|are) furnished to do so, subject to the following "
        r"conditions:? "
        r"The above copyright notice and this permission notice "
        r"shall be included in all copies or substantial portions "
        r"of the (?:Software|Materials?)\. "
        r"THE ",
        "MIT/X11",
        lambda *_a: "Expat",
    ),
    # GPL
    ReLicense(
        r"GNU General Public License Usage "
        r"(?:[^ ]+ ){,2}This [^ ]+ may be used under the terms of "
        r"the GNU General "
        r"Public License version 2\.0 or 3\.0 "
        r".{,512} Qt GPL Exception version 1\.3",
        "GPL",
        lambda *_a: "GPL-2+3 with QT-1.3 exception",
    ),
    ReLicense(
        r"GNU General Public License Usage "
        r"(?:[^ ]+ ){,2}This [^ ]+ may be used under the terms of "
        r"the GNU General "
        r"Public License version 2[.0]* or \(at your option\) "
        r"the GNU General Public license version 3[.0]* or any later "
        r"version approved by the KDE Free",
        "GPL",
        lambda *_a: "GPL-2+3+KDEeV",
    ),
    ReLicense(
        r"GNU General Public License Usage "
        r"(?:[^ ]+ ){,2}This [^ ]+ may be used under the terms of "
        r"the GNU General "
        r"Public License version ([\d.]+) (or later)?"
        r".{,512} (Qt GPL Exception version 1\.3)?",
        "GPL",
        lambda _t, m, _: "GPL-{}{}{}".format(
            m.group(1).rstrip("0."),
            "+" if m.groups()[1] else "",
            " with QT-1.3 exception" if m.groups()[2] else "",
        ),
    ),
    ReLicense(
        r"you can (?:re)?distribute "
        r"(?:it|them) and(?:/or)? (?:[^ ]+ ){,10}modify (?:it|them)"
        r"under the terms of (?:the )? "
        r"(?:version [^ ]+ (?:or later )?(?:\(?only\)? )?of )?"
        r"the (?:GNU )?General Public License",
        "GPL",
    ),
    ReLicense(
        r"you may (?:re)?distribute "
        r"(?:it|them) and(?:/or)? (?:[^ ]+ ){,10}modify (?:it|them)"
        r"under the terms of (?:the )? "
        r"(?:version [^ ]+ (?:or later )?(?:\(?only\)? )?of )?"
        r"the (?:GNU )?General Public License",
        "GPL",
    ),
    ReLicense(
        r"you can (?:re)?distribute "
        r"(?:it|them) and(?:/or)? (?:[^ ]+ ){,10}modify (?:it|them)"
        r"under the terms of (?:the )? "
        r"(?:version [^ ]+ (?:or later )?(?:\(?only\)? )?of )?"
        r"the (?:GNU )?GPL",
        "GPL",
    ),
    ReLicense(
        r"you may (?:re)?distribute "
        r"(?:it|them) and(?:/or)? (?:[^ ]+ ){,10}modify (?:it|them)"
        r"under the terms of (?:the )? "
        r"(?:version [^ ]+ (?:or later )?(?:\(?only\)? )?of )?"
        r"the (?:GNU )?GPL",
        "GPL",
    ),
    ReLicense(
        r"is distributed "
        r"under the terms of (?:the )?"
        r"(?:version [^ ]+ (?:or later )?(?:\(?only\)? )?of )?"
        r"the (?:GNU )?General Public License",
        "GPL",
    ),
    ReLicense(
        r"is distributed "
        r"under the terms of (?:the )?"
        r"(?:version [^ ]+ (?:or later )?(?:\(?only\)? )?of )?"
        r"the (?:GNU )?GPL",
        "GPL",
    ),
    ReLicense(
        r"is licensed "
        r"under the terms of (?:the )?"
        r"(?:version [^ ]+ (?:or later )?(?:\(?only\)? )?of )?"
        r"the (?:GNU )?General Public License",
        "GPL",
    ),
    ReLicense(
        r"is licensed "
        r"under the terms of (?:the )?"
        r"(?:version [^ ]+ (?:or later )?(?:\(?only\)? )?of )?"
        r"the (?:GNU )?GPL",
        "GPL",
    ),
    ReLicense(
        r"(?:(?:is free software.? )?you (?:can|may) (?:re)?distribute "
        r"(?:it|them) and(?:/or)? modify (?:it|them)|is (?:distributed|"
        r"licensed)) under the terms of (?:the )?(?:GNU )?"
        r"(?:General Public License|GPL)",
        "GPL",
    ),
    ReLicense(r"is distributed (?:[^ ]+ ){,16}terms (?:[^ ]+ ){,64}GPL", "GPL"),
    ReLicense(r"is distributed under the (?:[^ ]+ ){,64}GPL", "GPL"),
    ReLicense(r"licensed under the (?:[^ ]+ ){,64}GPL ", "GPL"),
    ReLicense(
        r"may be distributed and/or modified under the "
        r"terms of the GNU General Public License",
        "GPL",
    ),
    ReLicense(
        r"You can Freely distribute this program under the GNU "
        r"General Public License",
        "GPL",
    ),
    ReLicense(
        r"GNU GENERAL PUBLIC LICENSE "
        r"Version (\d+), (?:\d+ )?\w+ \d+ "
        r"Copyright \(C\) (?:[\d, ]+) Free Software Foundation, Inc. "
        r"(?:<?https?[: ]/?/?fsf.org/>? |"
        r"51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA )?"
        r"Everyone is permitted to copy and distribute verbatim copies "
        r"of this license document, but changing it is not allowed.",
        "GPL",
        group_version,
    ),
    ReLicense(
        r"may be used under the terms of the GNU General Public License "
        r"version (\d)\.0",
        "GPL",
        group_version,
    ),
    ReLicense(
        r'license:? (?:[^ ]+ ){,2}[("]?'
        r'https?[: ]/?/?creativecommons\.org/licenses/GPL/2\.0/?[")]?',
        "GPL",
        lambda *_a: "GPL-2+",
    ),
    ReLicense(
        r"License:? GPLWithACException",
        "GPL",
        lambda *_a: "GPL with AutoConf exception",
    ),
    ReLicense(
        r"License:? GPL[- v]*([\d.]*)(\+?)",
        "GPL",
        lambda _t, m, _: "GPL{}".format(
            "-{}{}".format(m.group(1).rstrip("0."), m.group(2))
            if m.groups()[0]
            else "",
        ),
    ),
    # "License: [preamble] GPL v3 see <https://www.gnu.org/licenses/gpl.html>" style headers  # noqa: E501
    # Allow up to ~2 lines of preamble between License: and the GPL reference
    ReLicense(
        r"License: (?:\S+ ){,10}GPL[- v]+([\d.]+)(\+?)\s*see\s*https?[ :]/?/?(?:www\.)?gnu\.org/licenses/gpl",  # noqa: E501
        "GPL",
        lambda _t, m, _: "GPL-{}{}".format(m.group(1).rstrip("0."), m.group(2)),
    ),
    ReLicense(
        r"This [^ ]+ is (?:freely distributable|licensed) under "
        r"the (?:GNU (?:General )?Public License|GPL)",
        "GPL",
    ),
    ReLicense(r" GPL2 or later ", "GPL", lambda *_a: "GPL-2+"),
    ReLicense(
        r" is Free Software, released under the GNU Public "
        r"License\. ",
        "GPL",
        lambda *_a: "GPL-2+",
    ),
    # mpl alternative license
    ReLicense(
        r"may be used under the terms of "
        r"(?:[^ ]+ ){,20}the GNU General "
        r"Public License "
        r"Version ([\d.]+) ((?:or later)?)",
        "GPL",
        lambda _t, m, _: "GPL-{}{}".format(
            m.group(1).rstrip("0."),
            "+" if m.groups()[1] else "",
        ),
    ),
    # License document without the example boiler plate
    ReLicense(
        r"GNU GENERAL PUBLIC LICENSE "
        r"Version ([\d.]+),? (?:[^ ]+ ){,4}"
        r"Copyright (?:[^ ]+ ){,32}"
        r"Everyone is permitted to copy and distribute verbatim copies "
        r"of this license document, but changing it is not allowed\.",
        "GPL",
        partial(name_version, name="GPL"),
    ),
    # LGPL
    ReLicense(
        r"GNU (?:Lesser|Library) General Public License Usage "
        r"(?:[^ ]+ ){,2}This [^ ]+ may be used under the terms of "
        r"the GNU (?:Lesser|Library) General "
        r"Public License version ([\d.]+) (or later)?"
        r".{,512} (Qt LGPL Exception version ([\d.]+))?",
        "LGPL",
        lambda _t, m, _: "LGPL-{}{}{}".format(
            m.group(1).rstrip("0."),
            "+" if m.groups()[1] else "",
            f" with QT-{m.group(4)} exception" if m.groups()[2] else "",
        ),
    ),
    ReLicense(
        r"GNU Lesser General Public License Usage "
        r"(?:[^ ]+ ){,2}This [^ ]+ may be used under the terms of "
        r"the GNU Lesser General "
        r"Public License version 2\.1 "
        r".{,512} Qt LGPL Exception version 1\.1",
        "LGPL",
        lambda *_a: "LGPL-2.1 with QT-1.1 exception",
    ),
    ReLicense(
        r"Qwt License Version 1.0,? .+"
        r"The Qwt library and included programs are provided under "
        r"the terms of the GNU LESSER GENERAL PUBLIC LICENSE ",
        "LGPL",
        lambda *_a: "LGPL-2.1 with Qwt-1 exception",
    ),
    ReLicense(
        r"(?:(?:is free software.? )?you (?:can|may) (?:re)?distribute "
        r"(?:it|them) and(?:/or)? modify (?:it|them)|is (?:distributed|"
        r"licensed)) under the terms (?:and conditions )?of (?:the )?"
        r"(?:version [^ ]+ "
        r"(?:\(?only\)? )?of )?the (?:GNU )?"
        r"(?:(?:Library(?:/Lesser)? |Lesser(?:/Library)? )"
        r"(?:GNU )?General Public Licen[sc]e|LGPL)",
        "LGPL",
    ),
    ReLicense(
        r"(?:(?:is free software.? )?you (?:can|may) (?:re)?distribute "
        r"(?:it|them) and(?:/or)? modify (?:it|them)|is (?:distributed|"
        r"licensed)) under the terms of (?:the )?(?:GNU )?"
        r"(?:(?:Library |Lesser(?:/Library)? )(?:GNU )?General Public "
        r"(?:version(?: [^ ]+){,5} )?License|LGPL)",
        "LGPL",
    ),
    ReLicense(r"licensed under (?:[^ ]+ ){,10}LGPL ", "LGPL"),
    ReLicense(
        r"may be (?:distributed and/or modified|used) under the terms of "
        r"the GNU Lesser(?:/Library)? "
        r"General Public License",
        "LGPL",
    ),
    ReLicense(
        r"This [^ ]+ is "
        r"(?:distributed|freely distributable|licensed) under "
        r"the (?:(?:terms|conditions) of the |license )?(?:GNU )?"
        r"(?:(?:Lesser|Library) (?:General )?"
        r"Public License|LGPL)",
        "LGPL",
    ),
    # mpl alternative license
    ReLicense(
        r"may be used under the terms of "
        r"(?:[^ ]+ ){,20}the GNU (?:Lesser|Library) General "
        r"Public License "
        r"Version ([\d.]+) ((?:or later)?)",
        "LGPL",
        lambda _t, m, _: "LGPL-{}{}".format(
            m.group(1).rstrip("0."),
            "+" if m.groups()[1] else "",
        ),
    ),
    ReLicense(
        r"License:? LGPL[- v]*([\d.]*)(\+?)",
        "LGPL",
        lambda _t, m, _: "LGPL{}".format(
            "-{}{}".format(m.group(1).rstrip("0."), m.group(2))
            if m.groups()[0] and m.group(1).rstrip("0.")
            else "",
        ),
    ),
    ReLicense(r"Distributed under the LGPL\.", "LGPL"),
    ReLicense(
        r"This (?:[^ ]+ ){,2}is free software licensed under the "
        r"GNU LGPL(?:\.|->) You can find a copy of this license in "
        r"LICENSE\.txt in the top directory of the source "
        r"code(\.|->)",
        "LGPL",
    ),  # found in marble, actually lgpl-2.1+
    ReLicense(
        r"This version of the GNU Lesser General Public License "
        r"incorporates the terms and conditions of version 3 of the "
        r"GNU General Public License, supplemented by the additional "
        r"permissions listed below.",
        "LGPL",
        lambda *_a: "LGPL-3+",
    ),
    # GFDL, GFDL-NIV
    ReLicense(
        r"Permission is (?:hereby )?granted to copy, distribute "
        r"and(?:/or)? modify this [^ ]+ under the terms of the GNU "
        r"Free Documentation License",
        "GFDL",
    ),
    ReLicense(
        r"[< ]legalnotice[> ][& ]?FDLNotice;[< ]/legalnotice[> ]",
        "GFDL",
        lambda *_a: "GFDL-1.2+",
    ),
    # LPPL
    ReLicense(
        r"This [^ ]+ (?:(?:can|may)(?: be)?|is) (?:re)?distributed "
        r"and(?:/or)? modified under the (?:terms|conditions) of "
        r"the LaTeX Project Public License",
        "LPPL",
    ),
    # MPL
    # cpal is based on the mpl 1.1
    ReLicense(
        r"The contents of this file are subject to the Common "
        r"Public Attribution License Version ([\d.]+) \(the "
        r'(?:“|")?License(?:”|[" ])?\);? you may not use '
        r"this file except in compliance with the License\.",
        "MPL",
        partial(name_version, name="CPAL"),
    ),
    # erlpl is based on the mpl 1.0
    ReLicense(
        r"The contents of this file are subject to the Erlang "
        r"Public License,? Version ([\d.]+),? \(the "
        r'(?:“|")?License(?:”|[" ])?\);? you may not use '
        r"this file except in compliance with the License\.",
        "MPL",
        partial(name_version, name="ErlPL"),
    ),
    # interbase is based on the mpl 1.1
    ReLicense(
        r"The contents of this file are subject to the Interbase Public "
        r'License Version ([\d.]+),? \(the (?:“|")?License(?:”|[" ])?\);? '
        r"you may not use this file except in compliance with the "
        r"License\.",
        "MPL",
        partial(name_version, name="Interbase"),
    ),
    # Hack to avoid the license listing in LiLiQ-R to match the MPL catch all
    ReLicense(
        r"Licence Libre du Québec [-–]? ?Réciprocité \(LiLiQ-R\) "  # noqa: RUF001
        r"Version ([\d.]+) "
        r"1\. Préambule ",
        "MPL",
        partial(name_version, name="LiLiQ-R"),
    ),
    ReLicense(
        r"This Source Code Form is subject to the terms of the "
        r"Mozilla Public License, (?:v\.|version) ([\d.]+)\. "
        r"If a copy of the MPL was not distributed with this "
        r"file, You can obtain one at "
        r"https?[: ]/?/?mozilla.org/MPL/[\d.]+/?\. "
        r'This Source Code Form is [“"]?Incompatible With '
        r'Secondary Licenses[”" ]?, as defined by the Mozilla Public '
        r"License, (?:v.|version) [\d.]+\.",
        "MPL",
        lambda _t, m, _: "MPL-{} with no-copyleft exception".format(
            m.group(1).rstrip(".0"),
        ),
    ),
    ReLicense(
        r"The contents of this file are subject to the Netscape Public "
        r'License Version ([\d.]+) \(the "?License[" ]\);? you may not '
        r"use this file except in compliance with the License\. You may "
        r"obtain a copy of the License at "
        r"https?[: ]/?/?www.mozilla.org/NPL/? "
        r"Software distributed under the License is distributed on an "
        r'"?AS IS"? basis, WITHOUT WARRANTY OF ANY KIND, either express '
        r"or implied\. See the License for the specific language "
        r"governing rights and limitations under the License\. "
        r"(?:[^\s]+ ){,8192}"
        r"The contents of this file are subject to the Mozilla Public "
        r'License Version ([\d.]+) \(the "?License[" ]\);? you may not '
        r"use this file except in compliance with the License\. You may "
        r"obtain a copy of the License at "
        r"https?[: ]/?/?www.mozilla.org/MPL/? "
        r"Software distributed under the License is distributed on an "
        r'"?AS IS"? basis, WITHOUT WARRANTY OF ANY KIND, either express '
        r"or implied\. See the License for the specific language "
        r"governing rights and limitations under the License\.",
        "MPL",
        lambda _t, m, _: "MPL-{}_NPL-{}".format(
            m.group(2).rstrip(".0"),
            m.group(1).rstrip(".0"),
        ),
    ),
    ReLicense(
        r"The contents of this file are subject to the Mozilla Public "
        r'License Version ([\d.]+) \(the "?(?:License|MPL)[" ]\);? '
        r"you may not "
        r"use this file except in compliance with the (?:License|MPL)"
        r"(?: or as specified alternatively below)?"
        r"\. You may "
        r"obtain a copy of the (?:License|MPL) at "
        r"https?[: ]/?/?www.mozilla.org/MPL/? "
        r"Software distributed under the (?:License|MPL) is distributed "
        r"on an "
        r'"?AS IS"? basis, WITHOUT WARRANTY OF ANY KIND, either express '
        r"or implied\. See the (?:License|MPL) for the specific language "
        r"governing rights and limitations under the (?:License|MPL)\.",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"Mozilla Public License,? (?:Version|v\.?) ?([\d+]+)\.? "
        r"If a copy of the MPL was not distributed with this file, "
        r"You can obtain one at https?[: ]/?/?mozilla.org/MPL/[\d.]+//?",
        "MPL",
        group_version,
    ),
    # catch dual licensed
    ReLicense(
        r"(?:licensed|released) under the (?:[^ ]+ ){,32}"
        r"Mozilla Public License,? (?:\(?MPL\)? )?v(?:ersion)?\.? ?([\d.]+)?",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"may be used under the terms of "
        r"(?:either )?the (?:[^ ]+ ){,32}"
        r"Mozilla Public License,? (?:\(?MPL\)? )?v(?:ersion)?\.? ?([\d.]+)?",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"is distributed under the terms of "
        r"(?:either )?(?:[^ ]+ ){,32}the "
        r"Mozilla Public License,? (?:\(?MPL\)? )?v(?:ersion)?\.? ?([\d.]+)?",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"Licensed? ?:(?:: OSI Approved ::)? ?"
        r"Mozilla Public License,? (?:\(?MPL\)? )?v(?:ersion)?\.? ?([\d.]+)?",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"is made available subject to the terms of the "
        r"Mozilla Public License,? (?:\(?MPL\)? )?v(?:ersion)?\.? ?([\d.]+)?",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"is subject to the terms of the "
        r"Mozilla Public License,? (?:\(?MPL\)? )?v(?:ersion)?\.? ?([\d.]+)?",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"is to be made available under the terms of the "
        r"Mozilla Public License,? (?:\(?MPL\)? )?v(?:ersion)?\.? ?([\d.]+)?",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"permits you to use, modify, and distribute this file "
        r"in accordance with the terms of the "
        r"Mozilla Public License,? (?:\(?MPL\)? )?v(?:ersion)?\.? ?([\d.]+)?",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"the contents of this file "
        r"(?:may be used|are also (?:re)?distributable) under the terms of "
        r"(?:either )? the "
        r"Mozilla Public License,? (?:\(?MPL\)? )?v(?:ersion)?\.? ?([\d.]+)?",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"is free software and is available to be redistributed and/or "
        r"modified under the terms of (?:either )?the (?:[^ ]+ ){,32}"
        r"Mozilla Public License,? (?:\(?MPL\)? )?v(?:ersion)?\.? ?([\d.]+)?",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"use under the restrictions of the (?:[^ ]+ ){,32}"
        r"Mozilla Public License,? (?:\(?MPL\)? )?v(?:ersion)?\.? ?([\d.]+)?",
        "MPL",
        group_version,
    ),
    ReLicense(
        r"you can redistribute it and/or modify it under the terms of "
        r"(?:one or more of the following,? )?(?:[^\s]+ ){,64}"
        r"Mozilla Public License as published by the The Mozilla "
        r"Foundation;? version ([\d.]+)",
        "MPL",
        group_version,
    ),
    # Perl
    ReLicense(
        r"you can redistribute it and/or modify it under the "
        r"same terms as Perl",
        "GPL",
        lambda *_a: "GPL-1+",
    ),
    ReLicense(
        r"you can redistribute it and/or modify it under the "
        r"same terms as Perl",
        "Artistic",
        lambda *_a: "Artistic-1-Perl",
    ),
    # Python
    ReLicense(
        r"(?:licensed under the"
        r"|released under"
        r"|according to the terms of the"
        r"|license:) "
        r"PYTHON SOFTWARE FOUNDATION LICENSE( VERSION ([^ ]+))?",
        "Python",
        python_detail,
    ),
    ReLicense(
        r"PYTHON SOFTWARE FOUNDATION LICENSE( VERSION ([^ ]+))? "
        r"See "
        r"https?[: ]/?/?www.opensource.org/licenses/Python-[\d.]+ "
        r"for full terms",
        "Python",
        python_detail,
    ),
    ReLicense(
        r"PYTHON SOFTWARE FOUNDATION LICENSE( VERSION ([^ ]+))? "
        r"([^\s]+ ){,16}"
        r"This LICENSE AGREEMENT is between the Python Software "
        r"Foundation",
        "Python",
        python_detail,
    ),
    # QPL
    ReLicense(
        r"may be distributed under the terms "
        r"of the Q Public License( version ([\d.]+))",
        "QPL",
        lambda _t, m, _: "QPL{}".format(
            f"-{m.group(2)}".rstrip(".0") if m.groups()[1] else "",
        ),
    ),
    ReLicense(
        r"may redistribute it under the terms "
        r"of the Q Public License( version ([\d.]+))",
        "QPL",
        lambda _t, m, _: "QPL{}".format(
            f"-{m.group(2)}".rstrip(".0") if m.groups()[1] else "",
        ),
    ),
    ReLicense(
        r"This file is part of the .*Qt GUI Toolkit. This file may "
        r"be distributed under the terms of the Q Public License "
        r"as defined",
        "QPL",
    ),
    # W3C
    ReLicense(
        r"This [^ ]+ (?:(?:may|can)(?: be)?|is) (?:re)distributed "
        r"under the (?:W3C®|W3C) Software License",
        "W3C",
    ),
    # Zlib
    # Eurosym license extends zlib
    ReLicense(
        r"The origin of this software must not be misrepresented"
        r".*Altered source versions must be plainly marked as such"
        r".*You must not use any of the names of the authors "
        r"or copyright holders of the original software for "
        r"advertising or publicity pertaining to distribution "
        r"without specific, written prior permission"
        r".*If you change this software and redistribute parts "
        r"or all of it in any form, you must make the source "
        r"code of the altered version of this software available"
        r".*This notice may not be removed or altered from any "
        r"source distribution",
        "Zlib",
        lambda *_a: "Eurosym",
    ),
    # cube license extends zlib
    ReLicense(
        r"The origin of this software must not be misrepresented"
        r".*Altered source versions must be plainly marked as such"
        r".*This notice may not be removed or altered from any "
        r"source distribution"
        r'.*Source versions may not be "?relicensed"? '
        r"under a different license without my explicitly "
        r"written permission\.",
        "Zlib",
        lambda *_a: "Cube",
    ),
    ReLicense(
        r"The origin of this software must not be misrepresented;? "
        r"you must not claim that you wrote the original "
        r"software\. If you use this software in a product, an "
        r"acknowledgment (?:\(see the following\) )?in the "
        r"product documentation is required\."
        r".*Altered source versions must be plainly marked as such"
        r".*This notice may not be removed or altered from any "
        r"source distribution",
        "Zlib",
        lambda *_a: "Zlib-acknowledgement",
    ),
    ReLicense(
        r"The origin of this software must not be misrepresented"
        r".*Altered source versions must be plainly marked as such"
        r".*This notice may not be removed or altered from any "
        r"source distribution",
        "Zlib",
    ),
    ReLicense(r"see copyright notice in zlib\.h", "Zlib"),
    ReLicense(
        r"This code is released under the libpng license",
        "Zlib",
        lambda *_a: "Libpng",
    ),
    # Zope
    ReLicense(
        r"This [^ ]+ (?:(?:(?:can|may)(?: be)?|is) (?:re)?distributed "
        r"and(?:/or)? modified under the (?:terms|conditions)|is "
        r"subject to the provisions) of the Zope Public License",
        "ZPL",
    ),
    ReLicense(r"Zope Public License \(?ZPL\)?", "ZPL"),
    # Other licenses not in:
    # https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
    ReLicense(
        r"Permission is granted to make and distribute "
        r"verbatim copies of this document provided that "
        r"the copyright notice and this permission notice "
        r"are preserved on all copies. "
        r"Permission is granted to copy and distribute "
        r"modified versions of this document under the "
        r"conditions for verbatim copying, provided that "
        r"the entire resulting derived work is distributed "
        r"under the terms of a permission notice identical "
        r"to this one.",
        "Abstyles",
        lambda *_a: "Abstyles",
    ),
    ReLicense(
        r"Licensed under the Academic Free License version "
        r"([\d.]+)",
        "Academic",
        group_version,
    ),
    ReLicense(
        r"This file may be freely copied and redistributed "
        r"as long as:? "
        r"(?:[^\s]+ ){,2}"
        r"This entire notice continues to be included in "
        r"the file[,.]? "
        r"(?:[^\s]+ ){,2}"
        r"If the file has been modified in any way, a notice "
        r"of such modification is conspicuously indicated.",
        "Adobe",
        lambda *_a: "Afmparse",
    ),
    ReLicense(
        r"Permission is hereby granted, free of charge, "
        r"to any person obtaining a copy of this documentation "
        r"file, to create their own derivative works from the "
        r"content of this document to use, copy, publish, "
        r"distribute, sublicense, and\/or sell the derivative "
        r"works, and to permit others to do the same, provided "
        r"that the derived work is not represented as being "
        r"a copy or version of this document. "
        r"Adobe shall not be liable to any party for any loss ",
        "Adobe",
        lambda *_a: "Adobe-Glyph",
    ),
    ReLicense(
        r"Adobe Systems Incorporated grants to you a perpetual, "
        r"worldwide, non-exclusive, no-charge, royalty-free, "
        r"irrevocable copyright license, to reproduce, prepare "
        r"derivative works of, publicly display, publicly "
        r"perform, and distribute this source code and such "
        r"derivative works in source or object code form without "
        r"any attribution requirements\.",
        "Adobe",
        lambda *_a: "Adobe-2006",
    ),
    ReLicense(
        r"This file and the (?:\d+ )?PostScript[\( ]?R\)? "
        r"AFM files it accompanies may be used, copied, and "
        r"distributed for any purpose and without charge, "
        r"with or without modification, provided that all "
        r"copyright notices are retained;? that the AFM "
        r"files are not distributed without this file;? "
        r"that all modifications to this file or any of "
        r"the AFM files are prominently noted in the modified "
        r"file[\( ]?s[\) ]?;? and that this paragraph is "
        r"not modified. Adobe Systems has no responsibility "
        r"or obligation to support the use of the AFM files.",
        "Adobe",
        lambda *_a: "APAFML",
    ),
    ReLicense(
        r'This software code is made available "?AS IS"? '
        r"without warranties of any kind. You may copy, "
        r"display, modify and redistribute the software "
        r"code either by itself or as incorporated into "
        r"your code; provided that you do not remove any "
        r"proprietary notices. Your use of this software "
        r"code is at your own risk and you waive any claim "
        r"against Amazon Digital Services, Inc. or its "
        r"affiliates with respect to your use of this software "
        r"code.",
        "ADSL",
    ),
    ReLicense(
        r"(?:(?:is free software.? )?you (?:can|may) (?:re)?distribute "
        r"(?:it|them) and(?:/or)? modify (?:it|them)|is (?:distributed|"
        r"licensed)) under the terms of (?:the )?(?:version [^ ]+ "
        r"(?:\(?only\)? )?of )?the (?:GNU )?"
        r"(?:Affero (?:GNU )?General Public License|AGPL)",
        "AGPL",
    ),
    ReLicense(
        r"(?:(?:is free software.? )?you (?:can|may) (?:re)?distribute "
        r"(?:it|them) and(?:/or)? modify (?:it|them)|is (?:distributed|"
        r"licensed)) under the terms of (?:the )?(?:GNU )?"
        r"(?:Affero (?:GNU )?General Public License|AGPL)",
        "AGPL",
    ),
    ReLicense(
        r"The licenses for most software are designed to take away your "
        r"freedom to share and change it. By contrast, the Affero "
        r"General Public License is intended to guarantee your freedom "
        r"to share and change free software[- ]?-?to make sure the "
        r"software "
        r"is free for all its users. This Public License applies to "
        r"most "
        r"of Affero[\' ]?s software and to any other program whose "
        r"authors "
        r"commit to using it. \(?Some other Affero software is covered by "
        r"the GNU Library General Public License instead.\)? You can "
        r"apply "
        r"it to your programs, too.",
        "AGPL",
        lambda *_a: "AGPL-1",
    ),
    ReLicense(
        r"Aladdin Enterprises hereby grants to anyone the "
        r"permission to apply this License to their own "
        r"work, as long as the entire License \(?including "
        r"the above notices and this paragraph\)? is copied "
        r"with no changes, additions, or deletions except "
        r"for changing the first paragraph of Section 0 "
        r"to include a suitable description of the work "
        r"to which the license is being applied and of "
        r"the person or entity that holds the copyright "
        r"in the work, and, if the License is being applied "
        r"to a work created in a country other than the "
        r"United States, replacing the first paragraph "
        r"of Section 6 with an appropriate reference to "
        r"the laws of the appropriate country.",
        "Aladdin",
    ),
    ReLicense(
        r"Redistribution and use in any form of this material "
        r"and any product thereof including software in "
        r"source or binary forms, along with any related "
        r"documentation, with or without modification "
        r'\(?[" ]this material[" ]\)?, is permitted provided '
        r"that the following conditions are met:? "
        r"(?:[^\s]+ ){,80}"
        r"Neither the names nor trademarks of (?:[^\s]+ ){,8}"
        r"(?:or )?any copyright holders or contributors may "
        r"be used to endorse or promote products derived "
        r"from this material without specific prior written "
        r"permission.",
        "AMDPLPA",
    ),
    ReLicense(
        r"In consideration of your agreement to abide by "
        r"the following terms, and subject to these terms, "
        r"Apple grants you a personal, non-exclusive license, "
        r"under Apple[\' ]?s copyrights in this original "
        r'Apple software \(?the "?Apple Software[" ]?\)?, '
        r"to use, reproduce, modify and redistribute the "
        r"Apple Software, with or without modifications, "
        r"in source and[/ ]or binary forms;? provided that "
        r"if you redistribute the Apple Software in its "
        r"entirety and without modifications, you must "
        r"retain this notice and the following text and "
        r"disclaimers in all such redistributions of the "
        r"Apple Software. Neither the name, trademarks, "
        r"service marks or logos of Apple Computer, Inc. "
        r"may be used to endorse or promote products derived "
        r"from the Apple Software without specific prior "
        r"written permission from Apple. Except as expressly "
        r"stated in this notice, no other rights or licenses, "
        r"express or implied, are granted by Apple herein, "
        r"including but not limited to any patent rights "
        r"that may be infringed by your derivative works "
        r"or by other works in which the Apple Software "
        r"may be incorporated.",
        "AML",
    ),
    ReLicense(
        r"We reserve no legal rights to the ANTLR-?[- ]?"
        r"it is fully in the public domain. An individual "
        r"or company may do whatever they wish with source "
        r"code distributed with ANTLR or the code generated "
        r"by ANTLR, including the incorporation of ANTLR, "
        r"or its output, into commerical software.",
        "public-domain",
        lambda *_a: "ANTLR-PD",
    ),
    ReLicense(
        r"THE LICENSED WORK IS PROVIDED UNDER THE TERMS OF "
        r"(?:THIS|THE) ADAPTIVE PUBLIC LICENSE "
        r'\(?[" ]?LICENSE[" ]?[\) ]?',
        "APL",
        lambda *_a: "APL-1",
    ),
    ReLicense(
        r"APPLE PUBLIC SOURCE LICENSE "
        r"Version ([\d.]+) - \w+ \d+, \d+ "
        r"Please read this License carefully before downloading this "
        r"software\. By downloading (?:and|or) using this software, "
        r"you are "
        r"agreeing to be bound by the terms of this License\. If you do "
        r"not or cannot agree to the terms of this License, please do "
        r"not download or use the software.",
        "APSL",
        group_version,
    ),
    ReLicense(
        r"This file contains Original Code and/or Modifications of "
        r"Original Code as defined in and that are subject to the Apple "
        r"Public Source License Version ([\d.]+) \(the \'?License[\' ]?\). "
        r"You may not use this file except in compliance with the "
        r"License\. Please obtain a copy of the License at "
        r".+ "
        r"and read it before using this file.",
        "APSL",
        group_version,
    ),
    ReLicense(
        r"These patterns were developed for internal GMV "
        r"use and are made public in the hope that they "
        r"will benefit others. Also, spreading these patterns "
        r"throughout the Spanish[- ]language TeX community "
        r"is expected to provide back[- ]benefits to GMV in "
        r"that it can help keeping GMV in the mainstream "
        r"of spanish users.",
        "Bahyph",
    ),
    ReLicense(
        r"Its use is unrestricted. It may be freely distributed, "
        r"unchanged, for non[- ]commercial or commercial "
        r"use. If changed, it must be renamed. Inclusion "
        r"in a commercial software package is also permitted, "
        r"but I would appreciate receiving a free copy for "
        r"my personal examination and use.",
        "Barr",
    ),
    ReLicense(
        r"The contents of this file are subject to the "
        r"BitTorrent Open Source License Version ([\d.]+) \(the "
        r"License\). You may not copy or use this file, "
        r"in either source code or executable form, except "
        r"in compliance with the License.",
        "BitTorrent",
        group_version,
    ),
    ReLicense(
        r"You may freely use, modify, and/or distribute "
        r"each of the files in this package without limitation. "
        r"The package consists of the following files:?"
        r".+"
        r"Of course no support is guaranteed",
        "Borceux",
    ),
    ReLicense(r"License: BSD Protection license", "BSD", lambda *_a: "BSD-protection"),
    ReLicense(
        r"Boost Software License[ .,-]+(Version (\d+(?:\.\d+)*)[ .,-]+?)?",
        "BSL",
        lambda _t, m, _: "BSL{}".format(
            "-{}".format(m.group(2).rstrip(".0")) if m.groups()[1] else "",
        ),
    ),
    ReLicense(
        r"Permission is hereby granted, free of charge, to any "
        r"person or organization obtaining a copy of the software "
        r"and accompanying documentation covered by this license "
        r'\(the[" ]*Software[" ]?\)',
        "BSL",
    ),
    ReLicense(r"THE BEER-WARE LICENSE", "Beerware"),
    # Caldera family - the shared BSD-4-clause body fires the rule; caldera_detail
    # returns "Caldera" when the ancient-UNIX "fee free license" preamble is also
    # present, else "Caldera-no-preamble".
    ReLicense(
        r"software developed or owned by Caldera International",
        "Caldera",
        caldera_detail,
    ),
    ReLicense(
        r"Computer Associates Trusted Open Source License "
        r"(?:Version )?1\.1",
        "CATOSL",
        lambda *_a: "CATOSL-1.1",
    ),
    ReLicense(
        r"CeCILL FREE SOFTWARE LICENSE AGREEMENT\s+Version ([\d.]+)",
        "CeCILL",
        group_version,
    ),
    ReLicense(r"CeCILL FREE SOFTWARE LICENSE AGREEMENT", "CeCILL"),
    ReLicense(
        r"Ce contrat est une licence de logiciel libre "
        r"dont l\'objectif est de conférer aux utilisateurs "
        r"la liberté de modification et de redistribution "
        r"du logiciel régi par cette licence dans le cadre "
        r"d\'un modèle de diffusion "
        r"(?:en logiciel libre"
        r"|(?:« ?)?open source ?»? ?"
        r"(?: fondée sur le droit français)?)\.",
        "CeCILL",
    ),
    ReLicense(
        r"The purpose of this Free Software Licensing Agreement "
        r"is to grant users the right to modify and redistribute "
        r"the software governed by this license within the "
        r'framework of an ["«]? ?open source ?["»]? '
        r"distribution model\. ",
        "CeCILL",
    ),
    ReLicense(
        r"Ce contrat est une licence de logiciel libre "
        r"dont l\'objectif est de conférer aux utilisateurs "
        r"une très large liberté de modification et de "
        r"redistribution du logiciel régi par cette licence\. ",
        "CeCILL",
        lambda *_a: "CeCILL-B",
    ),
    ReLicense(
        r"This Agreement is an open source software license "
        r"intended to give users significant freedom to "
        r"modify and redistribute the software licensed "
        r"hereunder\. ",
        "CeCILL",
        lambda *_a: "CeCILL-B",
    ),
    ReLicense(
        r"Ce contrat est une licence de logiciel libre "
        r"dont l\'objectif est de conférer aux utilisateurs "
        r"la liberté de modifier et de réutiliser le logiciel "
        r"régi par cette licence\. ",
        "CeCILL",
        lambda *_a: "CeCILL-C",
    ),
    ReLicense(
        r"The purpose of this Free Software license agreement "
        r"is to grant users the right to modify and re[- ]?use "
        r"the software governed by this license\. ",
        "CeCILL",
        lambda *_a: "CeCILL-C",
    ),
    ReLicense(r"under the terms of the CeCILL-([^ ]+) ", "CeCILL", group_version),
    ReLicense(r"under the terms of the CeCILL ", "CeCILL"),
    # The Python 2.0/2.0.1 collection embeds a CNRI agreement; suppress the CNRI
    # family so the whole file is reported under the single Python id (detected
    # by the Python family). The BeOpen heading appears only in the collection.
    ReLicense(
        r"BEOPEN PYTHON OPEN SOURCE LICENSE",
        "CNRI",
        lambda *_a: None,
    ),
    ReLicense(
        r"is made available subject to the terms and conditions "
        r"in CNRI\'?s License Agreement\.",
        "CNRI",
    ),
    ReLicense(
        r"IS PROVIDED UNDER THE TERMS OF THIS CODE PROJECT "
        r"OPEN LICENSE",
        "CPOL",
        lambda *_a: "CPOL-1.02",
    ),
    ReLicense(
        r"is distributed in the hope that it will be useful, "
        r"but WITHOUT ANY WARRANTY\. No author or distributor "
        r"accepts responsibility to anyone for the consequences "
        r"of using it or for whether it serves any particular "
        r"purpose or works at all, unless he says so in "
        r"writing\. "
        r"Everyone is granted permission to copy, modify "
        r"and redistribute .+, provided this copyright notice "
        r"is preserved and any modifications are indicated\.",
        "Crossword",
    ),
    ReLicense(
        r"The module is,?(?: [^ ]+){,5} licensed under(:? [^ ]+){,2} "
        r"CRYPTOGAMS(?: [^ ]+){,16} "
        r"https?[: ]/?/?www.openssl.org/[~ ]?appro/cryptogams",
        "CRYPTOGAMS",
    ),
    ReLicense(
        r"is freeware. This means you can pass copies around "
        r"freely provided you include this document in it\'s "
        r"original form in your distribution\.",
        "CrystalStacker",
    ),
    ReLicense(
        r"The contents of this file are subject to the "
        r"CUA Office Public License Version ([\d.]+)",
        "CUA-OPL",
        group_version,
    ),
    ReLicense(
        r"Dieses Programm kann durch jedermann gemäß den "
        r"Bestimmungen der Deutschen Freien Software Lizenz "
        r"genutzt werden\.",
        "D-FSL",
    ),
    ReLicense(
        r"is open-source, freely available software, you "
        r"are free to use, modify, copy, and distribute--perpetually "
        r"and irrevocably--",
        "DOC",
    ),
    ReLicense(
        r"This file may be freely transmitted and reproduced, "
        r"but it may not be changed unless the name is changed "
        r"also (?:\(except that you may freely change the "
        r"paper-size option for \\?documentclass\))?\. "
        r"This notice must be left intact\.",
        "Dotseqn",
    ),
    ReLicense(
        r"This program discloses material protectable under "
        r"copyright laws of the United States\. Permission "
        r"to copy and modify this software and its documentation "
        r"is hereby granted, provided that this notice is "
        r"retained thereon and on all copies or modifications\. ",
        "DSDP",
    ),
    ReLicense(
        r"A modified version of this file may be distributed, "
        r"but it should be distributed with a \*?different\*? "
        r"name\. Changed files must be distributed \*?together "
        r"with a complete and unchanged\*? distribution of "
        r"these files\.",
        "dvipdfm",
    ),
    ReLicense(
        r"1. you can do what you want with it "
        r"2. I refuse any responsibility for the consequences",
        "Permissive",
        lambda *_a: "diffmark",
    ),
    ReLicense(
        r"Licensed under the Educational Community License,? version "
        r"([\d.]+)",
        "ECL",
        group_version,
    ),
    ReLicense(
        r"Permission is hereby granted to use, copy, modify "
        r"and/or distribute this package, provided that:? "
        r"copyright notices are retained unchanged,? "
        r"any distribution of this package, whether modified "
        r"or not, includes this (?:license text|file)",
        "EFL",
    ),
    ReLicense(
        r"Subject to the terms and conditions "
        r"(?:in|of this) eGenix.com Public License Agreement",
        "CNRI",
        lambda *_a: "eGenix",
    ),
    ReLicense(
        r"Redistribution and use in source and binary forms, "
        r"with or without modification, are permitted provided "
        r"that the following conditions are met:? "
        r".{,4}Redistributions of source code must retain "
        r"the above copyright notice, this list of conditions "
        r"and the following disclaimer. "
        r".{,4}Redistributions in binary form must reproduce "
        r"the above copyright notice, this list of conditions "
        r"and the following disclaimer in the documentation "
        r"and/or other materials provided with the distribution. "
        r".{,4}The end-user documentation included with the "
        r"redistribution, if any, must include the following "
        r"acknowledgment:? "
        r'"?This product includes open source software developed by '
        r"(?:[^ ]+ ){,16}"
        r"Alternately, this acknowledgment may appear in the software "
        r"itself, if and wherever such third-party acknowledgments "
        r"normally appear. "
        r".{,4}The names? (?:[^ ]+ ){,8}must not be used to "
        r"endorse or promote products derived from this software "
        r"without prior written permission. For written permission, "
        r"please contact (?:[^ ]+ ){,8}"
        r".{,4}Products derived from this software may not be called "
        r"(?:[^ ]+ ){,8}nor may (?:[^ ]+ ){,8}appear in their name, "
        r"without prior written permission of (?:[^ ]+ ){,4}"
        r"""THIS SOFTWARE IS PROVIDED (?:``|''|")?AS IS(?:''|")? AND """
        r"ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "
        r"LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY",
        "BSD",
        lambda *_a: "BSD-like-Entessa",
    ),
    ReLicense(
        r"Redistribution and use in source and binary forms, "
        r"with or without modification, are permitted provided "
        r"that the following conditions are met:? "
        r".{,4}Redistributions of source code must retain "
        r"the above copyright notice, this list of conditions,? "
        r"and the following disclaimer\. "
        r".{,4}Redistributions in binary form must reproduce the "
        r"above copyright notice, this list of conditions, and the "
        r"disclaimer that follows these conditions in the documentation "
        r"and/or other materials provided with the distribution\. "
        r".{,4}The names? (?:[^ ]+ ){,8}must not be used to endorse or "
        r"promote products derived from this software without prior "
        r"written permission\. For written permission, please contact "
        r"(?:[^ ]+ ){,8}"
        r".{,4}Products derived from this software may not be called "
        r"(?:[^ ]+ ){,8}nor may (?:[^ ]+ ){,8}appear in their name, "
        r"without prior written permission from the (?:[^ ]+ ){,8}"
        r"In addition, we request \(but do not require\) that you include "
        r"in the end-user documentation provided with the "
        r"redistribution and/or in the software itself an "
        r"acknowledgement equivalent to the following:? "
        r'"?This product includes software developed by the (?:[^ ]+ ){,8}'
        r"Alternatively, the acknowledgment may be graphical using the "
        r"logos available at (?:[^ ]+ ){,8}"
        r"""THIS SOFTWARE IS PROVIDED (?:``|''|")?AS IS(?:''|")? AND """
        r"ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "
        r"LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY",
        "BSD",
        lambda *_a: "BSD-like-Saxpath",
    ),
    ReLicense(
        r"Eclipse Public License - v ([\d.]+) "
        r"THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF "
        r'THIS ECLIPSE PUBLIC LICENSE \([" ]AGREEMENT[" ]\)\. ANY USE, '
        r"REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES "
        r"RECIPIENT[\' ]S ACCEPTANCE OF THIS AGREEMENT\.",
        "EPL",
        group_version,
    ),
    ReLicense(
        r"published under the EPL ([\d.]+), "
        r"see COPYING\.TESTDATA for the full license",
        "EPL",
        group_version,
    ),
    ReLicense(r"Licensed under the EUPL V.([\d.]+)", "EUPL", group_version),
    # EUPL by title-and-version - v1.2 dropped the version from the appendix
    # "Licensed under the EUPL" notice, so match the licence header instead,
    # paired with the substantive "applies to the Work" clause to reject a bare
    # reference. Covers v1.0/v1.1/v1.2 alike (version read from the title).
    ReLicense(
        r"European Union Public Licence v\.? ?([\d.]+).{0,120}This European "
        r"Union Public Licence \( ?the EUPL ?\) applies to the Work",
        "EUPL",
        group_version,
    ),
    ReLicense(
        r"Usage of the works is permitted provided that "
        r"this instrument is retained with the works, so "
        r"that any entity that uses the works is notified "
        r"of this instrument\. "
        r"DISCLAIMER:? THE WORKS ARE WITHOUT WARRANTY\.",
        "Fair",
    ),
    ReLicense(
        r"This file contains software that has been made "
        r"available under The Frameworx Open License 1.0. "
        r"Use and distribution hereof are subject to the "
        r"restrictions set forth therein\.",
        "Frameworx",
        lambda *_a: "Frameworx-1",
    ),
    ReLicense(
        r"The contents of this file are subject to the "
        r'FreeImage Public License Version 1.0 \(the "?License[" ]?\);? '
        r"you may not use this file except in compliance "
        r"with the License\.",
        "FreeImage",
        lambda *_a: "FreeImage-1",
    ),
    ReLicense(
        r"This file (?:is part of the FreeType project, and )?may only be used,? "
        r"modified,? and distributed under the terms of the FreeType project "
        r"license, LICENSE.TXT. By continuing to use, modify, or distribute "
        r"this file you indicate that you have read the license and "
        r"understand and accept it fully.",
        "FTL",
    ),
    ReLicense(
        r"This license applies to all files distributed in the original "
        r"FreeType Project, including all source code, binaries and "
        r"documentation, unless otherwise stated in the file in its "
        r"original, unmodified form as distributed in the original archive. "
        r"If you are unsure whether or not a particular file is covered by "
        r"this license, you must contact us to verify this.",
        "FTL",
    ),
    ReLicense(
        r"In lieu of a licence Fonts in this site are offered free for any "
        r"use; they may be installed, embedded, opened, edited, modified, "
        r"regenerated, posted, packaged and redistributed.",
        "fonts-ancient-scripts_license",
    ),
    ReLicense(
        r"is gift-ware. It was created by a number of people "
        r"working in cooperation, and is given to you freely "
        r"as a gift. You may use, modify, redistribute, and "
        r"generally hack it about in any way you like, and "
        r"you do not have to give us anything in return.",
        "Giftware",
    ),
    ReLicense(
        r"Permission to use, copy, and distribute this "
        r"software and its documentation for any purpose "
        r"with or without fee is hereby granted, provided "
        r"that the copyright notice appear in all copies "
        r"and that both that copyright notice and this "
        r"permission notice appear in supporting documentation. "
        r"Permission to modify and distribute modified versions "
        r"of this software is granted, provided that:? "
        r".{,4}the modifications are licensed under the "
        r"same terms as this software;? "
        r".{,4}you make available the source code of any "
        r"modifications that you distribute, either on "
        r"the same media as you distribute any executable "
        r"or other form of this software, or via a mechanism "
        r"generally accepted in the software development "
        r"community for the electronic transfer of data.",
        "GL2PS",
    ),
    ReLicense(
        r"THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION "
        r"AND IS OFFERED ONLY PURSUANT TO THE 3DFX GLIDE "
        r"GENERAL PUBLIC LICENSE. THERE IS NO RIGHT TO "
        r"USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN "
        r"PERMISSION OF 3DFX INTERACTIVE, INC. A COPY OF "
        r"THIS LICENSE MAY BE OBTAINED FROM THE DISTRIBUTOR "
        r"OR BY CONTACTING 3DFX INTERACTIVE INC \(info@3dfx.com\). "
        r'THIS PROGRAM. IS PROVIDED "?AS IS"? WITHOUT WARRANTY '
        r"OF ANY KIND, EITHER EXPRESSED OR IMPLIED. SEE THE "
        r"3DFX GLIDE GENERAL PUBLIC LICENSE FOR A FULL "
        r"TEXT OF THE NON-WARRANTY PROVISIONS.",
        "Glide",
    ),
    ReLicense(
        r"You may copy and distribute it freely, by any "
        r"means and under any conditions, as long as the "
        r"code and documentation is not changed. You may "
        r"also incorporate this code into your own program "
        r"and distribute that, or modify this code and "
        r"use and distribute the modified version, as long "
        r"as you retain a notice in your program or documentation "
        r"which mentions my name and the URL shown above.",
        "Glulxe",
    ),
    ReLicense(
        r"Permission to use, copy, and distribute this software "
        r"and its documentation for any purpose with or "
        r"without fee is hereby granted, provided that "
        r"the above copyright notice appear in all copies "
        r"and that both that copyright notice and this "
        r"permission notice appear in supporting documentation. "
        r"Permission to modify the software is granted, "
        r"but not the right to distribute the complete "
        r"modified source code. Modifications are to be "
        r"distributed as patches to the released version. "
        r"Permission to distribute binaries produced by "
        r"compiling modified sources is granted, provided you ",
        "gnuplot",
    ),
    ReLicense(
        r"The contents of this file are subject to the "
        r"gSOAP Public License Version 1.3 \(the "
        r'"?License[" ]?\);? you may not use this file '
        r"except in compliance with the License.",
        "gSOAP",
        lambda *_a: "gSOAP-1.3",
    ),
    ReLicense(
        r"The authors intend this Report to belong to the "
        r"entire Haskell community, and so we grant permission "
        r"to copy and distribute it for any purpose, provided "
        r"that it is reproduced in its entirety, including "
        r"this Notice. Modified versions of this Report may "
        r"also be copied and distributed for any purpose, "
        r"provided that the modified version is clearly "
        r"presented as such, and that it does not claim "
        r"to be a definition of the Haskell 2010 Language.",
        "HaskellReport",
    ),
    ReLicense(
        r"This source code has been made available to you by IBM on an "
        r"AS-IS basis. Anyone receiving this source is licensed under "
        r"IBM copyrights to use it in any way he or she deems fit, "
        r"including copying it, modifying it, compiling it, and "
        r"redistributing it either with or without modifications. "
        r"No license under IBM patents or patent applications is to be "
        r"implied by the copyright license. "
        r"Any user of this software should understand that IBM cannot "
        r"provide technical support for this software and will not be "
        r"responsible for any consequences resulting from the use of "
        r"this software. "
        r"Any person who transfers this source code or any derivative "
        r"work must include the IBM copyright notice, this paragraph, "
        r"and the preceding two paragraphs in the transferred software.",
        "IBM-pibs",
    ),
    # IJG family - the shared README/no-warranty permission clause; ijg_detail
    # returns "IJG" for the full licence (carries the "derived from or based on
    # the IJG code" condition) and "IJG-short" for the brief form.
    ReLicense(
        r"then this README file must be included, with this copyright and "
        r"no-warranty notice unaltered",
        "IJG",
        ijg_detail,
    ),
    ReLicense(
        r'Licensed under the ImageMagick License \(the[" ]*License[" ]?\)'
        r";? you may not use this file except in compliance with the "
        r"License. You may obtain a copy of the License at "
        r"https?[: ]/?/?www.imagemagick.org/script/license.php "
        r"Unless required by applicable law or agreed to in writing, "
        r"software distributed under the License is distributed on an "
        r"""(?:``|''|")?AS IS(?:''|")? BASIS, WITHOUT WARRANTIES OR """
        r"CONDITIONS OF ANY KIND, either express or implied. See the "
        r"License for the specific language governing permissions and "
        r"limitations under the License.",
        "ImageMagick",
    ),
    ReLicense(
        r"This license agreement covers your use of the iMatix "
        r"STANDARD FUNCTION LIBRARY \(SFL\), its source code, "
        r"documentation, and executable files, hereinafter referred "
        r'to as[" ]*the Product[" ]?.',
        "iMatix",
    ),
    ReLicense(
        r'This software is provided[" ]*as is,[" ]*without warranty of any '
        r"kind, express or implied. In no event shall Info-ZIP or its "
        r"contributors be held liable for any direct, indirect, "
        r"incidental, special or consequential damages arising out of "
        r"the use of or inability to use this software.",
        "Info-ZIP",
    ),
    ReLicense(
        r"ACPI - Software License Agreement "
        r"Software License Agreement IMPORTANT - READ BEFORE COPYING, "
        r"INSTALLING OR USING\. "
        r"Do not use or load this software and any associated materials "
        r'\(collectively, the [" ]?Software[" ]?\) until you have carefully '
        r"read the following terms and conditions\. By loading or using "
        r"the Software, you agree to the terms of this Agreement. If you "
        r"do not wish to so agree, do not install or use the Software\. "
        r"1\. COPYRIGHT NOTICE Some or all of this work - Copyright "
        r"[© ]*[0-9, -]* Intel Corp\. All rights reserved\. "
        r"2\. LICENSE "
        r"2\.1\. This is your license from Intel Corp\. under its "
        r"intellectual property rights\. You may have additional license "
        r"terms from the party that provided you this software, covering "
        r"your right to use that party\'s intellectual property rights\. "
        r"2\.2\. Intel grants, free of charge, to any person "
        r'\([" ]?Licensee[" ]?\) obtaining a copy of the source code '
        r'appearing in this file \([" ]?Covered Code[" ]?\) an '
        r"irrevocable, perpetual, worldwide license under Intel\'s "
        r"copyrights in the base code distributed originally by Intel "
        r'\([" ]?Original Intel Code[" ]?\) to copy, make derivatives, '
        r"distribute, use and display any portion of the Covered Code in "
        r"any form, with the right to sublicense such rights;? and "
        r"2\.3\. Intel grants Licensee a non-exclusive and "
        r"non-transferable patent license \(with the right to "
        r"sublicense\), under only those claims of Intel patents that "
        r"are infringed by the Original Intel Code, to make, use, sell, "
        r"offer to sell, and import the Covered Code and derivative "
        r"works thereof solely to the minimum extent necessary to "
        r"exercise the above copyright license, and in no event shall "
        r"the patent license extend to any additions to or modifications "
        r"of the Original Intel Code\. No other license or right is "
        r"granted directly or by implication, estoppel or otherwise;? ",
        "Intel-ACPI",
    ),
    ReLicense(
        r"IPA Font License Agreement (?:v ?|version ?)?([\d.]+) "
        r"The Licensor provides the Licensed Program \(as defined in "
        r"Article 1 below\) under the terms of this license agreement "
        r'\([" ]?Agreement[" ]\)\. Any use, reproduction or distribution '
        r"of the Licensed Program, or any exercise of rights under this "
        r"Agreement by a Recipient \(as defined in Article 1 below\) "
        r"constitutes the Recipient\'s acceptance of this Agreement\.",
        "IPA",
        group_version,
    ),
    ReLicense(
        r"IBM Public License Version ([\d.]+) "
        r"THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS "
        r'IBM PUBLIC LICENSE \([" ]?AGREEMENT[" ]?\)\. ANY USE, REPRODUCTION OR '
        r"DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT\'S "
        r"ACCEPTANCE OF THIS AGREEMENT\.",
        "IPL",
        group_version,
    ),
    ReLicense(
        r"JasPer License Version ([\d.]+) "
        r"(?:[^\s]+ ){,80}"
        r"All rights reserved\. "
        r"Permission is hereby granted, free of charge, to any person "
        r'\(the "?User[" ]?\) obtaining a copy of this software and '
        r'associated documentation files \(the "?Software[" ]?\), to deal '
        r"in the Software without restriction, including without "
        r"limitation the rights to use, copy, modify, merge, publish, "
        r"distribute, and/or sell copies of the Software, and to permit "
        r"persons to whom the Software is furnished to do so, subject to "
        r"the following conditions",
        "JasPer",
        group_version,
    ),
    ReLicense(
        r"Licence Art Libre (?:\[? ?Copyleft Attitude ?\]? Version )?"
        r"([\d.]+) (?:\(LAL [\d.]+\) )?"
        r"Préambule :? ?"
        r"Avec (?:cette|la) Licence Art Libre, l[’ ]autorisation "  # noqa: RUF001
        r"est donnée de "
        r"copier, de diffuser et de transformer librement les "
        r"(?:oeuvres|œuvres) dans le respect des droits de l[‘ ]auteur\.",  # noqa: RUF001
        "LAL",
        group_version,
    ),
    ReLicense(
        r"Permission is granted to make and distribute verbatim copies "
        r"of this manual provided the copyright notice and this "
        r"permission notice are preserved on all copies\. "
        r"Permission is granted to copy and distribute modified versions "
        r"of this manual under the conditions for verbatim copying, "
        r"provided that the entire resulting derived work is distributed "
        r"under the terms of a permission notice identical to this one\. "
        r"Permission is granted to copy and distribute translations of "
        r"this manual into another language, under the above conditions "
        r"for modified versions\.",
        "Latex2e",
    ),
    ReLicense(
        r"This software is distributed in the hope that it will be "
        r"useful, but with NO WARRANTY OF ANY KIND\. "
        r"No author or distributor accepts responsibility to anyone for "
        r"the consequences of using this software, or for whether it "
        r"serves any particular purpose or works at all, unless he or "
        r"she says so in writing\. Everyone is granted permission to "
        r"copy, modify and redistribute this source code, for commercial "
        r"or non-commercial purposes, with the following restrictions:? "
        r"\(1\) the origin of this source code must not be "
        r"misrepresented;? "
        r"\(2\) modified versions must be plainly marked as such;? and "
        r"\(3\) this notice may not be removed or altered from any "
        r"source or modified source distribution\.",
        "Leptonica",
    ),
    ReLicense(
        r"Permission to use, copy, modify, distribute, and sell this "
        r"software and its documentation for any purpose is hereby "
        r"granted without fee, provided that \(i\) the above copyright "
        r"notices and this permission notice appear in all copies of "
        r"the software and related documentation, and \(ii\) the names? "
        r"of (?:[^\s]+ ){,80}may not be used in any advertising or "
        r"publicity relating to the software without the specific, prior "
        r"written permission of ",
        # In the MIT/X11 family so it dedups against the generic HPND "sell"
        # grant rules (which also match this notice).
        "MIT/X11",
        lambda *_a: "libtiff",
    ),
    ReLicense(
        r"Licence Libre du Québec [-–]? ?Permissive \(LiLiQ-P\) "  # noqa: RUF001
        r"Version ([\d.]+) "
        r"1\. Préambule ",
        "LiLiQ-P",
        group_version,
    ),
    ReLicense(
        r"Licence Libre du Québec [-–]? ?Réciprocité forte "  # noqa: RUF001
        r"\(LiLiQ-R\+\) "
        r"Version ([\d.]+) "
        r"1\. Préambule ",
        "LiLiQ-R+",
        group_version,
    ),
    ReLicense(
        r"Lucent Public License Version ([\d.]+) "
        r"THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS "
        r'PUBLIC LICENSE \([" ]?AGREEMENT[" ]?\)\. ANY USE, REPRODUCTION '
        r"OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT\'S "
        r"ACCEPTANCE OF THIS AGREEMENT\.",
        "LPL",
        group_version,
    ),
    ReLicense(
        r"Permission is hereby granted to make and distribute original "
        r"copies of this program provided that the copyright notice and "
        r"this permission notice are preserved and provided that the "
        r"recipient is not asked to waive or limit his right to "
        r"redistribute copies as allowed by this permission notice and "
        r"provided that anyone who receives an executable form of this "
        r"program is granted access to a machine-readable form of the "
        r"source code for this program at a cost not greater than "
        r"reasonable reproduction, shipping, and handling costs\. "
        r"Executable forms of this program distributed without the "
        r"source code must be accompanied by a conspicuous copy of this "
        r"permission notice and a statement that tells the recipient how "
        r"to obtain the source code\.",
        "MakeIndex",
    ),
    ReLicense(
        r"Provided that these terms and disclaimer and all copyright "
        r"notices are retained or reproduced in an accompanying "
        r"document, permission is granted to deal in this work without "
        r"restriction, including unlimited rights to use, publicly "
        r"perform, distribute, sell, modify, merge, give away, or "
        r"sublicence\. "
        r'This work is provided "?AS IS"? and WITHOUT WARRANTY of any '
        r"kind, to the utmost extent permitted by applicable law, "
        r"neither express nor implied;? without malicious intent or "
        r"gross negligence\. In no event may a licensor, author or "
        r"contributor be held liable for indirect, direct, other "
        r"damage, loss, or other issues arising in any way out of "
        r"dealing in the work, even if advised of the possibility of "
        r"such damage or existence of a defect, except proven that it "
        r"results out of said person\'s immediate fault when using the "
        r"work as intended\.",
        "MirOS",
    ),
    # This license seems to be only present in license checkers.. :/
    ReLicense(
        r"MOTOSOTO OPEN SOURCE LICENSE -? ?Version [\d.]+ "
        r'This Motosoto Open Source License \(the "?License[" ]?\) '
        r'applies to "?Community Portal Server"? and related software '
        r"products as well as any updatesor maintenance releases of "
        r'that software \([" ]?Motosoto Products[" ]?\) that are '
        r'distributed by Motosoto\.Com B\.V\. \([" ]?Licensor[" ]\)\. '
        r"Any Motosoto Product licensed pursuant to this License is a "
        r'"?Licensed Product\."? Licensed Product, in its entirety, is '
        r"protected by Dutch copyright law\. This License identifies "
        r"the terms under which you may use, copy, distribute or modify "
        r"Licensed Product and has been submitted to the Open Software "
        r"Initiative \(OSI\) for approval\.",
        "Motosoto",
    ),
    ReLicense(
        r"Permission is hereby granted to use, reproduce, prepare "
        r"derivative works, and to redistribute to others\. "
        r"This software was authored by:? ",
        "mpich",
    ),
    ReLicense(r"Microsoft (?:Permissive|Public) License \(Ms-PL\)", "MS-PL"),
    ReLicense(
        r"Microsoft Reciprocal License \(Ms-RL\) "
        r"This license governs use of the accompanying software. If you "
        r"use the software, you accept this license\. If you do not "
        r"accept the license, do not use the software\.",
        "MS-RL",
    ),
    ReLicense(
        r"This file is part of the Matrix Template Library "
        r"Dresden University of Technology -?-? ?short TUD -?-? ?and "
        r"Indiana University -?-? ?short IU -?-? ?have the exclusive "
        r"rights to license this product under the following license\.",
        "MTLL",
    ),
    ReLicense(
        r"Permission to use, copy, modify, and distribute these "
        r"programs and their documentation for any purpose and without "
        r"fee is hereby granted, ?provided that the below copyright "
        r"notice and historical background appear in all copies and "
        r"that both the copyright notice and historical background "
        r"and this permission notice appear in supporting "
        r"documentation, and that the names of "
        r"(?:[^\s]+ ){,80}"
        r"not be used in advertising or publicity pertaining to "
        r"distribution of the programs without specific prior written "
        r"permission\.",
        "Multics",
    ),
    ReLicense(
        r"The licenses for most data are designed to take away your "
        r"freedom "
        r"to share and change it. By contrast, this License is intended "
        r"to "
        r"guarantee your freedom to share and change free data[- ]?-?to "
        r"make "
        r"sure the data are free for all their users\. "
        r"This License, the Lesser General Public License for Linguistic "
        r"Resources, applies to some specially designated linguistic "
        r"resources -?-? typically lexicons and grammars\.",
        "LGPL",
        lambda *_a: "LGPLLR",
    ),
    ReLicense(
        r"modify and distribute this stylesheet and its accompanying "
        r"documentation for any purpose and without fee is hereby "
        r"granted in perpetuity",
        "MIT/X11",
        lambda *_a: "MIT-like-Docbook-Stylesheet",
    ),
    # Sibling DocBook grants (the DTD has 4 words before "and its", past the
    # generic rule's window; the XML form's Expat grant has a doubled quote the
    # generic rule misses) - name them like the stylesheet form.
    ReLicense(
        r"XML DTD and its accompanying documentation for any purpose and "
        r"without fee is hereby granted in perpetuity",
        "MIT/X11",
        lambda *_a: "MIT-like-DocBook-DTD",
    ),
    ReLicense(
        r"Any stylesheet derived from this Software that is publically "
        r"distributed will be identified with a different name",
        "MIT/X11",
        lambda *_a: "MIT-like-DocBook-XML",
    ),
    ReLicense(
        r"Permission to use, copy, modify and distribute this "
        r"(?:[^ ]+ ){,3}(?:and its accompanying documentation )?"
        r"for any purpose and without fee is hereby granted"
        r"(?: in perpetuity)?, provided that the above copyright "
        r"notice and this (?:paragraph|permission notice) appear "
        r"in all copies\. The copyright holders make no "
        r"representation about the suitability of (?:[^ ]+ ){,5}"
        r'for any purpose\. It is provided "?as is"? without '
        r"expressed or implied warranty\.",
        "MIT/X11",
        lambda *_a: "MIT_OLIF",
    ),
    ReLicense(
        r"Subject to acceptance of the following conditions, permission "
        r"is hereby granted by Licensors without the need for written "
        r"agreement and without license or royalty fees, to use, copy, "
        r"modify and distribute this software for any purpose\. "
        r"The above copyright notice and the following four paragraphs "
        r"must be reproduced in all copies of this software and any "
        r"software including this software\.",
        "MIT/X11",
        lambda *_a: "MIT_versit",
    ),
    ReLicense(
        r"Permission is hereby granted, free of charge, to any "
        r"person obtaining a copy of this software and(?:\/or)? "
        r'associated documentation files \(the[" ]*'
        r'(?:Software|Materials)[" ]?\), to deal in the '
        r"(?:Software|Materials)",
        "MIT/X11",
    ),
    # The Python 2.0/2.0.1 collection embeds a CWI grant that matches the generic
    # MIT/X11 rule below; suppress the MIT/X11 family so the whole file is the
    # single Python id. The BeOpen heading appears only in the collection.
    ReLicense(
        r"BEOPEN PYTHON OPEN SOURCE LICENSE",
        "MIT/X11",
        lambda *_a: None,
    ),
    # HPND variants whose grant wording the generic rules below do not cover.
    ReLicense(
        r"hereby grants you permission to copy, modify, and distribute this "
        r"software and its documentation",
        "MIT/X11",
        lambda *_a: "MIT-like-HPND-Intel",
    ),
    ReLicense(
        r"this Python software and its associated documentation for any "
        r"purpose without fee is hereby granted",
        "MIT/X11",
        lambda *_a: "MIT-like-HPND-SMC",
    ),
    ReLicense(
        r"WITHIN THAT CONSTRAINT, permission to copy, modify, and distribute "
        r"this software",
        "MIT/X11",
        lambda *_a: "MIT-like-HPND-export-US-acknowledgement",
    ),
    # Net-SNMP is an aggregate of several BSD-like parts; its Part 1 is the
    # CMU/UCD grant, which the HPND grant rules below would otherwise report as
    # MIT/X11. Suppress the MIT/X11 family here (return None) so the whole file
    # is reported as Net-SNMP (detected in the BSD family). Must precede those
    # grant rules.
    ReLicense(
        r"Part 1: CMU/?UCD copyright notice",
        "MIT/X11",
        lambda *_a: None,
    ),
    # Same HPND grant but with the fee stated *after* "is hereby granted"; routes
    # to parse_mit, which names the specific variant via MIT_SUBS.
    ReLicense(
        r"Permission to use, copy, modify,?(?: distribute,?)?(?: and "
        r"(?:distribute|sell))? (?:[^ ]+ ){,3}"
        r"(?:and its (?:associated |accompanying )?documentation )?"
        r"for any purpose is hereby granted without fee",
        "MIT/X11",
    ),
    ReLicense(
        # The comma before "and distribute" is optional (some variants omit it).
        r"Permission to use, copy, modify,? and distribute "
        r"(?:[^ ]+ ){,3}(?:and its (:?accompanying )?documentation )?"
        r"for any purpose and without fee is hereby granted",
        "MIT/X11",
    ),
    ReLicense(
        r"Permission is hereby granted, without written agreement "
        r"and without license or royalty fees, to use, copy, "
        r"modify, and distribute this software and its "
        r"documentation for any purpose",
        "MIT/X11",
    ),
    ReLicense(
        r"Permission is hereby granted, free of charge, to any member of "
        r'the KDE project \(the "?K Desktop Environment"? '
        r'https?[ :]/?/?www.kde.org\) obtaining a copy of this "?Konqi '
        r'SDK"? package and associated documentation files \(the '
        r'"?Package[ "]?\), to deal in the Package without restriction, '
        r"including without limitation the rights to use, copy, modify, "
        r"merge, publish, distribute, sublicense, and/or sell copies of "
        r"the Package, and to permit persons to whom the Software is "
        r"furnished to do so, subject to the following conditions:? "
        r"The above copyright notice and this permission notice shall be "
        r"included in all copies or substantial portions of the Package.",
        "MIT/X11",
        lambda *_a: "Expat-like-Carddecks",
    ),
    # as used in kf5, mmh
    ReLicense(
        r"Distributed under terms of the MIT license\.",
        "MIT/X11",
        lambda *_a: "Expat",
    ),
    ReLicense(
        r"Permission to use, copy, modify and distribute this software "
        r"and its documentation for any purpose and without fee is "
        r"hereby granted, provided that the above copyright notice "
        r"appears in all copies and that both that copyright notice "
        r"and this permission notice appear in supporting "
        r"documentation, and that the name of CMU and The Regents "
        r"of the University of California not be used in "
        r"advertising or publicity pertaining to distribution of "
        r"the software without specific written permission\.",
        "MIT/X11",
        lambda *_a: "MIT-CMU",
    ),
    ReLicense(
        r"By obtaining, using, and/or copying this software "
        r"and/or its associated documentation, you agree that "
        r"you have read, understood, and will comply with the "
        r"following terms and conditions:",
        "MIT/X11",
        lambda *_a: "MIT-CMU",
    ),
    ReLicense(
        r"Permission to use, copy, modify, distribute, and sell "
        r"this software and its documentation for any purpose is "
        r"hereby granted without fee, provided that the above "
        r"copyright notice appear in all copies and that both that "
        r"copyright notice and this permission notice appear in "
        r"supporting documentation",
        "MIT/X11",
    ),
    # as used by jquery
    ReLicense(
        r"Released under the MIT license "
        r"https?[ :]/?/?jquery.org[ /]license",
        "MIT/X11",
        lambda *_a: "Expat",
    ),
    ReLicense(
        r"Permission to use, copy, modify, and distribute this software "
        r"for any purpose without fee is hereby granted, provided that "
        r"this entire notice is included in all copies of any software "
        r"which is or includes a copy or modification of this software "
        r"and in all copies of the supporting documentation for such "
        r"software.",
        "MIT/X11",
        lambda *_a: "ISC-like-dtoa",
    ),
    ReLicense(
        r"NASA OPEN SOURCE AGREEMENT VERSION ([\d.]+) "
        r'THIS OPEN SOURCE AGREEMENT \([" ]?AGREEMENT[" ]?\) DEFINES '
        r"THE RIGHTS OF USE, REPRODUCTION, DISTRIBUTION, MODIFICATION "
        r"AND REDISTRIBUTION OF CERTAIN COMPUTER SOFTWARE ORIGINALLY "
        r"RELEASED BY THE UNITED STATES GOVERNMENT AS REPRESENTED BY "
        r'THE GOVERNMENT AGENCY LISTED BELOW \([" ]?GOVERNMENT '
        r'AGENCY[" ]?\)\. '
        r"THE UNITED STATES GOVERNMENT, AS REPRESENTED BY GOVERNMENT "
        r"AGENCY, IS AN INTENDED THIRD-PARTY BENEFICIARY OF ALL "
        r"SUBSEQUENT DISTRIBUTIONS OR REDISTRIBUTIONS OF THE SUBJECT "
        r"SOFTWARE. ANYONE WHO USES, REPRODUCES, DISTRIBUTES, MODIFIES "
        r"OR REDISTRIBUTES THE SUBJECT SOFTWARE, AS DEFINED HEREIN, "
        r"OR ANY PART THEREOF, IS, BY THAT ACTION, ACCEPTING IN FULL "
        r"THE RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN THIS "
        r"AGREEMENT\.",
        "NASA",
        group_version,
    ),
    # Not even present in others license scanners. :/
    ReLicense(
        r"NAUMEN Public License "
        r"This software is "
        r"(?:[^\s]+ ){,16}"
        r"All rights reserved. "
        r"Redistribution and use in source and binary forms, with or "
        r"without modification, are permitted provided that the "
        r"following conditions are met",
        "Naumen",
    ),
    # The BSD-3-clause and the Expat licenses had a baby license
    ReLicense(
        r"Permission is hereby granted, free of charge, to any person "
        r"obtaining a copy of this software and associated "
        r'documentation files \(the "?Software[" ]?\), to deal with '
        r"the Software without restriction, including without "
        r"limitation the rights to use, copy, modify, merge, publish, "
        r"distribute, sublicense, and/or sell copies of the Software, "
        r"and to permit persons to whom the Software is furnished to do "
        r"so, subject to the following conditions:? "
        r".{,4}Redistributions of source code must retain the above "
        r"copyright notice, this list of conditions and the following "
        r"disclaimers\. "
        r".{,4}Redistributions in binary form must reproduce the above "
        r"copyright notice, this list of conditions and the following "
        r"disclaimers in the documentation and/or other materials "
        r"provided with the distribution\. "
        r".{,4}Neither the names of "
        r"(?:[^\s]+ ){,16}"
        r"nor the names of its contributors may be used to endorse or "
        r"promote products derived from this Software without specific "
        r"prior written permission\. "
        r'THE SOFTWARE IS PROVIDED "?AS IS[" ]?, WITHOUT WARRANTY OF '
        r"ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE "
        r"WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR "
        r"PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE "
        r"CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, "
        r"DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, "
        r"TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH "
        r"THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE\.",
        "NCSA",
    ),
    ReLicense(
        r"Permission is granted to anyone to use this software for any "
        r"purpose on any computer system, and to redistribute it "
        r"freely, subject to the following restrictions:? "
        r".{,4}This software is distributed in the hope that it will be "
        r"useful, but WITHOUT ANY WARRANTY;? without even the implied "
        r"warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR "
        r"PURPOSE\. "
        r".{,4}Altered versions must be plainly marked as such, and must "
        r"not be misrepresented as being the original software\.",
        "Newsletr",
    ),
    # Based on the original Bison GPL
    ReLicense(
        r"Everyone is permitted to copy and distribute verbatim copies "
        r"of this license, but changing it is not allowed. You can also "
        r"use this wording to make the terms for other programs\. "
        r"The license agreements of most software companies keep you "
        r"at the mercy of those companies\. By contrast, our general "
        r"public license is intended to give everyone the right to "
        r"share NetHack\. To make sure that you get the rights we want "
        r"you to have, we need to make restrictions that forbid anyone "
        r"to deny you these rights or to ask you to surrender the "
        r"rights\. Hence this license agreement\.",
        "NGPL",
    ),
    ReLicense(
        r"This licence grants you the right to copy, use and "
        r"distribute information, provided you acknowledge the "
        r"contributors and comply with the terms and conditions "
        r"stipulated in this licence\. By using information made "
        r"available under this licence, you accept the terms and "
        r"conditions set forth in this licence\. As set out in Section "
        r"7, the licensor disclaims any and all liability for the "
        r"quality of the information and what the information is "
        r"used for\. "
        r"This licence shall not impose any limitations on the rights "
        r"or freedoms of the licensee under the Norwegian Freedom of "
        r"Information Act or any other legislation granting the general "
        r"public a right of access to public sector information, or "
        r"that follow from exemptions or limitations stipulated in "
        r"the Norwegian Copyright Act\. Further, the licence shall "
        r"not impose any limitations on the licensee\'s freedom of "
        r"expression recognized by law\.",
        "NLOD",
        lambda *_a: "NLOD-1",
    ),
    ReLicense(
        r"The contents of this file are subject to the NOKOS License "
        r'Version ([\d.]+) \(the "?License[" ]\);? you may not use this '
        r"file except in compliance with the License\. "
        r"Software distributed under the License is distributed on an "
        r'"?AS IS"? basis, WITHOUT WARRANTY OF ANY KIND, either express '
        r"or implied\. See the License for the specific language "
        r"governing rights and limitations under the License\.",
        # SPDX/OSI name for the NOKOS (Nokia Open Source) License.
        "Nokia",
        lambda *_a: "Nokia",
    ),
    ReLicense(
        r"The contents of this file are subject to the Netizen Open "
        r'Source License Version ([\d.]+) \(the "?License[" ]\);? '
        r"you may not use this file except in compliance with the "
        r"License\. You may obtain a copy of the License at "
        r"https?[: ]/?/?netizen.com.au/licenses/NOPL/? "
        r"Software distributed under the License is distributed on an "
        r'"?AS IS"? basis, WITHOUT WARRANTY OF ANY KIND, either express '
        r"or implied\. See the License for the specific language "
        r"governing rights and limitations under the License\.",
        "NOSL",
        group_version,
    ),
    ReLicense(
        r"Noweb is available free for any use in any field of endeavor\. "
        r"You may redistribute noweb in whole or in part provided you "
        r"acknowledge its source and include this COPYRIGHT file\. You "
        r"may modify noweb and create derived works, provided you retain "
        r"this copyright notice, but the result may not be called noweb "
        r"without my written consent\.",
        "Noweb",
    ),
    ReLicense(
        r"The contents of this file are subject to the Netscape Public "
        r'License Version ([\d.]+) \(the "?License[" ]\);? you may not '
        r"use this file except in compliance with the License\. You may "
        r"obtain a copy of the License at "
        r"https?[: ]/?/?www.mozilla.org/NPL/? "
        r"Software distributed under the License is distributed on an "
        r'"?AS IS"? basis, WITHOUT WARRANTY OF ANY KIND, either express '
        r"or implied\. See the License for the specific language "
        r"governing rights and limitations under the License\.",
        "MPL",
        partial(name_version, name="NPL"),
    ),
    ReLicense(
        r"Licensed under the Non-Profit Open Software License version "
        r"([\d.]+)",
        "NPOSL",
        group_version,
    ),
    ReLicense(
        r"NRL grants permission for redistribution and use in source "
        r"and binary forms, with or without modification, of the "
        r"software and documentation created at NRL provided that "
        r"the following conditions are met",
        "NRL",
    ),
    ReLicense(
        r"Permission to use, copy, modify, and distribute this software "
        r"and its documentation for any purpose with or without fee is "
        r"hereby granted, provided that the above copyright notice "
        r"appears in all copies and that both the copyright notice and "
        r"this permission notice appear in supporting documentation, "
        r"and that the name "
        r"(?:[^\s]+ ){,16}"
        r"not be used in advertising or publicity pertaining to "
        r"distribution of the software without specific, written prior "
        r"permission\. "
        r"(?:[^\s]+ ){,16}"
        r"makes no representations about the suitability this software "
        r'for any purpose\. It is provided "?as is"? without express or '
        r"implied warranty\.",
        "NTP",
    ),
    ReLicense(
        r"it may be copied and furnished to others, and derivative works "
        r"that comment on or otherwise explain it or assist in its "
        r"implementation may be prepared, copied, published, and "
        r"distributed, in whole or in part, without restriction of any "
        r"kind, provided that the above copyright notice and this section "
        r"are included on all such copies and derivative works. "
        r"However, this document itself may not be modified in any way, "
        r"including by removing the copyright notice or references to "
        r"OASIS, except as needed for the purpose of developing any "
        r"document or deliverable produced by an OASIS Technical "
        r"Committee \(in which case the rules applicable to copyrights, as "
        r"set forth in the OASIS IPR Policy, must be followed\) or as "
        r"required to translate it into languages other than English. "
        r"The limited permissions granted above are perpetual and will "
        r"not be revoked by OASIS or its successors or assigns.",
        "OASIS",
    ),
    ReLicense(
        r"The content of this file is subject to the Open CASCADE "
        r'Technology Public License \(the "?License[" ]\)\. You may not '
        r"use the content of this file except in compliance with the "
        r"License\. Please obtain a copy of the License at "
        r"opencascade\.com and read it completely before using this "
        r"file\.",
        "OCCT-PL",
    ),
    ReLicense(
        r"The contents of this file, as updated from time to time by the "
        r"OCLC Office of Research, are subject to OCLC Research Public "
        r'License Version ([\d.]+) \(the "?License[" ]\);? you may not '
        r"use this file except in compliance with the License\. You may "
        r"obtain a current copy of the License at "
        r"https?[: ]/?/?purl.oclc.org/oclc/research/ORPL/?\. Software "
        r'distributed under the License is distributed on an "?AS IS"? '
        r"basis, WITHOUT WARRANTY OF ANY KIND, either express or "
        r"implied\. See the License for the specific language governing "
        r"rights and limitations under the License\.",
        "OCLC",
        group_version,
    ),
    ReLicense(
        r"The Open Database License \(ODbL\) is a license agreement "
        r"intended to allow users to freely share, modify, and use this "
        r"Database while maintaining this same freedom for others\. Many "
        r"databases are covered by copyright, and therefore this "
        r"document licenses these rights\. Some jurisdictions, mainly in "
        r"the European Union, have specific rights that cover databases, "
        r"and so the ODbL addresses these rights, too\. Finally, the "
        r"ODbL is also an agreement in contract for users of this "
        r"Database to act in certain ways in return for accessing this "
        r"Database\.",
        "ODbL",
        lambda *_a: "ODbL-1",
    ),
    ReLicense(
        r"SIL OPEN FONT LICENSE "
        r"Version ([\d.]+) -? ?(?:[^\s]+ ){,8}"
        r"PREAMBLE "
        r"The goals of the Open Font License \(OFL\) are to stimulate "
        r"worldwide development of (?:cooperative|collaborative) font "
        r"projects, to support the font creation efforts of academic "
        r"and linguistic communities, and to provide "
        r"(?:a free and open|an open) framework in which fonts may be "
        r"shared and improved in partnership with others\. "
        r"The OFL allows the licensed fonts to be used, studied, "
        r"modified and redistributed freely as long as they are not "
        r"sold by themselves\. The fonts, including any derivative "
        r"works, can be bundled, embedded, redistributed and(?:/or)? "
        r"sold with any software provided that "
        r"(?:the font names of derivative works are changed|"
        r"any reserved names are not used by derivative works)\. The "
        r"fonts and derivatives, however, cannot be released under any "
        r"other type of license\.",
        "OFL",
        group_version,
    ),
    ReLicense(
        r"The OpenLDAP Public License "
        r"Version ([\d.]+),? "
        r"(?:[^\s]+ ){,32}"
        r"Redistribution and use of this software and associated "
        r'documentation \([" ]Software[" ]\), with or without '
        r"modification, are permitted provided that the following "
        r"conditions are met",
        "Apache",
        partial(name_version, name="OLDAP"),
    ),
    ReLicense(
        r"Redistribution and use of this software and associated "
        r'documentation \([" ]Software[" ]\), with or without '
        r"modification, are permitted provided that the following "
        r"conditions are met:? "
        r".{,4}Redistributions of source code must retain copyright "
        r"statements and notices\. Redistributions must also contain a "
        r"copy of this document\. "
        r".{,4}Redistributions in binary form must reproduce the above "
        r"copyright notice, this list of conditions and the following "
        r"disclaimer in the documentation and/or other materials "
        r"provided with the distribution\. "
        r".{,4}The names? (?:[^\s]+ ){,8}must not be used to endorse or "
        r"promote products derived from this Software without prior "
        r"written permission of (?:[^\s]+ ){,8}For written permission, "
        r"please contact (?:[^\s]+ ){,8}"
        r".{,4}Products derived from this Software may not be called "
        r"(?:[^\s]+ ){,8}nor may (?:[^\s]+ ){,8}appear in their names "
        r"without prior written permission of (?:[^\s]+ ){,8}"
        r"(?:[^\s]+ ){,8}is a registered trademark of "
        r"(?:[^\s]+ ){,8}"
        r".{,4}Due credit should be given to (?:[^\s]+ ){,8}"
        r"THIS SOFTWARE IS PROVIDED BY (?:[^\s]+ ){,8}AND CONTRIBUTORS "
        r"`?`?AS IS\'?\'? AND ANY EXPRESSED OR IMPLIED WARRANTIES, "
        r"INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF "
        r"MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE "
        r"DISCLAIMED. IN NO EVENT SHALL "
        r"(?:[^\s]+ ){,8}OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, "
        r"INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL "
        r"DAMAGES \(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF "
        r"SUBSTITUTE GOODS OR SERVICES;? LOSS OF USE, DATA, OR "
        r"PROFITS;? OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND ON "
        r"ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT "
        r"LIABILITY, OR TORT \(INCLUDING NEGLIGENCE OR OTHERWISE\) "
        r"ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF "
        r"ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\.",
        "Apache",
        lambda *_a: "Plexus",
    ),
    ReLicense(
        r"permits you to use, copy, modify, distribute, and license "
        r"this Software and the Documentation for any purpose, provided "
        r"that existing copyright notices are retained in all copies "
        r"and that this notice is included verbatim in any "
        r"distributions\. No written agreement, license, or royalty fee "
        r"is required for any of the authorized uses. Modifications to "
        r"this Software and Documentation may be copyrighted by their "
        r"authors and need not follow the licensing terms described "
        r"here\. If modifications to this Software and Documentation "
        r"have new licensing terms, the new terms must be clearly "
        r"indicated on the first page of each file where they apply\.",
        "OML",
    ),
    ReLicense(
        r"Redistribution and use in source and binary forms, with or without "
        r"modification, are permitted provided that the following conditions "
        r"are met:? "
        r"(?:[^\s]+ ){,2}"
        r"Redistributions of source code must retain the above copyright "
        r"notice, this list of conditions and the following disclaimer. "
        r"(?:[^\s]+ ){,2}"
        r"Redistributions in binary form must reproduce the above copyright "
        r"notice, this list of conditions and the following disclaimer in "
        r"the documentation and/or other materials provided with the "
        r"distribution. "
        r"(?:[^\s]+ ){,2}"
        r"All advertising materials mentioning features or use of this "
        r"software must display the following acknowledgment:? "
        r'"?This product includes software developed by the OpenSSL Project '
        r'for use in the OpenSSL Toolkit. \(https?[: ]/?/?www.openssl.org/\)"? '
        r"(?:[^\s]+ ){,2}"
        r'The names "?OpenSSL Toolkit"? and "?OpenSSL Project"? must not be used to '
        r"endorse or promote products derived from this software without "
        r"prior written permission. For written permission, please contact "
        r"(?:openssl-core|licensing)@openssl.org. "
        r"(?:[^\s]+ ){,2}"
        r'Products derived from this software may not be called "?OpenSSL"? '
        r'nor may "?OpenSSL"? appear in their names without prior written '
        r"permission of the OpenSSL Project. "
        r"(?:[^\s]+ ){,2}"
        r"Redistributions of any form whatsoever must retain the following "
        r"acknowledgment:? "
        r'"?This product includes software developed by the OpenSSL Project '
        r'for use in the OpenSSL Toolkit \(https?[: ]/?/?www.openssl.org/\)"?',
        "OpenSSL",
        # The combined OpenSSL licence also carries the full SSLeay grant (its
        # clause about Windows-specific code); the standalone OpenSSL form keeps
        # only the Eric Young / Tim Hudson acknowledgments, not that grant.
        lambda t, *_a: (
            "OpenSSL"
            if "If you include any Windows specific code" in t
            else "OpenSSL-standalone"
        ),
    ),
    ReLicense(r"The module is,?(?: [^ ]+){,5} licensed under OpenSSL", "OpenSSL"),
    ReLicense(
        r"This submission to OpenSSL is to be made available under the "
        r"OpenSSL license, and only to the OpenSSL project, in order to "
        r"allow integration into the publicly distributed code. "
        r"The use of this code, or portions of this code, or concepts "
        r"embedded in this code, or modification of this code and/or "
        r"algorithm\(s\) in it, or the use of this code for any other "
        r"purpose than stated above, requires special licensing.",
        "OpenSSL",
    ),
    ReLicense(
        r"Rights for redistribution and usage in source and binary forms "
        r"are granted according to the OpenSSL license.",
        "OpenSSL",
    ),
    ReLicense(
        r"OPEN PUBLIC LICENSE "
        r"Version ([\d.]+) "
        r"[^\s]+ Definitions",
        "OPL",
        group_version,
    ),
    ReLicense(
        r"This Source Code Form is subject to the terms of the OSET "
        r'Public License, v.([\d.]+) \([“" ]OSET-PL-[\d.]+[”" ]\)\. '
        r"If a copy of the OPL was not distributed with this file, You "
        r"can obtain one at:? www.OSETFoundation.org/public-license\.",
        "OSET-PL",
        group_version,
    ),
    ReLicense(
        r"Licensed under the Open Software License version ([\d.]+)",
        "OSL",
        group_version,
    ),
    ReLicense(
        r"The Open Data Commons -? ?Public Domain Dedication &? ?Licence "
        r"is a document intended to allow you to freely share, modify, "
        r"and use this work for any purpose and without any "
        r"restrictions\. This licence is intended for use on databases "
        r'or their contents \([" ]data[" ]\), either together or '
        r"individually\.",
        "PDDL",
        lambda *_a: "PDDL-1",
    ),
    ReLicense(
        r"is free (?:software|documentation); the (Free "
        r"Software Foundation|author[\( ]?s?\)?|copyright holders?) gives "
        r"unlimited permission to copy, "
        r"distribute and modify it\.",
        "Permissive",
        lambda *_a: "FSFUL",
    ),
    ReLicense(
        r"is free (?:software|documentation); the (Free "
        r"Software Foundation|author[\( ]?s?\)?|copyright holders?) gives "
        r"unlimited permission to copy "
        r"and(?:/or)? distribute it, with or without modifications, "
        r"as long as this notice is preserved\.",
        "Permissive",
        lambda *_a: "FSFULLR",
    ),
    # Functional Source License 1.1 (converts to its "future licence" after a
    # change date); the future-licence terms also match the Apache/MIT matchers,
    # so the result is a disjunction with the future licence.
    ReLicense(
        r"Functional Source License, Version 1\.1, ALv2",
        "FSL",
        lambda *_a: "FSL-1.1-ALv2",
    ),
    ReLicense(
        r"Functional Source License, Version 1\.1, MIT",
        "FSL",
        lambda *_a: "FSL-1.1-MIT",
    ),
    # FSFAP with the warranty disclaimer; the no-disclaimer variant (which ends
    # at "...are preserved.") falls through to the rule below it.
    ReLicense(
        r"Copying and distribution of this [^ ]+, with or without "
        r"modification, are permitted in any medium without royalty "
        r"provided the copyright notice and this notice are "
        r"preserved\. This file is offered as-is, without any warranty\.",
        "Permissive",
        lambda *_a: "FSFAP",
    ),
    ReLicense(
        r"Copying and distribution of this [^ ]+, with or without "
        r"modification, are permitted in any medium without royalty "
        r"provided the copyright notice and this notice are "
        r"preserved\.",
        "Permissive",
        lambda *_a: "FSFAP-no-warranty-disclaimer",
    ),
    ReLicense(
        r"Permission to use, copy, modify and distribute "
        r"this software and its documentation for any purpose "
        r"and without fee is hereby granted, provided that "
        r"the above copyright notice appear in all copies ?,? "
        r"(?:and )?that both (?:that )?(?:the )?copyright notice "
        r"and this permission notice appear in supporting "
        r"documentation(?: ?,? and that the name (?:of )?"
        r"(?:[^ ]+ ){,4}(?:or (?:[^ ]+ ){,8})?not be used in "
        r"advertising or publicity pertaining to distribution "
        r"of the software without specific, written prior "
        r"permission ?)?\.",
        "Permissive",
        lambda *_a: "HPND",
    ),
    ReLicense(
        r"NO LIMIT PUBLIC LICENSE "
        r"Terms and conditions for copying, distribution, modification "
        r"or anything else\. "
        r".{,4}No limit to do anything with this work and this license\.",
        "Permissive",
        lambda *_a: "NLPL",
    ),
    ReLicense(
        r"This (?:[^ ]+ ){,2}may be copied and used freely without "
        r"restrictions\.",
        "Permissive",
    ),
    ReLicense(
        r"Copying and distribution of this file, with or without modification, "
        r"is permitted in any medium without royalty provided the copyright "
        r"notice and this notice are preserved.",
        "Permissive",
    ),
    ReLicense(
        r"The PHP License, version ([\d.]+) "
        r"(?:[^\s]+ ){,16}"
        r"Redistribution and use in source and binary forms, with or "
        r"without modification, is permitted provided that the "
        r"following conditions are met",
        "PHP",
        group_version,
    ),
    ReLicense(
        r"This source file is subject to version ([^ ]+) of the "
        r"PHP license",
        "PHP",
        group_version,
    ),
    ReLicense(
        r"Permission to use, copy, modify, and distribute this software "
        r"and its documentation for any purpose, without fee, and "
        r"without a written agreement is hereby granted, provided that "
        r"the above copyright notice and this paragraph and the "
        r"following two paragraphs appear in all copies\. "
        r"IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO "
        r"ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR "
        r"CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF "
        r"THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "
        r"UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY "
        r"OF SUCH DAMAGE\. "
        r"THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY "
        r"WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED "
        r"WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR "
        r'PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "?AS IS"? '
        r"BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS "
        r"TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR "
        r"MODIFICATIONS\.",
        "PostgreSQL",
    ),
    ReLicense(
        r"This system is distributed in the hope that it will be "
        r"useful, but WITHOUT ANY WARRANTY;? without even the implied "
        r"warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR "
        r"PURPOSE\. Don\'t come complaining to us if you modify this "
        r"file and it doesn\'t work[!.]? If this file is modified by anyone "
        r"but the authors, those changes and their authors must be "
        r"explicitly stated HERE\.",
        "psfrag",
    ),
    ReLicense(
        r"They may be copied and used for any purpose \(including "
        r"distribution as part of a for-profit product\), provided:? "
        r".{,4}The original attribution of the programs is clearly "
        r"displayed in the product and/or documentation, even if the "
        r"programs are modified and/or renamed as part of the product\. "
        r".{,4}The original source code of the programs is provided free "
        r"of charge \(except for reasonable distribution costs\). For a "
        r"definition of reasonable distribution costs, see the Gnu "
        r"General Public License or Larry Wall\'s Artistic License "
        r"\(provided with the Perl 4 kit\)\. The GPL and Artistic "
        r"License in NO WAY affect this license;? they are merely used "
        r"as examples of the spirit in which it is intended\. "
        r'.{,4}These programs are provided "?as-is[" ]\. No warranty or '
        r"guarantee of their fitness for any particular task is "
        r"provided\. Use of these programs is completely at your own "
        r"risk\. "
        r"Basically, I don\'t mind how you use the programs so long as "
        r"you acknowledge the author, and give people the originals if "
        r"they want them\.",
        "psutils",
    ),
    ReLicense(
        r"This software includes Qhull from The Geometry Center\. Qhull "
        r"is copyrighted as noted above.\ Qhull is free software and may "
        r"be obtained via http from www\.qhull\.org\. It may be freely "
        r"copied, modified, and redistributed under the following "
        r"conditions",
        "Qhull",
    ),
    ReLicense(
        r"You may copy this prolog in any way that is directly "
        r"related to this document. For other use of this prolog, "
        r"see your licensing agreement for Qt.",
        "QT_Prolog",
    ),
    ReLicense(
        r"Rdisc \(this program\) was developed by Sun Microsystems, "
        r"Inc\. and is provided for unrestricted use provided that this "
        r"legend is included on all tape media and as a part of the "
        r"software program in whole or part. Users may copy or modify "
        r"Rdisc without charge, and they may freely distribute it\.",
        "Rdisc",
    ),
    ReLicense(
        r"The contents of this file are subject to the Red Hat eCos "
        r"Public License Version ([\d.]+)",
        "RHeCos",
        group_version,
    ),
    ReLicense(
        r"Part of the software embedded in this product is eCos -? ?"
        r"Embedded Configurable Operating System, a trademark of "
        r"Red Hat\.",
        "RHeCos",
    ),
    ReLicense(
        r"Unless explicitly acquired and licensed from Licensor under "
        r'(?:the Technical Pursuit License \([" ]TPL[" ]\) Version [\d.]+ '
        r"or greater|another license), the contents of this file are "
        r"subject to the "
        r'Reciprocal Public License \([" ]RPL[" ]\) Version ([\d.]+), '
        r"or subsequent versions as allowed by the RPL, and You may "
        r"not copy or use this file in either source code or executable "
        r"form, except in compliance with the terms and conditions of "
        r"the RPL\.",
        "RPL",
        group_version,
    ),
    ReLicense(
        r"The contents of this file, and the files included with this "
        r"file, are subject to the current version of the RealNetworks "
        r'Public Source License Version ([\d.]+) \(the "?RPSL[" ]\) ',
        "RPSL",
        group_version,
    ),
    ReLicense(
        r"License to copy and use this software is granted provided "
        r'that it is identified as the "?RSA Data Security, Inc\. '
        r'([^\s]+ ){,8}Message-Digest Algorithm"? in all material '
        r"mentioning or referencing this software or this function\.",
        "RSA-MD",
    ),
    ReLicense(
        r"The contents of this file are subject to the Ricoh Source Code "
        r'Public License Version ([\d.]+) \(the "?License[" ]\);? you '
        r"may not use this file except in compliance with the License\. "
        r"You may obtain a copy of the License at "
        r"https?[: ]/?/?www.risource.org/RPL",
        "RSCPL",
        group_version,
    ),
    ReLicense(
        r"Licensed under the SCEA Shared Source License, Version "
        r'([\d.]+) \(the "?License[" ]\);? you may not use this file '
        r"except in compliance with the License\. You may obtain a copy "
        r"of the License at:? "
        r"https?[: ]/?/?research.scea.com/scea_shared_source_license.html",
        "SCEA",
        group_version,
    ),
    ReLicense(
        r"Except to the extent portions of this file are made subject to "
        r"an alternative license as permitted in the SGI Free Software "
        r'License B, Version ([\d.]+) \(the "?License[" ]\), the '
        r"contents of this file are subject only to the provisions of "
        r"the License\. You may not use this file except in compliance "
        r"with the License\.",
        "SGI-B",
        group_version,
    ),
    ReLicense(r"under the SGI Free Software License B", "SGI-B"),
    ReLicense(
        r"This Simple Public License ([\d.]+) \(SimPL [\d.]+ for short\) "
        r"is a plain language implementation of GPL [\d.]+. The words "
        r"are different, but the goal is the same -? ?to guarantee for "
        r"all users the freedom to share and change software\. If "
        r"anyone wonders about the meaning of the SimPL, they should "
        r"interpret it as consistent with GPL [\d.]+\.",
        "SimPL",
        group_version,
    ),
    ReLicense(
        r"The contents of this file are subject to the Sun (?:Industry )?"
        r"Standards (?:Source )?License Version ([\d.]+) "
        r'\(the "?License[" ]?\)[;.]? '
        r"You may not use this file except in compliance with the "
        r"License\.",
        "SISSL",
        group_version,
    ),
    # Also matching SFL
    ReLicense(
        r"The United States Government/Department of Defense/National "
        r"Security Agency/Office of Network Security "
        r'(?:\(collectively "?the U.S. Government[" ]\) )?'
        r"hereby grants permission "
        r"(?:to any person obtaining a copy"
        r"|for the copying and distribution of copies) "
        r"of the (?:[^ ]+ ){,4}source and object files"
        r'(?:,| \(the "?(?:[^ ]+ ){,4}Software[" ]\)) '
        r"and "
        r'(?:associated documentation files \(the "?'
        r'(?:[^ ]+ ){,4}Documentation[" ]\), or'
        r"|that of) "
        r"any (?:portions|part) thereof, "
        r"(?:to do the following, )?subject to the following "
        r"license conditions:? "
        r".{,4}You may, (?:free of charge and )?without additional "
        r"permission "
        r"from the U\.S\. Government, "
        r"(?:use, copy, modify, sublicense and "
        r"otherwise )?distribute the (?:[^ ]+ ){,4}Software or "
        r"components of the (?:[^ ]+ ){,4}"
        r"Software, with or without (?:modifications|additions) "
        r"developed by you "
        r"(?:and/)?or by others(?: at no charge)?\. "
        r".{,4}You may, (?:free of charge )?and without additional "
        r"permission "
        r"from the U\.S\. Government, distribute copies of the "
        r"(?:[^ ]+ ){,4}"
        r"Documentation, with or without (?:modifications|additions) "
        r"developed by "
        r"you (?:and/)?or by others,? at no charge or at a charge that "
        r"covers "
        r"the cost of reproducing (?:such|the) copies, provided that this "
        r"(?:[^ ]+ ){,4}"
        r"Public License is retained\. "
        r".{,4}Furthermore, if you distribute the "
        r"(?:[^ ]+ ){,4}"
        r"Software or parts of "
        r"the SMP Software, with or without (?:modifications|additions) "
        r"developed by "
        r"you (?:and/)?or others, then you must either make available the "
        r"source (?:code )?to all portions of the "
        r"(?:[^ ]+ ){,4}Software \(exclusive "
        r"of any (?:modifications|additions) made by you (?:and/)?or "
        r"by others\) upon "
        r"request, or instead you may notify anyone requesting "
        r"(?:the SMP Software )?source (?:code )?that it is freely "
        r"available from "
        r"the U\.S\. Government\. "
        r".{,4}(?:You may not omit )?Transmission of this "
        r"(?:[^ ]+ ){,4}License "
        r"(?:must accompany|agreement with) "
        r"whatever portions of the (?:[^ ]+ ){,4}Software "
        r"(?:you redistribute|that are distributed)\. "
        r".{,4}(?:The (?:[^ ]+ ){,4}Software|Any users of this software "
        r"must be notified that it) "
        r"is (?:provided )?without warrant(?:y|ee) or guarantee "
        r"of any nature, express or implied, "
        r"(?:including without limitation "
        r"the warranties of merchantability and|nor is there any) "
        r"fitness for (?:a particular purpose|use represented)\. "
        r".{,4}The U\.S\. Government cannot be held liable for any damages "
        r"either directly or indirectly caused by the use of the "
        r"(?:[^ ]+ ){,4}"
        r"Software\. "
        r".{,4}It is not permitted to copy, sublicense, distribute or "
        r"transfer any of the (?:[^ ]+ ){,4}Software except as expressly "
        r"indicated herein\. Any attempts to do otherwise will be "
        r"considered a violation of this License and your rights to the "
        r"(?:[^ ]+ ){,4}will be voided\. ",
        "SMPPL",
    ),
    ReLicense(
        r"The contents of this file are subject to the SNIA Public "
        r'License Version ([\d.]+) \(the "?License[" ]\);? you may not '
        r"use this file except in compliance with the License\. You "
        r"may obtain a copy of the License at:? ",
        "SNIA",
        group_version,
    ),
    ReLicense(
        r"Permission is granted to anyone to use this software for any "
        r"purpose on any computer system, and to(?: alter it and)? "
        r"redistribute it(?: freely)?, subject to the following "
        r"restrictions:? "
        r".{,4}The author is not responsible for the consequences of "
        r"use of this software, no matter how awful, even if they arise "
        r"from (?:defects|flaws) in it\. "
        r".{,4}The origin of this software must not be misrepresented, "
        r"either by explicit claim or by omission\. "
        r"(Since few users ever read sources, credits must appear in "
        r"the documentation\. )?"
        r".{,4}Altered versions must be plainly marked as such, and must "
        r"not be misrepresented as being the original software\. "
        r"(?:Since few users ever read sources, credits must appear in "
        r"the documentation\. )?"
        r".{,4}(?:This notice may not be removed or altered\. )?",
        "Spencer",
        lambda _t, m, li: "{}-{}".format(li, "94" if m.group(1) else "86"),
    ),
    ReLicense(
        r"The contents of this file are subject to the Sun Public "
        r'License Version ([\d.]+) \(the "?License[" ]?\);? you may not use '
        r"this file except in compliance with the License\. ",
        "SPL",
        group_version,
    ),
    ReLicense(
        r"The contents of this file are subject to the SugarCRM Public "
        r'License Version ([\d.]+) \((?:the )?[" ]?License[" ]?\);? '
        r"You may not use this file except in compliance with the "
        r"License\. ",
        "SugarCRM",
        group_version,
    ),
    ReLicense(
        r"Sun RPC is a product of Sun Microsystems, Inc\. and is provided "
        r"for unrestricted use provided that this legend is included on all "
        r"tape media and as a part of the software program in whole or "
        r"part\. Users may copy or modify Sun RPC without charge, but are "
        r"not authorized to license or distribute it to anyone else except "
        r"as part of a product or program developed by the user or with the "
        r"express written consent of Sun Microsystems, Inc\. "
        r"SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING "
        r"THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A "
        r"PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR "
        r"TRADE PRACTICE\.",
        "Sun-RPC",
    ),
    ReLicense(
        r"The authors hereby grant permission to use, copy, modify, "
        r"distribute, and license this software and its documentation "
        r"for any purpose, provided that existing copyright notices "
        r"are retained in all copies and that this notice is included "
        r"verbatim in any distributions. No written agreement, license, "
        r"or royalty fee is required for any of the authorized uses\. "
        r"Modifications to this software may be copyrighted by their "
        r"authors and need not follow the licensing terms described "
        r"here, provided that the new terms are clearly indicated on "
        r"the first page of each file where they apply\. "
        r"IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO "
        r"ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR "
        r"CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, "
        r"ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE "
        r"AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. "
        r"THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY "
        r"WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED "
        r"WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR "
        r"PURPOSE, AND NON-INFRINGEMENT\. THIS SOFTWARE IS PROVIDED ON "
        r'AN "?AS IS"? BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE '
        r"NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, "
        r"ENHANCEMENTS, OR MODIFICATIONS\. "
        r"(?:[^ ]+ ){,256}"
        r"BY INSTALLING THIS SOFTWARE, YOU ACKNOWLEDGE THAT YOU HAVE "
        r"READ THIS AGREEMENT, THAT YOU UNDERSTAND IT, AND THAT YOU "
        r"AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS\.",
        "TCL",
        lambda *_a: "SWL",
    ),
    ReLicense(
        r"The authors hereby grant permission to use, copy, modify, "
        r"distribute, and license this software and its documentation "
        r"for any purpose, provided that existing copyright notices "
        r"are retained in all copies and that this notice is included "
        r"verbatim in any distributions. No written agreement, license, "
        r"or royalty fee is required for any of the authorized uses\. "
        r"Modifications to this software may be copyrighted by their "
        r"authors and need not follow the licensing terms described "
        r"here, provided that the new terms are clearly indicated on "
        r"the first page of each file where they apply\. "
        r"IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO "
        r"ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR "
        r"CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, "
        r"ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE "
        r"AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. "
        r"THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY "
        r"WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED "
        r"WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR "
        r"PURPOSE, AND NON-INFRINGEMENT\. THIS SOFTWARE IS PROVIDED ON "
        r'AN "?AS IS"? BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE '
        r"NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, "
        r"ENHANCEMENTS, OR MODIFICATIONS\. ",
        "TCL",
    ),
    ReLicense(
        r"TORQUE is a modification of OpenPBS which was developed by "
        r"NASA Ames Research Center, Lawrence Livermore National "
        r"Laboratory, and Veridian TORQUE Open Source License "
        r"v(?:ersion)? ?([\d.]+).? 1? ?Information Solutions, Inc\. ",
        "TORQUE",
        group_version,
    ),
    # https://lists.debian.org/debian-legal/2006/01/msg00566.html
    ReLicense(
        r"Unicode, Inc\. hereby grants the right to freely use the "
        r"information supplied in this file in the creation of products "
        r"supporting the Unicode Standard, and to make copies of this "
        r"file in any form for internal or external distribution as long "
        r"as this notice remains attached\.",
        "Unicode",
    ),
    ReLicense(
        r"Unicode Terms of Use "
        r"For the general privacy policy governing access to this site, "
        r"see the Unicode Privacy Policy. For trademark usage, see the "
        r"Unicode®? Consortium Name and Trademark Usage Policy\. ",
        "Unicode-TOU",
    ),
    ReLicense(
        r"This is free and unencumbered software released into the "
        r"public domain\. "
        r"Anyone is free to copy, modify, publish, use, compile, sell, "
        r"or distribute this software, either in source code form or as "
        r"a compiled binary, for any purpose, commercial or "
        r"non-commercial, and by any means\. ",
        "Unlicense",
    ),
    ReLicense(
        r"The above copyright notice and either this complete "
        r"permission notice or at a minimum a reference to the UPL must "
        r"be included in all copies or substantial portions of the "
        r"Software\. "
        r'THE SOFTWARE IS PROVIDED "?AS IS[" ]?, WITHOUT WARRANTY OF ANY '
        r"KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE "
        r"WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR "
        r"PURPOSE AND NONINFRINGEMENT\. IN NO EVENT SHALL THE AUTHORS OR "
        r"COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER "
        r"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR "
        r"OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE "
        r"SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE\.",
        "UPL",
        lambda *_a: "UPL-1",
    ),
    ReLicense(
        r"There are no restrictions on distributing unmodified copies "
        r"of Vim except that they must include this license text\. You "
        r"can also distribute unmodified parts of Vim, likewise "
        r"unrestricted except that they must include this license text\. "
        r"You are also allowed to include executables that you made from "
        r"the unmodified Vim sources, plus your own usage examples and "
        r"Vim scripts\.",
        "Vim",
    ),
    ReLicense(
        r"Under this license, this Distribution may be modified and "
        r"the original version and modified versions may be copied, "
        r"distributed, publicly displayed and performed provided that "
        r"the following conditions are met:? "
        r".{,4}Modified versions are distributed with source code and "
        r"documentation and with permission for others to use any code "
        r"and documentation \(whether in original or modified versions\) "
        r"as granted under this license[;.]? "
        r".{,4}if modified, the source code, documentation, and user "
        r"run-time elements should be clearly labeled by placing an "
        r"identifier of origin \(such as a name, initial, or other tag\) "
        r"after the version number[;.]? "
        r".{,4}users, modifiers, distributors, and others coming into "
        r"possession or using the Distribution in original or modified "
        r"form accept the entire risk as to the possession, use, and "
        r"performance of the Distribution[;.]? "
        r".{,4}this copyright management information \(software "
        r"identifier and version number, copyright notice and "
        r"license\) shall be retained in all versions of the "
        r"Distribution[;.]? "
        r".{,4}(?:[^ ]+ ){,4}may make modifications to the Distribution "
        r"that are substantially similar to modified versions of the "
        r"Distribution, and may make, use, sell, copy, distribute, "
        r"publicly display, and perform such modifications, including "
        r"making such modifications available under this or other "
        r"licenses, without obligation or restriction[;.]? "
        r".{,4}modifications incorporating code, libraries, and/or "
        r"documentation subject to any other open source license may be "
        r"made, and the resulting work may be distributed under the "
        r"terms of such open source license if required by that open "
        r"source license, but doing so will not affect this "
        r"Distribution, other modifications made under this license or "
        r"modifications made under other (?:[^ ]+ ){,4}licensing "
        r"arrangements[;.]? "
        r".{,4}no permission is granted to distribute, publicly "
        r"display, or publicly perform modifications to the "
        r"Distribution made using proprietary materials that cannot be "
        r"released in source format under conditions of this license[;.]?"
        r".{,4}the name of (?:[^ ]+ ){,4}may not be used in advertising "
        r"or publicity pertaining to Distribution of the software "
        r"without specific, prior written permission[;.]? "
        r'This software is made available "?as is[" ]?, and '
        r"(?:[^ ]+ ){,4}DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, "
        r"WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL "
        r"IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A "
        r"PARTICULAR PURPOSE, AND IN NO EVENT SHALL VOSTROM BE LIABLE "
        r"FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY "
        r"DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR "
        r"PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT \(INCLUDING "
        r"NEGLIGENCE\) OR STRICT LIABILITY, ARISING OUT OF OR IN "
        r"CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE\.",
        "VOSTROM",
    ),
    ReLicense(
        r"Redistribution and use in source and binary forms, with or "
        r"without modification, are permitted provided that the "
        r"following conditions are met:? "
        r".{,4}Redistributions of source code must retain the above "
        r"copyright notice, this list of conditions and the following "
        r"disclaimer\. "
        r".{,4}Redistributions in binary form must reproduce the above "
        r"copyright notice, this list of conditions and the following "
        r"disclaimer in the documentation and/or other materials "
        r"provided with the distribution\. "
        r".{,4}The names (?:[^ ]+ ){,32}must not be used to endorse or "
        r"promote products derived from this software without prior "
        r"written permission. For written permission, please contact "
        r"(?:[^ ]+ ){,4}"
        r".{,4}Products derived from this software may not be called "
        r"(?:[^ ]+ ){,4}nor may (?:[^ ]+ ){,4}appear in their name, "
        r"without prior written permission\. "
        r'THIS SOFTWARE IS PROVIDED "?AS IS"? AND ANY EXPRESSED OR '
        r"IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE "
        r"IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A "
        r"PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT ARE DISCLAIMED. "
        r"IN NO EVENT SHALL (?:[^ ]+ ){,8}OR ITS CONTRIBUTORS BE LIABLE "
        r"FOR ANY DAMAGES IN EXCESS OF (?:[^ ]+ ){,4}NOR FOR ANY "
        r"INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL "
        r"DAMAGES \(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF "
        r"SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; "
        r"OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND ON ANY THEORY OF "
        r"LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT "
        r"\(INCLUDING NEGLIGENCE OR OTHERWISE\) ARISING IN ANY WAY OUT "
        r"OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE "
        r"POSSIBILITY OF SUCH DAMAGE\.",
        "VSL",
        lambda *_a: "VSL-1",
    ),
    ReLicense(
        r"By obtaining, using and/or copying this work, you \(the "
        r"licensee\) agree that you have read, understood, and will "
        r"comply with the following terms and conditions[:.]? "
        r"Permission to (?:use, )?copy, modify, and distribute this "
        r"software "
        r"and its documentation, with or without modification, for any "
        r"purpose and without fee or royalty is hereby granted, provided "
        r"that you include the following on ALL copies of the software "
        r"and documentation or portions thereof, including "
        r"modifications(?:, that you make)?[:.]? "
        r".{,4}The full text of this NOTICE in a location viewable to "
        r"users of the redistributed or derivative work\. "
        r".{,4}Any pre-existing intellectual property disclaimers, "
        r"notices, or terms and conditions. If none exist, "
        r"(?:the W3C Software|a) short "
        r"notice (?:should be included|of the following form) "
        r"\(hypertext is preferred, text "
        r"is permitted\) (?:should be used )?within the body of any "
        r'redistributed or derivative code[:.]? ("?Copyright ©? ?'
        r"\[?\$?date-of-software\]? World Wide Web Consortium, "
        r"\(Massachusetts Institute of Technology, Institut National de "
        r"Recherche en Informatique et en Automatique, Keio "
        r"University\)\. All Rights Reserved\. "
        r'https?[: ]/?/?www.w3.org/Consortium/Legal/?"? )?'
        r".{,4}Notice of any changes or modifications to the "
        r"(?:W3C )?files, "
        r"including the date changes were made\. \(We recommend you "
        r"provide URIs to the location from which the code is derived\.\) "
        r"(?:Disclaimers )?"
        r'THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "?AS IS,"? AND '
        r"COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, "
        r"EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES "
        r"OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR "
        r"THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT "
        r"INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR "
        r"OTHER RIGHTS\. "
        r"COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, "
        r"SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE "
        r"SOFTWARE OR DOCUMENTATION\. "
        r"The name and trademarks of copyright holders may NOT be used "
        r"in advertising or publicity pertaining to the software without "
        r"specific, written prior permission. Title to copyright in this "
        r"software and any associated documentation will at all times "
        r"remain with copyright holders\. ",
        "W3C",
        lambda _t, m, li: "W3C-19980720" if m.group(1) else li,
    ),
    ReLicense(
        r"This file contains Original Code and/or Modifications of "
        r"Original Code as defined in and that are subject to the "
        r"Sybase Open Watcom Public License version ([\d.]+) \(the "
        r'["\']?License[\'" ]?\)[.;] You may not use this file except '
        r"in compliance with the License\. BY USING THIS FILE YOU AGREE "
        r"TO ALL TERMS AND CONDITIONS OF THE LICENSE\. ",
        "Watcom",
        group_version,
    ),
    ReLicense(
        r"Unlimited copying and redistribution of each of the files is "
        r"permitted as long as the file is not modified\. Modifications, "
        r"and redistribution of modified versions, are also permitted, "
        r"but only if the resulting file is renamed\. ",
        "Wsuipa",
    ),
    ReLicense(
        r"Do What The Fuck You Want To Public License, Version "
        r"([^, ]+)",
        "WTFPL",
        group_version,
    ),
    ReLicense(r"Do what The Fuck You Want To Public License", "WTFPL"),
    ReLicense(r"License WTFPL", "WTFPL"),
    ReLicense(r"Under (?:the|a) WTFPL", "WTFPL"),
    ReLicense(
        r"Use and copying of this software and preparation of derivative "
        r"works based upon this software are permitted\. Any copy of this "
        r"software or of any derivative work must include the above "
        r"copyright notice of Xerox Corporation, this paragraph and the "
        r"one after it\. Any distribution of this software or derivative "
        r"works must comply with all applicable United States export "
        r"control laws\. ",
        "Xerox",
    ),
    ReLicense(
        r"The author \(Panagiotis Tsirigotis\) grants permission to use, "
        r"copy, and distribute this software and its documentation for "
        r"any purpose and without fee, provided that the above copyright "
        r"notice extant in files in this distribution is not removed "
        r"from files included in any redistribution and that this "
        r"copyright notice is also included in any redistribution\. ",
        "xinetd",
    ),
    ReLicense(
        r"This product includes software developed by the Indiana "
        r"University Extreme!? Lab\. For further information please "
        r"visit https?[: ]/?/?www.extreme.indiana.edu/?",
        "xpp",
    ),
    ReLicense(
        r"This program is free software;? you can redistribute it "
        r"freely\. "
        r"Use it at your own risk;? there is NO WARRANTY\. "
        r"Redistribution of modified versions is permitted provided that "
        r"the following conditions are met:? "
        r".{,4}All copyright &? ?permission notices are preserved\. "
        r".{,8}Only changes required for packaging or porting are made\. "
        r"or "
        r".{,8}It is clearly stated who last changed the program\. The "
        r"program is renamed or the version number is of the form x.y.z, "
        r"where x.y is the version of the original program and z is an "
        r"arbitrary suffix\.",
        "XSkat",
    ),
    ReLicense(
        r"Yahoo!? Public License, Version ([\d.]+) (?:\(YPL\) )?"
        r'This Yahoo!? Public License \(this "?Agreement[" ]\) is a '
        r"legal agreement that describes the terms under which Yahoo!? "
        r"Inc\., a Delaware corporation having its principal place of "
        r"business at 701 First Avenue, Sunnyvale, California 94089 "
        r'\([" ]Yahoo!?[" ]\) will provide software to you via download '
        r'or otherwise \([" ]Software[" ]\)\. By using the Software, '
        r'you, an individual or an entity \([" ]You[" ]\) agree to the '
        r"terms of this Agreement\.",
        "YPL",
        group_version,
    ),
    ReLicense(
        r"You may copy and distribute this file freely. Any queries and "
        r"complaints should be forwarded to (?:[^ ]+ ){,4}"
        r"If you make any changes to this file, please do not distribute "
        r"the results under the name (?:[^ ]+ ){,4}",
        "Zed",
    ),
    ReLicense(
        r"The Zend Engine License, version ([\d.]+) "
        r"(?:[^ ]+ ){,16}"
        r"Redistribution and use in source and binary forms, with or "
        r"without modification, is permitted provided that the following "
        r"conditions are met:? ",
        "Zend",
        group_version,
    ),
    ReLicense(
        r"Zimbra Public License, Version ([\d.]+) (:?\(ZPL\) )?"
        r'This Zimbra Public License \(this ["“]?Agreement["” ]?\) is a '
        r"legal agreement that describes the terms under which "
        r"(?:VMware|Zimbra), Inc., a (?:Delaware|Texas) corporation ",
        "Zimbra",
        group_version,
    ),
)


# Exception SUBS are a family-level concern: every rule sharing a family id
# carries that family's exception SUBS, so find_licenses applies them off the
# matched rule without a separate family-keyed lookup in licenses.py. A rule may
# still set its own exception_subs inline; that explicit value is preserved.
_FAMILY_EXCEPTION_SUBS: dict[str, tuple[ReSub | ReSubGroup, ...]] = {
    "Apache": APACHE_EXCEPTION_SUBS,
    "QPL": QPL_EXCEPTION_SUBS,
    "MIT/X11": MIT_EXCEPTION_SUBS,
    "CC-BY": CC_BY_SA_EXCEPTION_SUBS,
    "BSD": BSD_EXCEPTION_SUBS,
}

LICENSES_RES = tuple(
    rule._replace(exception_subs=_FAMILY_EXCEPTION_SUBS[rule.license])
    if rule.exception_subs is None and rule.license in _FAMILY_EXCEPTION_SUBS
    else rule
    for rule in LICENSES_RES
)


# Per-family detail refinement, wired onto every rule of the family as its
# get_detail callback (a rule's own inline get_detail takes precedence).
_FAMILY_DETAIL: dict[str, abc.Callable[[str, DetailMatch, str], str]] = {
    "Artistic": parse_artistic,
    "BSD": parse_bsd,
    "CC-BY": parse_cc_by,
    "DocLicense": parse_doc,
    "FontLicense": parse_font,
    "HardwareLicense": parse_hw,
    "USGovPD": parse_usgov_pd,
    "PdMisc": parse_pd_misc,
    "ManPage": parse_manpage,
    "CtanTex": parse_ctan,
    "StandardsBody": parse_std,
    "SrcAvailable": parse_srcavail,
    "EsaPl": parse_esa_pl,
    "TuBerlin": parse_tu_berlin,
    "MulanPsl": parse_mulan,
    "OslDerived": parse_osl_derived,
    "UdaData": parse_uda,
    "AswfAssets": parse_aswf,
    "MitreTou": parse_mitre,
    "CmuMach": parse_cmu_mach,
    "Ssh": parse_ssh,
    "BoehmGc": parse_boehm,
    "GPL": parse_gpl,
    "LGPL": parse_gpl,
    "GFDL": parse_gfdl,
    "LPPL": parse_lppl,
    "ZPL": parse_zpl,
    "AGPL": parse_gpl,
    "CeCILL": parse_cecill,
    "CNRI": parse_cnri,
    "EFL": parse_efl,
    "MIT/X11": parse_mit,
}

LICENSES_RES = tuple(
    rule._replace(get_detail=_FAMILY_DETAIL[rule.license])
    if rule.get_detail is None and rule.license in _FAMILY_DETAIL
    else rule
    for rule in LICENSES_RES
)


COMPILED_RES: tuple[rex.Pattern[str], ...] = tuple(
    rex.compile(re_license.re, re_license.re_flags) for re_license in LICENSES_RES
)
