"""
This file contains our open source policy.

Any library interfacing with ocyan, that is required to be installed on a production
server should conform to the following policy:

    The licence under which libraries are made available must be reviewed before usage.

    Licences of the type "NetworkCopyleft" (GNU Affero GPL and the like) are FORBIDDEN
    and must be IMMEDIATELY REMOVED if found to be part of any project.

    Licenses of the type "StrongCopyleft"  (GNU GPL and the like) are not allowed.
    When any package falling under such licences are found to be installed, they should
    be

    1. replaced with package with a more permissive license
    2. Removed from the project
    3. A more permissive licence must be purchased from the author.

    In the constants below the implementation of this policy is formed by enumerating
    the licenses currently in use, which are of a more permissive nature than NetworkCopyleft
    or StrongCopyleft. This list should be maintained and expanded when needed or pruned
    if licenses are nolonger in use.

Any library, not interfacing with ocyan and not installed on a production server should
conform to the following policy:

    The licence under which libraries are made available must be reviewed before usage.

    Licences of the type "NetworkCopyleft" (GNU Affero GPL and the like) are FORBIDDEN
    and must be IMMEDIATELY REMOVED if found to be part of any project.

    Other, more permissive licenses, even "StrongCopyleft" like GNU GPL are allowed,
    however these libraries must be registered below as IGNORED_CI_REQUIREMENTS and
    accompanied by an explanation why the package is needed.
"""

# Below licenses are currently in use and conform to the open source policy
ALLOWED_LICENSES = (
    "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0",
    "CDDL-1.0",
    "MIT License",
    "MIT",
    "MIT-CMU",
    "CMU License (MIT-CMU)",
    "BSD License",
    "BSD-1-Clause",
    "2-Clause BSD License",
    "BSD-2-Clause",
    "3-Clause BSD License",
    "BSD-3-Clause",
    "GNU Library or Lesser General Public License (LGPL)",
    "GNU Lesser General Public License v2 (LGPLv2)",
    "LGPL-2.0",
    "GNU Lesser General Public License v2 or later (LGPLv2+)",
    "LGPL-2.1",
    "LGPL-2.1-or-later",
    "LGPL-2.1-only OR MPL-1.1",
    "GNU Lesser General Public License v3 (LGPLv3)",
    "GNU Lesser General Public License v3 or later (LGPLv3+)",
    "LGPL-3.0",
    "LGPL-3.0-or-later",
    "LGPLv3+",
    "ISC License (ISCL)",
    "ISC",
    "Apache Software License",
    "Apache-1.1",
    "Apache 2.0",
    "Apache License, Version 2.0",
    "Apache-2.0",
    "Python Software Foundation License",
    "PSF-2.0",
    "Mozilla Public License 2.0 (MPL 2.0)",
    "MPL-2.0",
    "Historical Permission Notice and Disclaimer (HPND)",
    "HPND",
    "zlib/libpng License",
    "Zlib",
    "The Unlicense (Unlicense)",
    "Unlicense",
    "Other/Proprietary License",
    "Zope Public License",
    "Zope Public License (ZPL 2.1)",
    "ZPL - 2.1",
    "BSD 3-Clause OR Apache-2.0",
    "Apache-2.0 OR BSD-3-Clause",
)

# below package might have licenses that do not conform but exceptions
# are made because licenses where purchases, the code is owned by highbiza
# or some other reason, ALWAYS CLEARLY EXPLAINED BEHIND THE EXCEPTION
IGNORED_PACKAGES = (
    # Python PACKAGES
    "wagtail-extendedsearch",  # Owned by highbiza
    "straight.plugin",  # HAS MIT LICENCE, see https://github.com/highbiza/straight.plugin/blob/master/LICENSE
    "configtype",  # Dual license obtained from author
    "uwsgidecorators-fallback",  # Dual license obtained from author
    "django-oscar-elasticsearch",  # owned by highbiza
    "seo-ville-slugger",  # has MIT licese, see https://github.com/specialunderwear/seo-ville-slugger/blob/master/LICENSE
    "wagtail-instance-selector",  # Has MIT license, see https://github.com/ixc/wagtail-instance-selector/blob/master/LICENSE
    "mailjet-rest",  # Has MIT license, see https://github.com/mailjet/mailjet-apiv3-python/blob/master/LICENSE
    "docx2txt",  # has MIT license, see https://github.com/ankushshah89/python-docx2txt/blob/master/LICENSE.txt
    "django-secret-sharing",  # Has MIT license, see https://github.com/vicktornl/django-secret-sharing/blob/master/LICENSE
    "django-oscar-odin",  # this opensource project is created by highbiza and has the BSD license. Unfortunately the license info is lost when a package is built by our CI, so we must exclude it, untill a better solution has been found.
    "referencing",  # Has MIT license, see https://github.com/python-jsonschema/referencing/,tree/main?tab=MIT-1-ov-file, can be removed once all projects run voxyan as newer version do properly specify license.
    "attrs",  # Has MIT license, see https://github.com/python-attrs/attrs/blob/main/LICENSE, can be removed once all projects run voxyan as newer version do properly specify license.
    "keybiza",  # Owned by Highbiza,
    "mypy_extensions",  # Has MIT License; https://github.com/python/mypy_extensions/blob/master/LICENSE, can be removed once all projects run voxyan as newer version do properly specify license.
    "typing_extensions",  # Has GPL License; https://github.com/python/typing_extensions/blob/main/LICENSE, can be removed once all projects run voxyan as newer version do properly specify license.
    "jsonschema-specifications",  # Has MIT License; https://github.com/python-jsonschema/jsonschema-specifications, can be removed once all projects run voxyan as newer version do properly specify license.
    # JS PACKAGES
    "jquery.mmenu@7.2.2",  # we purchased a license from the copyright holder: 4-jsms-0848-20240227-4ae8-b46f01
    "tesseract.js-core@5.1.0",  # Has Apache-2.0 license, see https://github.com/naptha/tesseract.js-core/blob/master/LICENSE, but license-checker returns Apache* as the license in package.json is not valid spdx format
    "matplotlib-inline",  # Has BSD 3-Clause License https://github.com/ipython/matplotlib-inline/blob/main/LICENSE
)


# During CI testing package might be installed but are not included in
# when the project is installed on the server. We allow package
IGNORED_CI_REQUIREMENTS = (
    "vdt.version",  # this package is need for automated releases in CI
    "vdt.versionplugin.default",  # this package is need for automated releases in CI
    "vdt.versionplugin.wheel",  # this package is need for automated releases in CI
    "pylint",  # this package is needed to enforce code quality standards in CI
    "pylint-django",  # this package is needed to enforce code quality standards in CI
    "pylint-plugin-utils",  # this package is needed to enforce code quality standards in CI
)
