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
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# readers.py by:
# Agustin Zubiaga <aguz@sugarlabs.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import cPickle
import csv
class StopWatch():
def __init__(self, data):
self._data = cPickle.load(data)
def get_stopwatchs_with_marks(self):
count = 0
stopwatchs_list = []
for i in self._data[-1]:
if i:
count += 1
stopwatchs_list.append([count, self._data[1][count - 1]])
return stopwatchs_list, count
def get_stopwatch_name(self, num=0):
return self._data[1][num]
def marks_to_chart_data(self, num=0, chart_data=[]):
marks_count = 0
marks = self._data[-1][num]
marks.sort()
for i in marks:
marks_count += 1
chart_data.append((str(marks_count), round(i, 2)))
return chart_data
def times_to_chart_data(self):
times = [i[0][0] for i in self._data[2]]
times_count = 0
chart_data = []
for i in times:
times_count += 1
chart_data.append((self.get_stopwatch_name(times_count - 1),
round(i, 2)))
return chart_data
class Measure():
def __init__(self, data):
self._reader = csv.reader(data)
def get_chart_data(self):
count = 0
chart_data = []
for row in self._reader:
count += 1
if count > 6:
label, value = row[0].split(": ")
chart_data.append((label, float(value)))
return chart_data
|