generated from riscv-admin/template-group-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wbs2csv
executable file
·56 lines (46 loc) · 1.48 KB
/
wbs2csv
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
#!/bin/bash
# usage: wbs2csv < wbs.md > wbs.csv
normalize_time () {
if [[ $1 =~ ^([[:digit:]]+)([hdwm]) ]]; then
case ${BASH_REMATCH[2]} in
h) echo ${BASH_REMATCH[1]} ;;
d) echo $(( ${BASH_REMATCH[1]} * 8 )) ;;
w) echo $(( ${BASH_REMATCH[1]} * 5 * 8 )) ;;
m) echo $(( ${BASH_REMATCH[1]} * 4 * 5 * 8 )) ;;
esac
else
echo $1
fi
}
echo "\"element\",\"description\",\"dependencies\",\"owner\",\"optimistic\",\"expected\",\"pessimistic\",\"progress\""
while IFS= read line; do
element=""
description=""
dep=""
owner=""
optimistic=""
expected=""
pessimistic=""
progress=""
if [[ $line =~ ^([[:alnum:].-]+)[[:space:]]((:?[^=[]+[[:space:]]?)+)([[:space:]]|$) ]]; then
element="${BASH_REMATCH[1]}"
description="${BASH_REMATCH[2]}"
else
continue
fi
if [[ $line =~ [[:space:]][[]([0-9dwm]+),\ ([0-9dwm]+),\ ([0-9dwm]+)[]]([[:space:]]|$) ]]; then
optimistic="$(normalize_time ${BASH_REMATCH[1]})"
expected="$(normalize_time ${BASH_REMATCH[2]})"
pessimistic="$(normalize_time ${BASH_REMATCH[3]})"
fi
if [[ $line =~ dep=([[:alnum:].,-]+)([[:space:]]|$) ]]; then
dep="${BASH_REMATCH[1]}"
fi
if [[ $line =~ owner=([[:graph:]]+)([[:space:]]|$) ]]; then
owner="${BASH_REMATCH[1]}"
fi
if [[ $line =~ progress=([[:digit:]]+)%([[:space:]]|$) ]]; then
progress="${BASH_REMATCH[1]}"
fi
echo "\"$element\",\"$description\",\"$dep\",\"$owner\",\"$optimistic\",\"$expected\",\"$pessimistic\",\"$progress\""
done