Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to pull license file path and contents #22

Merged
merged 2 commits into from
Feb 18, 2019
Merged

Add option to pull license file path and contents #22

merged 2 commits into from
Feb 18, 2019

Conversation

cpeel
Copy link
Contributor

@cpeel cpeel commented Feb 13, 2019

My organization needs the ability to pull the license file path and contents, similar to how npm license-checker does when using --customPath licenseText. This adds that functionality with the --with-license-file argument.

While validating this, I discovered that PTable determines vertical table layout based on the data in the row even if those fields won't be output. Hence commit 90470ab to only add fields to the row if we want to output them. I've broken that into a separate logical commit but can break it out into another PR if that would be preferred.

During testing I also found a missing development dependency, hence the updates to dev-requirements.in (and the re-computed dev-requirements.txt) in a separate commit.

@codecov
Copy link

codecov bot commented Feb 13, 2019

Codecov Report

Merging #22 into master will decrease coverage by 0.19%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #22     +/-   ##
=========================================
- Coverage   97.59%   97.39%   -0.2%     
=========================================
  Files           1        1             
  Lines         166      192     +26     
=========================================
+ Hits          162      187     +25     
- Misses          4        5      +1
Impacted Files Coverage Δ
piplicenses.py 97.39% <100%> (-0.2%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 121fa86...8531244. Read the comment docs.

@codecov
Copy link

codecov bot commented Feb 13, 2019

Codecov Report

Merging #22 into master will decrease coverage by 0.19%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #22     +/-   ##
=========================================
- Coverage   97.59%   97.39%   -0.2%     
=========================================
  Files           1        1             
  Lines         166      192     +26     
=========================================
+ Hits          162      187     +25     
- Misses          4        5      +1
Impacted Files Coverage Δ
piplicenses.py 97.39% <100%> (-0.2%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 956349f...ef22217. Read the comment docs.

@raimon49
Copy link
Owner

Thank you for many suggestions and patches.

I will take the time soon to review this.

dev-requirements.in Outdated Show resolved Hide resolved
@@ -144,6 +145,11 @@ When executed with the `--with-description` option, output with short descriptio
pytz 2017.3 MIT World timezone definitions, modern and historical
```

### Option: with-license-file

When executed with the `--with-license-file` option, output the location of the package's license file on disk and the full contents of that file. Due to the length of these fields, this option is best paired with `--format-json`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The document is valid and I agree.

After merging this P-R, I make a warning to recommend the JSON format when running the --with-license-file option with table format.

How do you like it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that a warning to use the JSON format with --with-license-file is a good idea.

PTable determines vertical layout based on row contents, even if
those fields won't be output. Only add fields to rows that we
intend to output.

Update tests to ensure we are exercising FIELDS_TO_METADATA_KEYS
@mitchbte
Copy link

Agreed, this feature would be very useful, especially for non standard licenses. It would be great if it could do a compare of the licenses and print a summary of which packages use which licenses.

@raimon49
Copy link
Owner

raimon49 commented Feb 18, 2019

@cpeel Thank you for rebase. I will merge this P-R and release next version of pip-licenses 1.11.0 to PyPI.

And I will implement warning output at pip-licenses 1.12.0 and later.

Your code is cool because it also supports Python 2.7 👍

@raimon49 raimon49 merged commit 0f716ea into raimon49:master Feb 18, 2019
@cpeel cpeel deleted the add-license-files branch February 18, 2019 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants