Skip to content
Snippets Groups Projects
app-tech 3.50 KiB
#!/usr/bin/env python

from collections import Counter

import yaml
data = yaml.load(open('app-tech.yaml'))

class Person(object):
    def __init__(self, uname):
        self.uname = uname
        self.info = data['people'][uname]

    def name(self):
        return self.info['name']

    def md_linked_name(self):
        return '[' + self.name() + "](https://www.uib.no/user/uib/" + self.uname + ")"

class Service(object):
    def __init__(self, sname):
        self.sname = sname
        self.info = data['services'][sname]

    def name(self):
        name = self.info.get('name')
        if not name:
            url = self.info.get('url')
            if url:
                name = url
                import re
                name = re.sub(r'^https?://', '', name)
            else:
                name = self.sname.capitalize()
        return name

    def md_linked_name(self):
        res = self.name()
        url = self.info.get('url')
        if url:
            res  = '[' + res + '](' + url + ')'
        tk = self.info.get('tk')
        if tk:
            res += ' [📕](https://tk.app.uib.no/node/' + str(tk) + ')'
        project = self.info.get('project')
        if project:
            res += ' [🎯](' + project + ')'
        repo = self.info.get('repo')
        if repo:
            res += ' [🗄](' + repo + ')'
        return res

teams = data['teams']
for team in sorted(teams):
    people_tech = Counter()
    service_tech = Counter()

    print("# Team " + teams[team]['name'])
    print()
    print("People:\n")
    for person in map(Person, sorted(data['people'])):
        if person.info.get('team') != team:
            continue
        print("* " + '@' + person.uname + ' ' + person.md_linked_name())
        tech = person.info.get('tech')
        if tech:
            for t in tech:
                people_tech[t.split(' ')[1]] += 1
    print()

    print("Services:\n")
    found = False
    for svc in map(Service, sorted(data['services'])):
        if svc.info.get('team') != team:
            continue
        print("* " + svc.md_linked_name())
        found = True
        tech = svc.info.get('tech')
        if tech:
            for t in tech:
                service_tech[t] += 1
    if not found:
        print("* (None)")
    print()
    print("| Techology | People | Services |")
    print("|-----------|-------:|---------:|")
    for tech in people_tech + service_tech:
        print("| " + tech + " | " + str(people_tech[tech]) + " | " + str(service_tech[tech]) + " |")
    print()


people_tech = Counter()
service_tech = Counter()
print("# Teamless")
print()
print("People:\n")
for person in map(Person, sorted(data['people'])):
    if person.info.get('team'):
        continue
    print("* " + '@' + person.uname + ' ' + person.md_linked_name())
    tech = person.info.get('tech')
    if tech:
        for t in tech:
            people_tech[t.split(' ')[1]] += 1
print()

print("Services:\n")
found = False
for svc in map(Service, sorted(data['services'])):
    if svc.info.get('team'):
        continue
    print("* " + svc.md_linked_name())
    found = True
    tech = svc.info.get('tech')
    if tech:
        for t in tech:
            service_tech[t] += 1
if not found:
    print("* (None)")
print()

print()
print("| Techology | People | Services |")
print("|-----------|-------:|---------:|")
for tech in people_tech + service_tech:
    print("| " + tech + " | " + str(people_tech[tech]) + " | " + str(service_tech[tech]) + " |")
print()

if 0:
    print("\n# Data dump\n\n```")
    print(yaml.dump(data))
    print("```")