Last active
November 24, 2024 14:46
-
-
Save chrisxaustin/aeec1362092c8ce52fc88dda23f388a7 to your computer and use it in GitHub Desktop.
Analyze the output from github contributors, which I capture with the list-contrib gist
This file contains hidden or 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
#!/opt/homebrew/bin/python3 | |
import re | |
import json | |
import sys | |
import datetime | |
for filename in sys.argv[1:]: | |
with open(filename, 'r') as fh: | |
repo = re.split(r'/', filename)[-1] | |
raw = fh.read() | |
#print(raw) | |
try: | |
data = json.loads(raw) | |
for user in data: | |
login = user['author']['login'] | |
for week in user['weeks']: | |
a = week['a'] | |
d = week['d'] | |
c = week['c'] | |
epoch = week['w'] | |
week = datetime.datetime.fromtimestamp(epoch).strftime('%Y-%m-%d') | |
print(f"{login}\t{repo}\t{week}\t{a}\t{d}\t{c}") | |
except Exception as e: | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment