Skip to content

Commit

Permalink
Merge pull request #7 from raimon49/support-display-multiple-license
Browse files Browse the repository at this point in the history
Support display multiple license
  • Loading branch information
raimon49 authored Mar 5, 2018
2 parents 17719e9 + bd0a375 commit db135b9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## CHANGELOG

### 1.6.1

* Fix bug
* Support display multiple license with `--from-classifier` option
* Improve document
* Add section of 'Uninstallation' in README

### 1.6.0

* Implement new option `--format-html`
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Dump the software license list of Python packages installed with pip.
* [More Information](#more-information)
* [License](#license)
* [Dependencies](#dependencies)
* [Uninstallation](#uninstallation)

## Description

Expand Down Expand Up @@ -217,3 +218,11 @@ Other, please make sure to execute the `--help` option.
* [PTable](https://pypi.python.org/pypi/PTable) by Luke Maurits and maintainer of fork version Kane Blueriver under the BSD-3-Clause License

`pip-licenses` has been implemented in the policy to minimize the dependence on external package.

## Uninstallation

Uninstall package and dependent package with `pip` command.

```bash
$ pip uninstall pip-licenses PTable
```
8 changes: 6 additions & 2 deletions piplicenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from prettytable.prettytable import HEADER as RULE_HEADER, ALL as RULE_ALL

__pkgname__ = 'pip-licenses'
__version__ = '1.6.0'
__version__ = '1.6.1'
__author__ = 'raimon'
__license__ = 'MIT License'
__summary__ = ('Dump the software license list of '
Expand Down Expand Up @@ -156,9 +156,13 @@ def factory_styled_table_with_args(args):
def find_license_from_classifier(message):
license_from_classifier = LICENSE_UNKNOWN

licenses = []
for k, v in message.items():
if k == 'Classifier' and v.startswith('License'):
license_from_classifier = v.split(' :: ')[-1]
licenses.append(v.split(' :: ')[-1])

if len(licenses) > 0:
license_from_classifier = ', '.join(licenses)

return license_from_classifier

Expand Down
11 changes: 11 additions & 0 deletions test_piplicenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ def test_find_license_from_classifier(self):
self.assertEquals('MIT License',
find_license_from_classifier(message))

def test_display_multiple_license_from_classifier(self):
metadata = ('Metadata-Version: 2.0\r\n'
'Name: helga\r\n'
'Version: 1.7.6\r\n'
'Classifier: License :: OSI Approved :: '
'GNU General Public License v3 (GPLv3)\r\n'
'Classifier: License :: OSI Approved :: MIT License\r\n')
message = message_from_string(metadata)
self.assertEquals('GNU General Public License v3 (GPLv3), MIT License',
find_license_from_classifier(message))

def test_not_found_license_from_classifier(self):
metadata_as_no_license = ('Metadata-Version: 2.0\r\n'
'Name: pip-licenses\r\n'
Expand Down

0 comments on commit db135b9

Please sign in to comment.