Skip to content

Commit

Permalink
Merge pull request #8 from raimon49/implement-output-confluence-wiki
Browse files Browse the repository at this point in the history
Implement output Confluence and JIRA Wiki markup
  • Loading branch information
raimon49 authored Mar 19, 2018
2 parents fb9c018 + 30b8972 commit df5a24a
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## CHANGELOG

### 1.7.0

* Implement new option `--format-confluence`

### 1.6.1

* Fix bug
Expand Down
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -64,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: [email protected]
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
Expand Down Expand Up @@ -180,6 +194,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 markup 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.
Expand Down
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 12 additions & 3 deletions piplicenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@

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'
__version__ = '1.7.0'
__author__ = 'raimon'
__license__ = 'MIT License'
__summary__ = ('Dump the software license list of '
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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,
Expand Down
13 changes: 12 additions & 1 deletion test_piplicenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit df5a24a

Please sign in to comment.