Go to file
2017-04-12 23:33:12 +02:00
docs Initial commit 2017-04-12 19:20:08 +02:00
src/licensename Those are not licenses. 2017-04-12 23:05:26 +02:00
tests Removing unknown, "deprecated", and duplicates (without any diff) licences from tests. 2017-04-12 22:39:23 +02:00
.coveragerc Initial commit 2017-04-12 19:20:08 +02:00
.gitignore Initial commit 2017-04-12 19:20:08 +02:00
.pre-commit-config.yaml Initial commit 2017-04-12 19:20:08 +02:00
AUTHORS.rst Initial commit 2017-04-12 19:20:08 +02:00
CHANGES.rst Tell there's no changes in CHANGES.rst 2017-04-12 23:11:01 +02:00
LICENSE.txt Initial commit 2017-04-12 19:20:08 +02:00
README.rst Updating README.rst 2017-04-12 23:04:54 +02:00
requirements.txt Initial commit 2017-04-12 19:20:08 +02:00
setup.cfg Better capitalize accronyms. 2017-04-12 23:33:12 +02:00
setup.py Initial commit 2017-04-12 19:20:08 +02:00
test-requirements.txt Initial commit 2017-04-12 19:20:08 +02:00

licensename

Module or script to find a license name from a license text or file.

Usage

This can be used as a script:

$ licensename tests/licenses/MIT.txt
MIT
$ licensename tests/licenses/BSD-2-Clause.txt
BSD-2-Clause

Or as a module:

>>> import licensename
>>> licensename.from_file('./tests/licenses/MIT.txt')
'MIT'
>>> licensename.from_file('./tests/licenses/BSD-2-Clause.txt')
'BSD-2-Clause'
>>> licensename.from_text("MIT License\nyadi yadi yada…")
'MIT'

Adding a license

Known licenses are stored in src/licensename/known_licenses.py. The structure is aimed to be understandable by humans: it's a simple dict, each level of the dict correspond to a line in the license, like:

"The LaTeX Project Public License": {
  "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-": {
      "LPPL Version 1.1 1999-07-10": "LPPL-1.1",
      "LPPL Version 1.2 1999-09-03": "LPPL-1.2",
      "LPPL Version 1.3a 2004-10-01": "LPPL-1.3a",
      "LPPL Version 1.3c 2008-05-04": "LPPL-1.3c"
  }
}

reads like: If line one is "The LaTeX Project Public License", and the line two is "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", and the line three is "LPPL Version 1.1 1999-07-10", it's an "LPPL-1.1", and so on.

In other worlds, first dict is for line one, second level of dicts are for line two, etc… until as string is found instead of a dict, meaning there's no longer need for disambiguation, and it's the license name.

Lines containing (c), (C), empty lines, or starting with Copyright are ignored.

Note

This project has been set up using PyScaffold 2.5.7. For details and usage information on PyScaffold see http://pyscaffold.readthedocs.org/.