Last active
November 13, 2017 22:26
-
-
Save davidthewatson/27053d9a54ae5568eb240531c1c6963e to your computer and use it in GitHub Desktop.
For a given python repo on github, output a list of dependencies for a virtualenv, then read that list and generate a CSV describing licenses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip list | xargs pip show >output.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = open('output.txt') | |
l = f.readlines() | |
headers = ('Product', 'Name', 'Public', 'Non-Public Software Contract Reference', 'License Type', 'CopyLeft?', 'URL of License or Download Site', 'Has CopyLeft Software Been Modified or Distributed', 'Royalty or Fees Due From Buyer to Other Parties on Transaction', 'Description') | |
row = [] | |
all = [] | |
for i in range(len(l)): | |
if l[i] == '---\n': | |
all.append(row) | |
row = [] | |
continue | |
else: | |
if l[i].find('://') > -1: | |
print(l[i]) | |
row.append(l[i].split(':')[1]+l[i].split(':')[2]) | |
else: | |
row.append(l[i].split(':')[1]) | |
data = [('', a[0].strip(), 'Yes', 'N/A', a[6].strip(), 'No', a[3].strip(), 'N/A', 'None', a[2].strip()) for a in all] | |
data = tablib.Dataset(*data, headers=headers) | |
import tablib | |
data = tablib.Dataset(*data, headers=headers) | |
f = open('dog.csv', 'w') | |
f.writelines(data.export('csv')) | |
f.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment