{ "info": { "author": "Miro Hron\u010dok", "author_email": "miro@hroncok.cz", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries" ], "description": "license\n=======\n\n.. image:: https://badge.fury.io/py/license.svg\n :target: http://badge.fury.io/py/license\n\n.. image:: http://img.shields.io/:license-mit-green.svg?style=flat\n :target: http://opensource.org/licenses/MIT\n\n.. image:: https://travis-ci.org/hroncok/license.png?branch=master\n :target: https://travis-ci.org/hroncok/license\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 license\n mit = license.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 = license.find_by_key('rpm', 'BSD')\n bsd\n [license.licenses.BSD3ClauseLicense, license.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 = license.find_by_key('rpm', 'BSD', multiple=False)\n bsd\n license.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 license.build_index('rpm')\n\nIn case you want to get rid of an index, use ``license.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 = license.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``license.iter()``:\n\n.. code-block:: python\n\n for cls in license.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(license.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``license.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 = license.base.custom_license_base_class(loader=jinja2.FileSystemLoader('path/to/templates'))\n \n class CustomLicense(CustomBaseLicense):\n ...\n\n license.register(CustomLicense)\n\nThe ``loader`` can be any valid `jinja2 loader `_.\nIf you wish to register multiple classes at once, you can use ``license.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 license.autoregister(sys.modules[__name__], ignore=[CustomBaseLicense])\n\nNote that if you add custom licenses and use ``license.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\nIsn't ``license`` a reserved name?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYes, it is, it prints the Python's license. Possibly something you would only use in an interactive\nPython console. By importing this library, you are overriding it. We could have named the library\nwith something cool and unique, such as ``licenraptor``, but we wanted to make the name as easy as\npossible. In case you don't like this, you can always do ``import license as somethignelse``.\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 `_", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hroncok/license", "keywords": "license", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "license", "package_url": "https://pypi.org/project/license/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/license/", "project_urls": { "Homepage": "https://github.com/hroncok/license" }, "release_url": "https://pypi.org/project/license/0.1a2/", "requires_dist": null, "requires_python": "", "summary": "Library that encapsulates free software licenses", "version": "0.1a2" }, "last_serial": 1785803, "releases": { "0.1.dev1": [], "0.1a1": [ { "comment_text": "", "digests": { "md5": "72223eae04c75fb5a412196b20684cc5", "sha256": "8112b3a46a61c148e44cead852c7f9f8bccb76e9718f036479d67bc114e0bf0c" }, "downloads": -1, "filename": "license-0.1a1.tar.gz", "has_sig": false, "md5_digest": "72223eae04c75fb5a412196b20684cc5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 70096, "upload_time": "2015-07-20T12:21:13", "url": "https://files.pythonhosted.org/packages/74/04/2d4f1fee962b87823d517ebf59014771798058e2c6a8abeebfc258a7c3b5/license-0.1a1.tar.gz" } ], "0.1a2": [ { "comment_text": "", "digests": { "md5": "fff8a4b70cbbfb452451e2fd0c92589a", "sha256": "f5582fd91583f0be226ea5965294247268e6486289137f0e63a114877a0fbc8d" }, "downloads": -1, "filename": "license-0.1a2.tar.gz", "has_sig": false, "md5_digest": "fff8a4b70cbbfb452451e2fd0c92589a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 70370, "upload_time": "2015-10-26T01:08:41", "url": "https://files.pythonhosted.org/packages/18/70/1e3258cfb70b096a93f2b5fbf005e711c7816520a0d224489c07711aeae4/license-0.1a2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fff8a4b70cbbfb452451e2fd0c92589a", "sha256": "f5582fd91583f0be226ea5965294247268e6486289137f0e63a114877a0fbc8d" }, "downloads": -1, "filename": "license-0.1a2.tar.gz", "has_sig": false, "md5_digest": "fff8a4b70cbbfb452451e2fd0c92589a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 70370, "upload_time": "2015-10-26T01:08:41", "url": "https://files.pythonhosted.org/packages/18/70/1e3258cfb70b096a93f2b5fbf005e711c7816520a0d224489c07711aeae4/license-0.1a2.tar.gz" } ] }