Created
July 15, 2020 20:59
-
-
Save di/1db107493a2ca0d2886d821faa171e03 to your computer and use it in GitHub Desktop.
Specifier vs LegacySpecifier analysis
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
import csv | |
from collections import defaultdict | |
import packaging.requirements | |
totals = defaultdict(int) | |
with open('specifiers.csv') as f: | |
reader = csv.reader(f) | |
with open('out.csv', 'w') as o: | |
writer = csv.writer(o) | |
for row in reader: | |
req, count = row | |
try: | |
rrr = packaging.requirements.Requirement(req) | |
specs = rrr.specifier._specs | |
if 'LegacySpecifier' in [type(x).__name__ for x in specs]: | |
totals['LegacySpecifier'] += int(count) | |
else: | |
totals['Specifier'] += int(count) | |
except packaging.requirements.InvalidRequirement: | |
totals['invalid'] += int(count) | |
print(totals) |
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
copy ( | |
select | |
specifier, | |
count(specifier) | |
from | |
release_dependencies | |
group by | |
specifier | |
) to STDOUT CSV; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment