{ "info": { "author": "Hong-She Liang", "author_email": "starofrainnight@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "licenraptor\n===========\n\n.. image:: https://img.shields.io/pypi/v/licenraptor.svg\n :target: https://pypi.python.org/pypi/licenraptor\n\n.. image:: https://travis-ci.org/starofrainnight/licenraptor.svg?branch=master\n :target: https://travis-ci.org/starofrainnight/licenraptor\n\n.. image:: https://ci.appveyor.com/api/projects/status/github/starofrainnight/licenraptor?svg=true\n :target: https://ci.appveyor.com/project/starofrainnight/licenraptor\n\nlicense is a Python library providing some metadata about common free software licenses, such as\nGNU GPL, MIT and others. It is compatible with Python 3.3+ and legacy Python 2.7.\n\nBasic usage\n-----------\n\nTo get a license, you can use `SPDX license identifier `_:\n\n.. code-block:: python\n\n import licenraptor\n mit = licenraptor.find('MIT')\n\nEach license is a static class providing a few properties:\n\n* ``id`` - the SPDX identifier\n* ``name`` - a human readable name of the license\n* ``rpm`` - `license identifier used in Fedora, RHEL and CentOS RPMs `_\n* ``python`` - `PyPI classifier `_\n* ``url`` - link to a license description or website\n\n.. code-block:: python\n\n mit.python\n 'License :: OSI Approved :: MIT License'\n\nLicense classes also offer a static method ``render()`` that will output the entire license text.\nSome variables have to be passed to it, usually ``name``, ``email`` and optional ``year``\n(current year is used when omitted).\n\n.. code-block:: python\n\n mit.render(name='Petr Foo', email='petr@foo.org')\n '''The MIT License (MIT)\n\n Copyright (c) 2015 Petr Foo \n\n Permission is hereby granted... (snip)'''\n\nSome licenses (such as the ones from GPL family) also have a header text, that's supposed to be\nadded to each source file. ``header()`` is used to render that, but be careful, if the license does\nnot use special header, ``AttributeError`` is risen.\n\n.. code-block:: python\n\n mit.header(name='Petr Foo', email='petr@foo.org')\n AttributeError: The MIT license uses no header\n\nIf you want to search the licenses by some other key, you can:\n\n.. code-block:: python\n\n bsd = licenraptor.find_by_key('rpm', 'BSD')\n bsd\n [licenraptor.licenses.BSD3ClauseLicense, licenraptor.licenses.BSD2ClauseLicense]\n\n``bsd`` is now a list, because unlike SPDX identifiers, other keys might not always be unique. If\nyou only need the first license with such identifier, you can pass ``multiple=False`` to\n``find_by_key()``:\n\n.. code-block:: python\n\n bsd = licenraptor.find_by_key('rpm', 'BSD', multiple=False)\n bsd\n licenraptor.licenses.BSD3ClauseLicense\n\nIf such license is not found, you'll get ``KeyError`` instead, the same as with regular ``find()``.\n\nIn case you would like to perform a lot of searches by some key, you can build and index, which\nshould (in theory) make the searches faster (no measurements have been performed).\n\n.. code-block:: python\n\n licenraptor.build_index('rpm')\n\nIn case you want to get rid of an index, use ``licenraptor.delete_index(key)``. It is safe to call it\neven if the index does not exist.\n\nIt is also possible to use ``find_by_function()`` to find licenses that match a certain expression.\nThe function should accept one argument (the license class) and return True if the license is\nsupposed to be in the results:\n\n.. code-block:: python\n\n osi = licenraptor.find_by_function(lambda l: l.python.startswith('License :: OSI Approved :: '))\n\nAgain, it returns a list and has ``multiple`` argument to change that.\n\nIn case a simple function is not enough, you can iterate over all the license with\n``licenraptor.iter()``:\n\n.. code-block:: python\n\n for cls in licenraptor.iter():\n # do something\n\nAdding licenses\n---------------\n\nThe current license list is in no way much extensive, so maybe your favorite license is not in\nthere. If you wish to change that, add the license to ``license/licenses.py`` and a template(s) to\n``license/templates``, and send a `pull request on GitHub\n`_. See the current licenses to learn how to do it.\nA license class looks like this:\n\n.. code-block:: python\n\n class AGPLv3LaterLicense(licenraptor.base.License):\n '''\n GNU Affero General Public License v3.0 or later\n '''\n id = 'AGPL-3.0+'\n rpm = 'AGPLv3+'\n python = 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)'\n url = 'http://www.gnu.org/licenses/agpl-3.0.html'\n\nOne license can inherit from other and omit the keys that are equal. Note that the docstring is\nimportant and it is used as ``name`` property. License template is named as ``id``, header template\nis named with ``__header`` suffix.\n\nIf you wish to add custom licenses in your code, you can do that as well. If you won't use\n``render()`` or ``header()``, the thing is simple. Just define such class anywhere and call\n``licenraptor.register()`` on it.\n\nHowever, if you would then call ``render()`` or ``header()``, the template would hove not been\nfound. In that case, you have to create a *Custom Base License* with a ``jinja2`` template loader.\n\n.. code-block:: python\n\n CustomBaseLicense = licenraptor.base.custom_license_base_class(loader=jinja2.FileSystemLoader('path/to/templates'))\n\n class CustomLicense(CustomBaseLicense):\n ...\n\n licenraptor.register(CustomLicense)\n\nThe ``loader`` can be any valid `jinja2 loader `_.\nIf you wish to register multiple classes at once, you can use ``licenraptor.autoregister()`` that will\nregister all classes present in given module. You will not want to register your\n``CustomBaseLicense``, so you'll pass it in the ``ignore`` argument.\n\n.. code-block:: python\n\n licenraptor.autoregister(sys.modules[__name__], ignore=[CustomBaseLicense])\n\nNote that if you add custom licenses and use ``licenraptor.build_index()``, you want to build the index\nafter registering them. Calling ``build_index()`` multiple times is safe.\n\n(Possibly) Frequently Asked Questions\n-------------------------------------\n\nWhy are licenses represented as subclasses and not instances of ``License``?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThis way, it is easier to inherit data between multiple licenses. The definition of classes is\neasier maintainable and readable.\n\nWhere the library name `licenraptor` came from?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nOh, Miro Hron\u010dok suggest this name in his project `license `_\nwhich this project fork from :)\n\nAren't there already Python tools that can render license texts?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYes, they are. However all of them are command line utilities and provide no API for Python\nprogrammers.\n\n* `choosealicense-cli `_\n* `licenser `_\n* `licen `_\n* `garnish `_\n\n\n\n\n=======\nHistory\n=======\n\n0.2.0 (2018-06-29)\n------------------\n\n* Changed package name to 'licenraptor'", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/starofrainnight/licenraptor", "keywords": "licenraptor,licenraptor", "license": "Apache Software License", "maintainer": "", "maintainer_email": "", "name": "licenraptor", "package_url": "https://pypi.org/project/licenraptor/", "platform": "", "project_url": "https://pypi.org/project/licenraptor/", "project_urls": { "Homepage": "https://github.com/starofrainnight/licenraptor" }, "release_url": "https://pypi.org/project/licenraptor/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Library that encapsulates free software licenses", "version": "0.2.1" }, "last_serial": 4017821, "releases": { "0.2.1": [ { "comment_text": "", "digests": { "md5": "e0fd31b76119aa0060354488c418fc73", "sha256": "7ff7221b0de3c64a06d059c32d9fe2fce30fcdc4942331f984f8ee55edab8bde" }, "downloads": -1, "filename": "licenraptor-0.2.1.zip", "has_sig": false, "md5_digest": "e0fd31b76119aa0060354488c418fc73", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26584, "upload_time": "2018-06-30T08:39:08", "url": "https://files.pythonhosted.org/packages/1b/08/58a9c33f81764d7d9b1f2f019bb91584a3ca1119c8aef3c6a91772be3196/licenraptor-0.2.1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e0fd31b76119aa0060354488c418fc73", "sha256": "7ff7221b0de3c64a06d059c32d9fe2fce30fcdc4942331f984f8ee55edab8bde" }, "downloads": -1, "filename": "licenraptor-0.2.1.zip", "has_sig": false, "md5_digest": "e0fd31b76119aa0060354488c418fc73", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26584, "upload_time": "2018-06-30T08:39:08", "url": "https://files.pythonhosted.org/packages/1b/08/58a9c33f81764d7d9b1f2f019bb91584a3ca1119c8aef3c6a91772be3196/licenraptor-0.2.1.zip" } ] }