-
Notifications
You must be signed in to change notification settings - Fork 3
/
bars_creator.py
56 lines (50 loc) · 1.6 KB
/
bars_creator.py
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
from PIL import Image, ImageFont, ImageDraw, ImageEnhance
import re
def drawProgressBar(d, x, y, w, h, progress, bg="black", fg="green"):
# draw background
d.ellipse((x+w, y, x+h+w, y+h), fill=bg)
d.ellipse((x, y, x+h, y+h), fill=bg)
d.rectangle((x+(h/2), y, x+w+(h/2), y+h), fill=bg)
# draw progress bar
if progress == 0:
return d
w *= progress
d.ellipse((x+w, y, x+h+w, y+h),fill=fg)
d.ellipse((x, y, x+h, y+h),fill=fg)
d.rectangle((x+(h/2), y, x+w+(h/2), y+h),fill=fg)
return d
def create(fname, iname):
out = Image.new("RGBA", (400, 38), (255, 255, 255, 0))
Image.new
d = ImageDraw.Draw(out)
tested = 0
for line in open(fname):
match = re.search('Tested: (\d+)', line)
if match:
tested = int(match.group(1))
passing = 0
for line in open(fname):
match = re.search('Passing: (\d+)', line)
if match:
passing = int(match.group(1))
percent = 0
if tested != 0:
percent = passing / tested
d = drawProgressBar(d, 0, 0, 150, 38, percent)
out.save(iname)
def create_gcovr(fname, iname):
out = Image.new("RGBA", (200, 38), (255, 255, 255, 0))
Image.new
d = ImageDraw.Draw(out)
value = 0
for line in open(fname):
match = re.search('(\d+)%', line)
stot = re.search('TOTAL', line)
if match and stot:
value = int(match.group(1))
percent = value / 100
d = drawProgressBar(d, 0, 0, 150, 38, percent)
out.save(iname)
create("eca_sync", "tests.png")
create_gcovr("eca_lc", "lines.png")
create_gcovr("eca_lb", "branches.png")