Skip to content

Commit

Permalink
Calcula as licenças para cada ecossistema;
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbaiser committed Oct 28, 2017
1 parent 7372711 commit 332aabc
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 16 deletions.
96 changes: 96 additions & 0 deletions calculateQtdeLicences.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
from edm import *
import json

unlisted = "unlisted.json"
osi = "osi.json"

allUnlistedLicense = 0
allOSI = 0

with open(unlisted) as file:
unlisted = json.load(file)
with open(osi) as file:
osi = json.load(file)

edm = EcosystemDataManager("cran")
licenses = edm.get("VersionsHasLicenses")
cranlicenses = [y for x in licenses for y in x]
print ("Cran Total Licenses" , len(cranlicenses))
crandistinctlicenses = list(set(cranlicenses))
unlistedLicense = 0
osiLicense = 0
misused = 0
for license in crandistinctlicenses:
if (license in osi):
osiLicense += 1
elif (license in unlisted):
unlistedLicense += 1
elif (license != "file" and license != "copyright" and license != "none"):
misused += 1
print ("Cran Distinct Licenses: "+ str(len(crandistinctlicenses)))
print ("Cran OSI Licenses known: " + str(osiLicense))
print ("Cran Unlisted Licenses unapproved: " + str(unlistedLicense))
print("Cran copyright", "copyright" in crandistinctlicenses)
print("Cran none", "none" in crandistinctlicenses)
print("Cran file", "file" in crandistinctlicenses)
print("Cran misused", misused)
print()

edm = EcosystemDataManager("rubygems")
licenses = edm.get("VersionsHasLicenses")
rubylicenses = [y for x in licenses for y in x]
print ("RubyGems Total Licenses" , len(rubylicenses))
rubydistinctlicenses = list(set(rubylicenses))
unlistedLicense = 0
osiLicense = 0
misused = 0
for license in rubydistinctlicenses:
if (license in osi):
osiLicense += 1
elif (license in unlisted):
unlistedLicense += 1
elif (license != "file" and license != "copyright" and license != "none"):
misused += 1
print ("RubyGems Distinct Licenses: "+ str(len(rubydistinctlicenses)))
print ("RubyGems OSI Licenses: " + str(osiLicense))
print ("RubyGems Unlisted Licenses: " + str(unlistedLicense))
print("Rubygems copyright", "copyright" in rubydistinctlicenses)
print("Rubygems none", "none" in rubydistinctlicenses)
print("Rubygems file", "file" in rubydistinctlicenses)
print("Rubygems misused", misused)
print()

edm = EcosystemDataManager("npm")
licenses = edm.get("VersionsHasLicenses")
npmlicenses = [y for x in licenses for y in x]
print ("NPM Total Licenses" , len(npmlicenses))
npmdistinctlicenses = list(set(npmlicenses))
unlistedLicense = 0
osiLicense = 0
misused = 0
for license in npmdistinctlicenses:
if (license in osi):
osiLicense += 1
elif (license in unlisted):
unlistedLicense += 1
elif (license != "file" and license != "copyright" and license != "none"):
misused += 1
print ("NPM Distinct Licenses: "+ str(len(npmdistinctlicenses)))
print ("NPM OSI Licenses: " + str(osiLicense))
print ("NPM Unlisted Licenses: " + str(unlistedLicense))
print("NPM copyright", "copyright" in npmdistinctlicenses)
print("NPM none", "none" in npmdistinctlicenses)
print("NPM file", "file" in npmdistinctlicenses)
print("NPM misused", misused)
print()

allecosystems = crandistinctlicenses + rubydistinctlicenses + npmdistinctlicenses
alldistinct = list(set(allecosystems))
inosi = [x for x in alldistinct if x in osi]


inUnlitesd = [x for x in alldistinct if x in unlisted]

print ("All Unlisted Licenses: " + str(len(unlisted)))
print ("All OSI Licenses: " + str(len(inosi)))
print ("All Distinct Licenses: " + str(len(alldistinct)))
2 changes: 1 addition & 1 deletion cran/DependenciesAreIregular.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cran/VersionsHasGlobalRegularityMean.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cran/VersionsHasGlobalRegularityRate.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cran/VersionsHasLocalRegularityRate.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions ecosystemDataManager/ecosystemDataManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,15 @@ def backupLicenses(self):
self.save("VersionsHasOriginalLicenses")

def evaluateInLicenses(self, inLicenses):
if not inLicenses:
return True
# if not inLicenses:
# return True
for inLicense in inLicenses:
if inLicense.getGroup() == Group.UNDEFINED:
return True
if inLicense.getGroup() == Group.COPYRIGHT:
return True
if inLicense.getGroup() == Group.UNAPPROVED:
return True
# if inLicense.getGroup() == Group.UNDEFINED:
# return True
# if inLicense.getGroup() == Group.COPYRIGHT:
# return True
# if inLicense.getGroup() == Group.UNAPPROVED:
# return True
if inLicense.getGroup() == Group.MISUSED:
return True
return False
Expand Down
2 changes: 1 addition & 1 deletion rubygems/DependenciesAreIregular.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rubygems/VersionsHasGlobalRegularityMean.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rubygems/VersionsHasGlobalRegularityRate.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rubygems/VersionsHasLocalRegularityRate.json

Large diffs are not rendered by default.

0 comments on commit 332aabc

Please sign in to comment.