import json todo_url = "https://todo.sr.ht/" git_url = "https://git.sr.ht/" #print(json.dumps(events, indent=4)) def show_ticket(ticket): assignees = [] for a in ticket['assignees']: assignees.append(a['canonical_name']) if ticket['submitter']['type'] == "user": submitter = ticket['submitter']['canonical_name'] elif ticket['submitter']['type'] == "email": submitter = ticket['submitter']['address'] else: submitter = ticket['submitter'] print(f"[{ticket['ref']}]") print() print(f" status: {ticket['status']}") print(f" resolution: {ticket['resolution']}") print(f" submitter: {submitter}") print(f" assigned: {assignees}") print(f" created: {ticket['created']}") print(f" updated: {ticket['updated']}") print(f" labels: {ticket['labels']}") print() print(ticket['title']) print() print(ticket['description']) def show_comments(events): print() for event in reversed(events): if "comment" not in event['event_type']: continue comment = event['comment'] submitter = comment['submitter']['canonical_name'] old_res = event['old_resolution'] new_res = event['new_resolution'] old_status = event['old_status'] new_status = event['new_status'] print(f"{comment['id']} {submitter} @ {comment['created']}") print(f"{old_status} -> {new_status}, {old_res} -> {new_res}") print(f" {comment['text']}") print() def show_tickets(tickets, closed): #print(json.dumps(tickets, indent=4)) for ticket in tickets: #tr_name = ticket['tracker']['name'] #tr_owner = ticket['tracker']['owner']['canonical_name'] #ticket_url = todo_url + tr_owner + "/" + tr_name + "/" + str(ticket['id']) if ticket['status'] == "resolved" and not closed: continue print(f"{ticket['id']}: {ticket['title']} ({ticket['status']})") #print(ticket_url) def show_trackers(trackers, verbose): for tracker in trackers: print(f"{tracker['id']} {tracker['name']}") if verbose: print(f"{todo_url}{tracker['owner']['canonical_name']}/{tracker['name']}") print(f" {tracker['description']}") print() def show_labels(labels): for label in labels: print(f"{label['name']}") def show_repos(repos, verbose): for repo in repos: print(f"{repo['id']} {repo['name']}") if verbose: print(f"{git_url}{repo['owner']['canonical_name']}/{repo['name']}") print(f" {repo['description']}") print()