From 4303c1b5b08f15a64b7f84b23ac5200a912138e0 Mon Sep 17 00:00:00 2001 From: raimon Date: Sun, 18 Mar 2018 23:15:01 +0900 Subject: [PATCH 1/6] Add implementation and testing for new CLI-option Option: '--format-confluence' --- piplicenses.py | 13 +++++++++++-- test_piplicenses.py | 13 ++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/piplicenses.py b/piplicenses.py index 45afa5f..6c92338 100644 --- a/piplicenses.py +++ b/piplicenses.py @@ -35,7 +35,8 @@ import pip from prettytable import PrettyTable -from prettytable.prettytable import HEADER as RULE_HEADER, ALL as RULE_ALL +from prettytable.prettytable import (FRAME as RULE_FRAME, ALL as RULE_ALL, + HEADER as RULE_HEADER, NONE as RULE_NONE) __pkgname__ = 'pip-licenses' __version__ = '1.6.1' @@ -140,7 +141,8 @@ def factory_styled_table_with_args(args): table = PrettyTable() table.field_names = FIELD_NAMES table.align = 'l' - table.border = (args.format_markdown or args.format_rst) + table.border = (args.format_markdown or args.format_rst or + args.format_confluence) table.header = True if args.format_markdown: @@ -149,6 +151,9 @@ def factory_styled_table_with_args(args): elif args.format_rst: table.junction_char = '+' table.hrules = RULE_ALL + elif args.format_confluence: + table.junction_char = '|' + table.hrules = RULE_NONE return table @@ -244,6 +249,10 @@ def create_parser(): action='store_true', default=False, help='dump as reST style') + parser.add_argument('--format-confluence', + action='store_true', + default=False, + help='dump as confluence wiki style') parser.add_argument('--format-html', action='store_true', default=False, diff --git a/test_piplicenses.py b/test_piplicenses.py index 5c854fc..ff9bbe7 100644 --- a/test_piplicenses.py +++ b/test_piplicenses.py @@ -4,7 +4,7 @@ from email import message_from_string from prettytable.prettytable import (FRAME as RULE_FRAME, ALL as RULE_ALL, - HEADER as RULE_HEADER) + HEADER as RULE_HEADER, NONE as RULE_NONE) from piplicenses import (__pkgname__, create_parser, create_licenses_table, get_output_fields, get_sortby, factory_styled_table_with_args, @@ -206,6 +206,17 @@ def test_format_rst(self): self.assertEquals('+', table.junction_char) self.assertEquals(RULE_ALL, table.hrules) + def test_format_confluence(self): + format_confluence_args = ['--format-confluence'] + args = self.parser.parse_args(format_confluence_args) + table = factory_styled_table_with_args(args) + + self.assertIn('l', table.align.values()) + self.assertTrue(table.border) + self.assertTrue(table.header) + self.assertEquals('|', table.junction_char) + self.assertEquals(RULE_NONE, table.hrules) + def test_format_html(self): format_html_args = ['--format-html'] args = self.parser.parse_args(format_html_args) From 4dbdee0dd51f71d84419ee564a68f0252ad63fe8 Mon Sep 17 00:00:00 2001 From: raimon Date: Sun, 18 Mar 2018 23:22:21 +0900 Subject: [PATCH 2/6] Update dependencies for development --- dev-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index be66755..a861465 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -27,12 +27,12 @@ pypandoc==1.4 pytest-cache==1.0 # via pytest-pycodestyle pytest-cov==2.5.1 pytest-pycodestyle==1.0.6 -pytest-runner==4.0 +pytest-runner==4.2 pytest==3.4.2 # via pytest-cache, pytest-cov, pytest-pycodestyle requests-toolbelt==0.8.0 # via twine requests==2.18.4 # via codecov, requests-toolbelt, twine six==1.11.0 # via pip-tools, pytest -tqdm==4.19.7 # via twine +tqdm==4.19.8 # via twine twine==1.10.0 urllib3==1.22 # via requests wheel==0.30.0 From 8924eaebb1c1366b1b3f949eb08401ebd257e7c0 Mon Sep 17 00:00:00 2001 From: raimon Date: Mon, 19 Mar 2018 00:08:51 +0900 Subject: [PATCH 3/6] Add section of '--format-confluence' option in README --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 8857622..8063ec8 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Dump the software license list of Python packages installed with pip. * [Option: order](#option-order) * [Option: format\-markdown](#option-format-markdown) * [Option: format\-rst](#option-format-rst) + * [Option: format\-confluence](#option-format-confluence) * [Option: format\-html](#option-format-html) * [More Information](#more-information) * [License](#license) @@ -180,6 +181,17 @@ When executed with the `--format-rst` option, you can output list in "[Grid tabl +--------+---------+---------+ ``` +### Option: format-confluence + +When executed with the `--format-confluence` option, you can output list in Confluence or JIRA Wiki format. + +```bash +(venv) $ pip-licenses --format-confluence +| Name | Version | License | +| Django | 2.0.2 | BSD | +| pytz | 2017.3 | MIT | +``` + ### Option: format-html When executed with the `--format-html` option, you can output list in HTML table format. From ddcabc1c9f485af726b48ab41081d7f9fb06d474 Mon Sep 17 00:00:00 2001 From: raimon Date: Mon, 19 Mar 2018 00:19:19 +0900 Subject: [PATCH 4/6] JIRA is second choice --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8063ec8..7993e64 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ When executed with the `--format-rst` option, you can output list in "[Grid tabl ### Option: format-confluence -When executed with the `--format-confluence` option, you can output list in Confluence or JIRA Wiki format. +When executed with the `--format-confluence` option, you can output list in Confluence (or JIRA) Wiki markup format. ```bash (venv) $ pip-licenses --format-confluence From 865f48de334a1e77e9a32bc2d735d4fc2d150364 Mon Sep 17 00:00:00 2001 From: raimon Date: Mon, 19 Mar 2018 15:53:43 +0900 Subject: [PATCH 5/6] Bump version to 1.7.0 --- CHANGELOG.md | 4 ++++ piplicenses.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d04a5f..94a0e46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## CHANGELOG +### 1.7.0 + +* Implement new option `--format-confluence` + ### 1.6.1 * Fix bug diff --git a/piplicenses.py b/piplicenses.py index 6c92338..b4ec49a 100644 --- a/piplicenses.py +++ b/piplicenses.py @@ -39,7 +39,7 @@ HEADER as RULE_HEADER, NONE as RULE_NONE) __pkgname__ = 'pip-licenses' -__version__ = '1.6.1' +__version__ = '1.7.0' __author__ = 'raimon' __license__ = 'MIT License' __summary__ = ('Dump the software license list of ' From 30b89721f0f75b742e0f207121e73430c54c3578 Mon Sep 17 00:00:00 2001 From: raimon Date: Mon, 19 Mar 2018 16:34:58 +0900 Subject: [PATCH 6/6] Improve document for '--from-classifier' option --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7993e64..ecbba4d 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,20 @@ By default, this tool finds the license from package Metadata. However, dependin (See also): [Set license to MIT in setup.py by alisianoi ・ Pull Request #1058 ・ pypa/setuptools](https://github.com/pypa/setuptools/pull/1058), [PEP 314\#License](https://www.python.org/dev/peps/pep-0314/#license) -If you want to refer to the license declared in Classifiers, use the `--from-classifier` option. +For example, even if you check with the `pip show` command, the license is displayed as `UNKNOWN`. + +```bash +(venv) $ pip show setuptools +Name: setuptools +Version: 38.5.0 +Summary: Easily download, build, install, upgrade, and uninstall Python packages +Home-page: https://github.com/pypa/setuptools +Author: Python Packaging Authority +Author-email: distutils-sig@python.org +License: UNKNOWN +``` + +If you want to refer to the license declared in [the Classifiers](https://pypi.python.org/pypi?%3Aaction=list_classifiers), use the `--from-classifier` option. ```bash (venv) $ pip-licenses --from-classifier --with-system