This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake-fundable-html
executable file
·70 lines (64 loc) · 3.24 KB
/
make-fundable-html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
import csv
import json
from collections import defaultdict
eco_map = {
'js': 'JavaScript',
'php': 'PHP',
'py': 'Python',
'rb': 'Ruby',
'rs': 'Rust',
}
eco_map_reverse = {v:k for k,v in eco_map.items()}
github = json.load(open('github.json'))
counts = {
'ecos': defaultdict(set),
'sponsorables': defaultdict(lambda: defaultdict(lambda: {'used_in': set(), 'projects': set()}))
}
urls = dict()
data = defaultdict(lambda: defaultdict(list))
inp = csv.reader(open('deps.csv'))
next(inp) # throw away headers
for org, sponsorable, url, repo, stars, eco in inp:
stars = int(stars)
used_in = sorted(list(set([x.split('/')[0] for x in github[eco][org][repo]])))
eco = eco_map.get(eco, eco)
counts['ecos'][eco].add(sponsorable)
counts['sponsorables'][eco][sponsorable]['used_in'] |= set(used_in)
counts['sponsorables'][eco][sponsorable]['projects'].add(repo)
urls[sponsorable] = url
data[eco][sponsorable].append((len(used_in), stars, used_in, org, repo))
for eco in counts['ecos']:
counts['ecos'][eco] = len(counts['ecos'][eco])
for eco in counts['sponsorables']:
for sponsorable in counts['sponsorables'][eco]:
nused_in = len(counts['sponsorables'][eco][sponsorable]['used_in'])
nprojects = len(counts['sponsorables'][eco][sponsorable]['projects'])
counts['sponsorables'][eco][sponsorable] = (nused_in, nprojects)
out = open('fundable.html', 'w+')
def p(*a, **kw):
print(*a, **kw, file=out)
p('<!DOCTYPE html><html><head><title>Sentry\'s Fundable Dependencies</title><link rel="stylesheet" href="style.css"></head><body><div class="ecos">')
p(f'<h1>Sentry\'s Fundable Dependencies</h1>')
p(f'<p>This is a <a href="https://github.com/getsentry/deps">hack</a> to find GitHub orgs/users from five ecosystems whose projects we directly depend on in our <a href="https://open.sentry.io/structure/">main repos</a> and who accept funding on either <a href="https://github.com/sponsors">GitHub Sponsors</a> or <a href="https://opencollective.com/">Open Collective</a>.</p>')
p(f'<h2>Your Laptop</h2>')
p(f'<p>If you\'re on a Mac using Homebrew then run <code>brew leaves</code> to see a list of packages you\'ve installed directly (top-level packages, not dependencies).</p>')
for n, eco in reversed(sorted([(v,k) for k,v in counts['ecos'].items()])):
p(f'<h2>{eco}</h2>')
p(f'<table class="orgs">')
p(f'<thead><tr><th></th><th>Org/User</th><th>Project</th></tr></thead>')
for i, ((nused_in, nprojects), sponsorable) in enumerate(reversed(sorted([(v,k) for k,v in counts['sponsorables'][eco].items()])), start=1):
url = urls[sponsorable]
p(f'<tr class="sponsorable">')
p(f' <td class="i">{i}</td>')
p(f' <td class="sponsorable"><a href="{url}" target="_blank">{sponsorable}</a></td>')
p(f' <td class="project">')
for j, (nused_in, stars, used_in, org, repo) in enumerate(reversed(sorted(data[eco][sponsorable]))):
p(f'<div><span class="stars">★ {stars:,}</span>')
p(f'<a href="https://github.com/{org}/{repo}">{repo}</a><br>')
for ours in used_in:
p(f'<span class="used_in">{ours}</span>')
p(f'</div>')
p(f'</td></tr>')
p(f'</table>')
p('</div></body></html>')