#default_exp ghtop
API details
#export
import sys, signal, shutil, os, json, emoji, enlighten
from dashing import *
from collections import defaultdict, Counter
from warnings import warn
from itertools import islice
from fastcore.utils import *
from fastcore.foundation import *
from fastcore.script import *
from ghapi.all import *
from rich.console import Console
from rich.style import Style
#export
term = Terminal() #TODO Remove when done transitioning to Rich
console = Console()
#export
def github_auth_device(wb='', n_polls=9999):
"Authenticate with GitHub, polling up to `n_polls` times to wait for completion"
auth = GhDeviceAuth()
print(f"First copy your one-time code: {term.yellow}{auth.user_code}{term.normal}")
print(f"Then visit {auth.verification_uri} in your browser, and paste the code when prompted.")
if not wb: wb = input("Shall we try to open the link for you? [y/n] ")
if wb[0].lower()=='y': auth.open_browser()
print("Waiting for authorization...", end='')
token = auth.wait(lambda: print('.', end=''), n_polls=n_polls)
if not token: return print('Authentication not complete!')
print("Authenticated with GitHub")
return token
When we run this we'll be shown a URL to visit and a code to enter in order to authenticate. Normally we'll be prompted to open a browser, and the function will wait for authentication to complete -- for demonstrating here we'll skip both of these steps:
github_auth_device('n',n_polls=0)
First copy your one-time code: DC25-7D48
Then visit https://github.com/login/device in your browser, and paste the code when prompted.
Waiting for authorization...Authentication not complete!
#export
def _exit(msg):
print(msg, file=sys.stderr)
sys.exit()
#exports
def limit_cb(rem,quota):
"Callback to warn user when close to using up hourly quota"
w='WARNING '*7
if rem < 1000: print(f"{w}\nRemaining calls: {rem} out of {quota}\n{w}", file=sys.stderr)
When creating GhApi we can pass a callback which will be called after each API operation. In this case, we use it to warn the user when their quota is getting low.
#export
Events = dict(
IssuesEvent_closed=('⭐', 'closed', noop),
IssuesEvent_opened=('📫', 'opened', noop),
IssueCommentEvent=('💬', 'commented on', term.white),
PullRequestEvent_opened=('✨', 'opened a pull request', term.yellow),
PullRequestEvent_closed=('✔', 'closed a pull request', term.green),
)
#export
def _to_log(e):
login,repo,pay = e.actor.login,e.repo.name,e.payload
typ = e.type + (f'_{pay.action}' if e.type in ('PullRequestEvent','IssuesEvent') else '')
emoji,msg,color = Events.get(typ, [0]*3)
if emoji:
xtra = '' if e.type == "PullRequestEvent" else f' issue # {pay.issue.number}'
d = try_attrs(pay, "pull_request", "issue")
return color(f'{emoji} {login} {msg}{xtra} on repo {repo[:20]} ("{d.title[:50]}...")')
elif e.type == "ReleaseEvent": return f'🚀 {login} released {e.payload.release.tag_name} of {repo}'
#export
def print_event(e, counter):
res = _to_log(e)
if res: print(res)
elif counter and e.type == "PushEvent": [counter.update() for c in e.payload.commits]
elif e.type == "SecurityAdvisoryEvent": print(term.blink("SECURITY ADVISORY"))
We can pretty print a selection of event types using print_event, e.g:
#Hamel
Events = dict(
IssuesEvent_closed=('⭐', 'closed', Style(color='default')),
IssuesEvent_opened=('📫', 'opened', Style(color='default')),
IssueCommentEvent=('💬', 'commented on', Style(color='white')),
PullRequestEvent_opened=('✨', 'opened a pull request', Style(color='yellow')),
PullRequestEvent_closed=('✔', 'closed a pull request', Style(color='green')),
SecurityAdvisoryEvent=('', 'SECURITY ADVISORY', Style(color='red', blink=True))
)
def _to_log(e):
login,repo,pay = e.actor.login,e.repo.name,e.payload
typ = e.type + (f'_{pay.action}' if e.type in ('PullRequestEvent','IssuesEvent') else '')
emoji,msg,style = Events.get(typ, ['','',Style(color='default')])
if emoji:
xtra = '' if e.type == "PullRequestEvent" else f' issue # {pay.issue.number}'
d = try_attrs(pay, "pull_request", "issue")
msg=f'{emoji} {login} {msg}{xtra} on repo {repo[:20]} ("{d.title[:50]}...")'.strip()
elif e.type == "ReleaseEvent": msg = f'🚀 {login} released {e.payload.release.tag_name} of {repo}'
return msg, style
class RichEvent:
def __init__(self, e):
self.ev=e
self.msg, self.style = _to_log(self.ev)
def __rich__(self): return self.msg
def print_event(e:RichEvent, counter):
if e.msg: console.print(e, style=e.style, highlight=False)
elif counter and e.ev.type == "PushEvent": counter.update({'commits':len(e.ev.payload.commits)})
evts = load_sample_events().map(RichEvent)
for e in evts[:100]: print_event(e,None)
✔ Didier-D-crypto closed a pull request on repo Didier-D-crypto/Empl ("Bump ini from 1.3.5 to 1.3.8...")
💬 Holzhaus commented on issue # 168 on repo mixxxdj/website ("Site of mixxx is out...")
💬 reaperrr commented on issue # 18828 on repo OpenRA/OpenRA ("InvalidDataException: nuyell1.aud is not a valid s...")
✨ fantommohammed opened a pull request on repo fantommohammed/Mu-lt ("Begin...")
💬 0pdd commented on issue # 2 on repo proofit404/cruftbot ("Initialize Django project....")
✨ dependabot opened a pull request on repo Didier-D-crypto/Empl ("Bump dot-prop from 4.2.0 to 4.2.1...")
📫 oulasvirta opened issue # 11 on repo oulasvirta/write-git ("Title...")
✔ pull closed a pull request on repo sgrayban/github-read (" master from anuraghazra:master...")
✨ dseo3 opened a pull request on repo dseo3/GroupProject_T ("Populating data inside of bookmark...")
✨ snyk-bot opened a pull request on repo BlueCC8/iot-simulato ("[Snyk] Security upgrade mongoose from 5.4.11 to 5....")
✔ realpaliy closed a pull request on repo realpaliy/Messenger ("Update SharedMediaVC.swift...")
✨ schancel opened a pull request on repo cashweb/stamp ("Ensure capacitor adds toolbar space...")
💬 zjklee commented on issue # 407 on repo Handlebars-Net/Handl ("Template compilation seems slower with 2.0...")
📫 ThomVivet opened issue # 452 on repo sahib/rmlint ("Documentation: clarification about the -C / --xatt...")
✨ GeertvanHorrik opened a pull request on repo WildGums/Orchestra ("GitHubSync update...")
💬 bodhish commented on issue # 9 on repo jcsherin/package-tod ("Todo CLI in Java...")
#export
#TODO display commit count to the terminal!!
def tail_events(evt):
"Print events from `fetch_events` along with a counter of push events"
c = Counter({'commits':0})
for ev in evt: print_event(ev, c)
tail_events(evts)
✔ Didier-D-crypto closed a pull request on repo Didier-D-crypto/Empl ("Bump ini from 1.3.5 to 1.3.8...")
💬 Holzhaus commented on issue # 168 on repo mixxxdj/website ("Site of mixxx is out...")
💬 reaperrr commented on issue # 18828 on repo OpenRA/OpenRA ("InvalidDataException: nuyell1.aud is not a valid s...")
✨ fantommohammed opened a pull request on repo fantommohammed/Mu-lt ("Begin...")
💬 0pdd commented on issue # 2 on repo proofit404/cruftbot ("Initialize Django project....")
✨ dependabot opened a pull request on repo Didier-D-crypto/Empl ("Bump dot-prop from 4.2.0 to 4.2.1...")
📫 oulasvirta opened issue # 11 on repo oulasvirta/write-git ("Title...")
✔ pull closed a pull request on repo sgrayban/github-read (" master from anuraghazra:master...")
✨ dseo3 opened a pull request on repo dseo3/GroupProject_T ("Populating data inside of bookmark...")
✨ snyk-bot opened a pull request on repo BlueCC8/iot-simulato ("[Snyk] Security upgrade mongoose from 5.4.11 to 5....")
✔ realpaliy closed a pull request on repo realpaliy/Messenger ("Update SharedMediaVC.swift...")
✨ schancel opened a pull request on repo cashweb/stamp ("Ensure capacitor adds toolbar space...")
💬 zjklee commented on issue # 407 on repo Handlebars-Net/Handl ("Template compilation seems slower with 2.0...")
📫 ThomVivet opened issue # 452 on repo sahib/rmlint ("Documentation: clarification about the -C / --xatt...")
✨ GeertvanHorrik opened a pull request on repo WildGums/Orchestra ("GitHubSync update...")
💬 bodhish commented on issue # 9 on repo jcsherin/package-tod ("Todo CLI in Java...")
✔ realpaliy closed a pull request on repo realpaliy/Messenger ("Update SharedMediaVC.swift...")
⭐ diddledan closed issue # 5 on repo diddlesnaps/openttd ("In game music does not play (Ubuntu / Snap version...")
✔ Quinnvanderschaar2 closed a pull request on repo Quinnvanderschaar2/B ("Development...")
💬 jef commented on issue # 1388 on repo jef/streetmerchant ("feat(proxies): Fallback to a global proxy list...")
📫 aisaioop opened issue # 1597 on repo aisaioop/yzevgyqigd ("福泉代开怀孕流产证明,B超单/做开诊断证明〖╅微2979194412〗...")
💬 twostraws commented on issue # 34667 on repo apple/swift ("Replace many instances of sanity, sane, and insane...")
✨ vuphuongha opened a pull request on repo DickinsonCollege/Far ("Change to correct link...")
💬 Roguinaa commented on issue # 262 on repo kevinclement/SimpleA ("Every Single Incorrect Mount Icon...")
✨ ghys opened a pull request on repo openhab/openhab-webu ("[Main UI/HABPanel] Mobile app interface, part 2...")
📫 github-learning-lab opened issue # 1 on repo pg45/markdown-portfo ("Getting Started with GitHub...")
💬 ljwagerfield commented on issue # 743 on repo lukeautry/tsoa ("Bundle with webpack for MonoRepo scenario...")
✨ JlchavezG opened a pull request on repo JlchavezG/Psbg ("Se agregan notificaciones...")
💬 github-learning-lab commented on issue # 1 on repo pg45/markdown-portfo ("Getting Started with GitHub...")
✔ GeertvanHorrik closed a pull request on repo WildGums/Orchestra ("GitHubSync update...")
💬 timashvayko9 commented on issue # 82 on repo Mikhail-M12/AiSD_938 ("lab3 - Balaeva...")
💬 ThomasWaldmann commented on issue # 257 on repo bepasty/bepasty-serv ("Errors & unsuccessful install following Installati...")
✨ mnxn opened a pull request on repo ocaml/opam-repositor (" jsonoo (0.2.1)...")
💬 trybe-evaluation-feedback commented on issue # 31 on repo tryber/sd-08-project ("Iniciando o projeto shopping cart...")
💬 sagemaker-bot commented on issue # 413 on repo aws/sagemaker-tensor ("change: include granular buildspecs for dlc and ge...")
✔ pull closed a pull request on repo rockonedege/javascri (" master from javascript-tutorial:master...")
💬 anirbank91 commented on issue # 42 on repo civictechindex/CTI-w ("Create Tag generator page...")
✨ al-lac opened a pull request on repo microsoft/winget-pkg ("Add GOG Galaxy 2.0.30.20...")
💬 sonarcloud commented on issue # 2 on repo turkdevops/acmephp (" master from acmephp:master...")
✨ OanaTudu opened a pull request on repo OanaTudu/Covid19 ("Add files via upload...")
📫 NillerMedDild opened issue # 3 on repo gigabit101/Shrink ("[Request] Don't print debug information when right...")
💬 m1dark commented on issue # 205 on repo ArugaZ/whatsapp-bot ("ADD SEARCH GOOGLE...")
✔ pull closed a pull request on repo kaycoinsUSA/pandoc (" master from jgm:master...")
✔ schancel closed a pull request on repo cashweb/stamp ("Ensure capacitor adds toolbar space...")
💬 t-bast commented on issue # 123 on repo ACINQ/phoenix ("No route for incoming payment...")
💬 RJVB commented on issue # 37 on repo RJVB/afsctool ("Compile errors - any ideas?...")
✔ dseo3 closed a pull request on repo dseo3/GroupProject_T ("Populating data inside of bookmark...")
📫 lucasfarias300 opened issue # 2 on repo lucasfarias300/githu ("Issue test...")
✨ recpi2008 opened a pull request on repo recpi2008/HW_MYSQL ("add hw_les_6...")
✨ Enrique325 opened a pull request on repo Edwin-Lines/Proyecto ("Update Recursos Materiales.md...")
📫 jabolopes opened issue # 44 on repo lafriks/go-tiled ("Possible width and height swapped?...")
📫 aisaioop opened issue # 1598 on repo aisaioop/yzevgyqigd ("北京通州区代开怀孕流产证明,B超单/做开诊断证明〖╅微2979194412〗...")
✨ pull opened a pull request on repo Alan-love/bgfx (" master from bkaradzic:master...")
✨ rmi7 opened a pull request on repo crytic/slither ("fix set `self.filename` when using crytic-compile...")
💬 zdenkotraste commented on issue # 2 on repo zdenkotraste/K8s-vir ("Dev...")
📫 jonathannaguin opened issue # 23 on repo navikt/mock-oauth2-s ("Access OAuth request body...")
💬 wingetbot commented on issue # 5481 on repo microsoft/winget-pkg ("Add GOG Galaxy 2.0.30.20...")
✔ JlchavezG closed a pull request on repo JlchavezG/Psbg ("Se agregan notificaciones...")
✔ Bod9001 closed a pull request on repo unitystation/unityst ("Adds basic item and object wrapping...")
✔ fantommohammed closed a pull request on repo fantommohammed/Mu-lt ("Begin...")
✔ TrueBrain closed a pull request on repo OpenTTD/OpenTTD ("Fix: [Actions] cleanup ci-build workflow to be up-...")
✔ varund7726 closed a pull request on repo ResurrectionRemix/an ("Update Greek translations...")
💬 X9VoiD commented on issue # 437 on repo InfinityGhost/OpenTa ("Add support for XP-Pen Star 06C...")
✨ Mooooooov opened a pull request on repo estartando-devs/Busq ("Feature/cadastromodal...")
✨ AlexandraLarisaa opened a pull request on repo AlexandraLarisaa/Pro ("Actualizare-clasa-Crawler...")
💬 jwilling commented on issue # 18 on repo itavero/homebridge-z ("Refactor code + use new exposes info provided by z...")
💬 Rost1116 commented on issue # 163 on repo ahodges9/LedFx ("(WinError 10065) An attempt was made to perform a ...")
💬 sagemaker-bot commented on issue # 413 on repo aws/sagemaker-tensor ("change: include granular buildspecs for dlc and ge...")
✔ pull closed a pull request on repo Alan-love/bgfx (" master from bkaradzic:master...")
✨ pull opened a pull request on repo earnrising/home-assi (" dev from home-assistant:dev...")
✔ OanaTudu closed a pull request on repo OanaTudu/Covid19 ("Add files via upload...")
✔ alexei-sintotski closed a pull request on repo alexei-sintotski/pub ("Check code with recent dart linter rules...")
💬 YoraeRasante commented on issue # 6782 on repo Monika-After-Story/M ("My Old Monika...")
✔ bodhish closed a pull request on repo jcsherin/package-tod ("Todo CLI in Java...")
✨ dependabot-preview opened a pull request on repo mongodb-js/compass-q ("build(deps-dev): bump sinon from 8.1.1 to 9.2.2...")
✨ Jandeh7 opened a pull request on repo maura-dev/i2talk-rea ("Form changes...")
💬 github-actions commented on issue # 11 on repo oulasvirta/write-git ("Title...")
✔ zdenkotraste closed a pull request on repo zdenkotraste/K8s-vir ("Dev...")
✔ swatso2020 closed a pull request on repo swatso2020/Project3 ("Thalia...")
💬 mlenser commented on issue # 643 on repo mlenser/kryx-rpg-iss ("Restoration and Heal do the same thing...")
💬 Filco306 commented on issue # 549 on repo giotto-ai/giotto-tda ("[BUG] Parameters for functions in Mapper pipeline ...")
✨ pull opened a pull request on repo Mu-L/bevy (" master from bevyengine:master...")
💬 dependabot-preview commented on issue # 192 on repo mongodb-js/compass-q ("build(deps-dev): bump sinon from 8.1.1 to 9.2.1...")
📫 aisaioop opened issue # 1599 on repo aisaioop/yzevgyqigd ("上海黄浦区代开怀孕流产证明,B超单/做开诊断证明〖╅微2979194412〗...")
💬 github-actions commented on issue # 4 on repo kshyk/a-qa ("[Snyk] Fix for 1 vulnerabilities...")
✔ dependabot-preview closed a pull request on repo mongodb-js/compass-q ("build(deps-dev): bump sinon from 8.1.1 to 9.2.1...")
📫 helmrich opened issue # 27 on repo vinceliuice/WhiteSur ("Spotify Icon not working...")
💬 rusefillc commented on issue # 2065 on repo rusefi/rusefi ("MRE issue with tle8888 - GP3 does not work?...")
🚀 github-actions released 20304 of Anuken/MindustryBuilds
✨ atodorov opened a pull request on repo kiwitcms/Kiwi ("Remove CsrfDisableMiddleware. Closes #297...")
✨ jesus-santamarca opened a pull request on repo toastmxIT/brandline- ("Add Page Edit...")
✔ pull closed a pull request on repo Mu-L/bevy (" master from bevyengine:master...")
💬 PN-Cryptid commented on issue # 277 on repo ProjectNelth/BugTrac ("[List] Twin Peaks...")
💬 oulasvirta commented on issue # 11 on repo oulasvirta/write-git ("Title...")
💬 eriksvedang commented on issue # 902 on repo carp-lang/Carp ("Unify languages...")
🚀 iDeagan released 0.1 of iDeagan/Duels-Winstreak-RichPresence
💬 clickysteve commented on issue # 512 on repo polyend/TrackerIssue ("[1.3.0b3] Export Song Stems - Various Issues inclu...")
✨ Chramox opened a pull request on repo Chramox/tytus ("Update...")
✔ Didier-D-crypto closed a pull request on repo Didier-D-crypto/Empl ("Bump lodash from 4.17.15 to 4.17.19...")
💬 WarrenWeckesser commented on issue # 9999 on repo scipy/scipy ("BUG: malloc() calls in Cython and C that are not c...")
💬 digitaldan commented on issue # 9347 on repo openhab/openhab-addo ("[WIP] MyQ Initial commit of the MyQ binding for OH...")
✔ pull closed a pull request on repo earnrising/home-assi (" dev from home-assistant:dev...")
💬 azure-pipelines commented on issue # 5481 on repo microsoft/winget-pkg ("Add GOG Galaxy 2.0.30.20...")
✔ Edmon999 closed a pull request on repo Edmon999/react_homew ("Homework19 21...")
💬 jrlanglois commented on issue # 145 on repo nick-thompson/bluepr ("EcmascriptEngine Duktape Pimpl...")
💬 Dexy2811 commented on issue # 2551 on repo ValveSoftware/csgo-o ("CS:GO stuck in windowed mode...")
📫 github-actions opened issue # 204 on repo Sakzsee/Sakthisree ("Error updating notebooks...")
✔ Edmon999 closed a pull request on repo Edmon999/react_homew ("Edit task new fields...")
✨ pyup-bot opened a pull request on repo dayalannair/wireless ("Update wheel to 0.36.2...")
✨ DJTai opened a pull request on repo DJTai/hugo-theme-cac ("Update Fork with Main...")
✨ dependabot-preview opened a pull request on repo mongodb-js/compass-s ("Bump sinon from 8.1.1 to 9.2.2...")
📫 aisaioop opened issue # 1600 on repo aisaioop/yzevgyqigd ("北京门头沟区代开怀孕流产证明,B超单/做开诊断证明〖╅微2979194412〗...")
💬 pyup-bot commented on issue # 21 on repo dayalannair/wireless ("Update wheel to 0.36.1...")
✔ kelseyhuse30 closed a pull request on repo DiversityCorp/compan ("Bump ini from 1.3.5 to 1.3.8...")
✨ bmmunds opened a pull request on repo bmmunds/363Stroop ("Merging...")
✨ KimMead opened a pull request on repo learn-co-students/re ("Done...")
⭐ glutamate closed issue # 466 on repo saltcorn/saltcorn ("Forgotten tag "Authentication" for google-auth plu...")
💬 glutamate commented on issue # 466 on repo saltcorn/saltcorn ("Forgotten tag "Authentication" for google-auth plu...")
✨ snyk-bot opened a pull request on repo guypod/goof ("[Snyk] Security upgrade mongoose from 4.2.4 to 5.1...")
✔ pyup-bot closed a pull request on repo dayalannair/wireless ("Update wheel to 0.36.1...")
💬 dependabot-preview commented on issue # 139 on repo mongodb-js/compass-s ("Bump sinon from 8.1.1 to 9.2.1...")
✨ charlyhackr opened a pull request on repo charlyhackr/security ("Revert "Add wolverine octocat to game"...")
✔ dependabot-preview closed a pull request on repo mongodb-js/compass-s ("Bump sinon from 8.1.1 to 9.2.1...")
✔ Jandeh7 closed a pull request on repo maura-dev/i2talk-rea ("Form changes...")
✨ syntactic-salt opened a pull request on repo syntactic-salt/brows ("release pipeline...")
✔ Owlnofeathers closed a pull request on repo Owlnofeathers/discog ("Bump ini from 1.3.5 to 1.3.8...")
✨ tcoupin opened a pull request on repo rclone/rclone ("Feat webdav nextcloud chunked...")
✔ isamaues closed a pull request on repo JambuOverflow/lepic ("User management login navigation bug fixed...")
💬 m1dark commented on issue # 205 on repo ArugaZ/whatsapp-bot ("ADD SEARCH GOOGLE...")
📫 autocode-app opened issue # 79330 on repo imamandrews/imamandr ("https://giphy.com/gifs/69jy30PI6zPyK5vY2c @ImamAnd...")
✨ jcockbain opened a pull request on repo jcockbain/advent-of- ("Create go.yml...")
✔ kodiakhq closed a pull request on repo chdsbd/kodiak ("add(docs): docs for cut_body_before and cut_body_a...")
💬 okeeffdp commented on issue # 8064 on repo wbond/package_contro ("Added a language syntax for Snowflake SQL...")
✔ alexerlandsson closed a pull request on repo alexerlandsson/dice ("Bump ini from 1.3.5 to 1.3.8...")
⭐ sanskritbscs closed issue # 3 on repo sanskritbscs/memory ("something broken...")
💬 sanskritbscs commented on issue # 3 on repo sanskritbscs/memory ("something broken...")
💬 github-learning-lab commented on issue # 2 on repo pfxsys/github-slides ("Your first contribution...")
💬 moezzineb commented on issue # 72248 on repo flutter/flutter ("Undefined name 'ScaffoldMessenger'...")
💬 JustSlone commented on issue # 16181 on repo microsoft/fluentui ("Dropdown component should adjust his callout width...")
💬 codecov commented on issue # 231 on repo open-mmlab/mmdetecti ("fix indoor_eval in case of less classes in predict...")
📫 aisaioop opened issue # 1601 on repo aisaioop/yzevgyqigd ("上海宝山区代开怀孕流产证明,B超单/做开诊断证明〖╅微2979194412〗...")
✨ constanceferragu opened a pull request on repo lucienwalewski/Maths ("week 5 constance...")
💬 mightybart commented on issue # 41 on repo floriankarsten/space ("Greek alphabet...")
🚀 dellagustin released v1.32.1 of podStation/podStation
✨ jyshangguan opened a pull request on repo jyshangguan/MorphSED ("add image module...")
✔ Ryukishi closed a pull request on repo adibhanna/matthewkin ("Feature/preach page...")
✔ ahocevar closed a pull request on repo openlayers/openlayer ("Better getPointResolution default when no transfor...")
✨ snyk-bot opened a pull request on repo stelthdroid8/yelpCam ("[Snyk] Security upgrade mongoose from 5.5.12 to 5....")
✔ mennovanemmerik closed a pull request on repo Softimistic/Project- ("Ship Model Added...")
💬 Joulinar commented on issue # 3973 on repo MichaIng/DietPi ("Nextcloud no :4443 port and no nc-config...")
💬 9mm commented on issue # 72 on repo rubycdp/ferrum ("Is there any way I could use a proxy?...")
✔ Chramox closed a pull request on repo Chramox/tytus ("Update...")
💬 dependabot commented on issue # 3 on repo herzliya-space-labor ("Bump ini from 1.3.5 to 1.3.8 in /backend...")
💬 codepope commented on issue # 340 on repo superfly/flyctl ("GitHub Codespaces Install Incomplete...")
💬 poelzi commented on issue # 3197 on repo mixxxdj/mixxx ("Add colored console output...")
📫 slingamn opened issue # 1455 on repo oragono/oragono ("split manual into an operator manual and an end us...")
✔ gabriel-hahn closed a pull request on repo gabriel-hahn/react-n ("Bump @storybook/addon-essentials from 6.1.9 to 6.1...")
✨ distantnative opened a pull request on repo getkirby/getkirby.co ("Remove svgo...")
✨ pull opened a pull request on repo antosubash/OrchardCo (" dev from OrchardCMS:dev...")
💬 ethindp commented on issue # 134 on repo rust-osdev/bootloade ("Documentation...")
✔ yakirgot closed a pull request on repo yakirgot/snake ("chore(deps): bump ini from 1.3.5 to 1.3.8...")
✔ mergify closed a pull request on repo spbu-coding/6-Lev0ni ("Исправлены ошибки с памятью...")
💬 michaelforney commented on issue # 14 on repo oasislinux/oasis ("Switch to BearSSL...")
✔ dependabot closed a pull request on repo herzliya-space-labor ("Bump ini from 1.3.5 to 1.3.8 in /backend...")
💬 stale commented on issue # 1298 on repo ironhack-labs/lab-ex ("[RMT-FT-102020] - Pablo Berho y Sergio Ros...")
💬 awolf78 commented on issue # 82 on repo ImpulseRC/OSD ("Add support for NEO-M9N...")
Counter({'commits': 868})
#export
def _pr_row(*its): print(f"{its[0]: <30} {its[1]: <6} {its[2]: <5} {its[3]: <6} {its[4]: <7}")
def watch_users(evts):
"Print a table of the users with the most events"
users,users_events = defaultdict(int),defaultdict(lambda: defaultdict(int))
while True:
for x in islice(evts, 10):
users[x.actor.login] += 1
users_events[x.actor.login][x.type] += 1
print(term.clear())
_pr_row("User", "Events", "PRs", "Issues", "Pushes")
sorted_users = sorted(users.items(), key=lambda o: (o[1],o[0]), reverse=True)
for u in sorted_users[:20]:
_pr_row(*u, *itemgetter('PullRequestEvent','IssuesEvent','PushEvent')(users_events[u[0]]))
#export
def _push_to_log(e): return f"{e.actor.login} pushed {len(e.payload.commits)} commits to repo {e.repo.name}"
def _logwin(title,color): return Log(title=title,border_color=2,color=color)
def quad_logs(evts):
"Print 4 panels, showing most recent issues, commits, PRs, and releases"
term.enter_fullscreen()
ui = HSplit(VSplit(_logwin('Issues', color=7), _logwin('Commits' , color=3)),
VSplit(_logwin('Pull Requests', color=4), _logwin('Releases', color=5)))
issues,commits,prs,releases = all_items = ui.items[0].items+ui.items[1].items
for o in all_items: o.append(" ")
d = dict(PushEvent=commits, IssuesEvent=issues, IssueCommentEvent=issues, PullRequestEvent=prs, ReleaseEvent=releases)
while True:
for x in islice(evts, 10):
f = [_to_log,_push_to_log][x.type == 'PushEvent']
if x.type in d: d[x.type].append(f(x)[:95])
ui.display()
#export
def simple(evts):
for ev in evts: print(f"{ev.actor.login} {ev.type} {ev.repo.name}")
#export
def _get_token():
path = Path.home()/".ghtop_token"
if path.is_file():
try: return path.read_text().strip()
except: _exit("Error reading token")
else: token = github_auth_device()
path.write_text(token)
return token
#export
def _signal_handler(sig, frame):
if sig != signal.SIGINT: return
print(term.exit_fullscreen(),term.clear(),term.normal)
sys.exit(0)
_funcs = dict(tail=tail_events, quad=quad_logs, users=watch_users, simple=simple)
_filts = str_enum('_filts', 'user', 'repo', 'org')
_OpModes = str_enum('_OpModes', *_funcs)
@call_parse
def main(mode: Param("Operation mode to run", _OpModes),
include_bots: Param("Include bots (there's a lot of them!)", store_true)=False,
types: Param("Comma-separated types of event to include (e.g PushEvent)", str)='',
filt: Param("Filtering method", _filts)=None,
filtval: Param("Value to filter by (for `repo` use format `owner/repo`)", str)=None):
signal.signal(signal.SIGINT, _signal_handler)
types = types.split(',') if types else None
if filt and not filtval: _exit("Must pass `filter_value` if passing `filter_type`")
if filtval and not filt: _exit("Must pass `filter_type` if passing `filter_value`")
kwargs = {filt:filtval} if filt else {}
api = GhApi(limit_cb=limit_cb, token=_get_token())
evts = api.fetch_events(types=types, incl_bot=include_bots, **kwargs)
_funcs[mode](evts)
#hide
from nbdev.export import notebook2script
notebook2script()
Converted 00_ghtop.ipynb. Converted index.ipynb. Converted rich_test.ipynb.