24 lines
1.1 KiB
Python
24 lines
1.1 KiB
Python
# From a match.py output: labels with no overlapping event of their own family, grouped by family, with their duration in h and the other events seen. Args: match.txt
|
|||
|
|
import sys, re
|
||
|
|
from datetime import datetime
|
||
|
|
cur, rows = None, []
|
||
|
|
for line in open(sys.argv[1]):
|
||
|
|
if line.startswith("#"):
|
||
|
|
break
|
||
|
|
m = re.match(r"(\S+) (\S+)→(\S+) \[(.+)\]", line)
|
||
|
|
if m:
|
||
|
|
cur = [m.group(1), m.group(2), m.group(3), m.group(4), [], False]
|
||
|
|
rows.append(cur)
|
||
|
|
elif cur and line.strip():
|
||
|
|
cur[4].append(line.strip())
|
||
|
|
cur[5] |= line.strip().startswith("=")
|
||
|
|
def h(a, b):
|
||
|
|
f = lambda s: datetime.strptime(s, "%Y-%m-%dT%H:%MZ")
|
||
|
|
return (f(b) - f(a)).total_seconds() / 3600
|
||
|
|
fams = sorted({r[3] for r in rows})
|
||
|
|
for fam in fams:
|
||
|
|
miss = [r for r in rows if r[3] == fam and not r[5]]
|
||
|
|
tot = [r for r in rows if r[3] == fam]
|
||
|
|
print(f"## {fam}: {len(miss)} of {len(tot)} labels without an event of the family, {sum(h(r[1], r[2]) for r in miss):.0f} h")
|
||
|
|
for r in miss:
|
||
|
|
print(f" {r[0]} {r[1]}→{r[2]} ({h(r[1], r[2]):.1f} h) : {' | '.join(x[2:60] for x in r[4][:3])}")
|