Skip to content

Instantly share code, notes, and snippets.

@davidthewatson
Last active November 13, 2017 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidthewatson/27053d9a54ae5568eb240531c1c6963e to your computer and use it in GitHub Desktop.
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
pip list | xargs pip show >output.txt
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