summaryrefslogtreecommitdiff
path: root/scripts/chatlog.py
blob: 4e228abb69ecb67af841ad5b17ea4488d0021f4b (plain)
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
71
72
73
#! /usr/bin/env python3
#===============================
#
# chatlog
#
# 2019/12/23 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
#===============================
import sys
import os
import re
import glob

import base
#====================================
#
# log
#
#====================================
class log(base.base):

    #--------------------
    # show
    #--------------------
    def show(self):
        print("h1. Chat Log\n")
        print("<table>")

        current=""
        year=""
        dir = "wiki/Chat_log"
        tr = 0

        files = glob.glob("{}/{}/*-chatlog".format(self.top(), dir))
        files.sort(reverse=True)

        for file in files:
            name = os.path.basename(file)
            date = re.sub(r'(\d+)-\w*-.*', r'\1', name)

            y = date[0:4]
            if (year != y):
                if (year != ""):
                    print("\n</td>", end="")

                if (tr % 6 == 0):
                    if (year != ""):
                        print("</tr>")
                    print("<tr>")
                print("<td valign=\"top\">\n")
                year = y
                tr += 1
                print("h2. {}\n".format(year))
                print("|_. date|_. core|_. io|_. mm|")

            if (date != current):
                current = date

                print("|{}-{}-{}".format(year, date[4:6], date[6:8]), end="")
                for grp in ["core", "io", "mm"]:
                    print("|%s" %("\"{}\":../../{}/{}-{}-chatlog".format(grp, dir, date, grp)
                                    if "{}/{}/{}-{}-chatlog".format(self.top(), dir, date, grp) in files
                                    else ""), end="")
                print("|")

        print("\n</td></tr></table>")

#====================================
#
# As command
#
#====================================
if __name__=='__main__':
    log().show()