diff options
author | Agustin Zubiaga <aguz@sugarlabs.org> | 2012-02-16 20:25:54 (GMT) |
---|---|---|
committer | Agustin Zubiaga <aguz@sugarlabs.org> | 2012-02-16 20:25:54 (GMT) |
commit | 8f5ff158f85d470644c0b3f04e66230b4a3ed994 (patch) | |
tree | d6d614765cc585ef6794af50e403cdf428542346 /activity.py | |
parent | 7b1c84065d4ad2d16b02fb4fe9e024965dd69fad (diff) |
Code fixes
Signed-off-by: Agustin Zubiaga <aguz@sugarlabs.org>
Diffstat (limited to 'activity.py')
-rw-r--r-- | activity.py | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/activity.py b/activity.py index ee445ce..87d0624 100644 --- a/activity.py +++ b/activity.py @@ -47,8 +47,8 @@ from sugar.graphics.alert import Alert from sugar.datastore import datastore from charts import Chart -from readers import StopWatch -from readers import Measure +from readers import StopWatchReader +from readers import MeasureReader def rgb_to_html(color): @@ -456,7 +456,7 @@ class SimpleGraph(activity.Activity): def _object_chooser(self, mime_type, type_name): chooser = ObjectChooser() - boolean = False + matches_mime_type = False response = chooser.run() if response == gtk.RESPONSE_ACCEPT: @@ -465,7 +465,7 @@ class SimpleGraph(activity.Activity): file_path = jobject.file_path if metadata['mime_type'] == mime_type: - boolean = True + matches_mime_type = True else: alert = Alert() @@ -484,36 +484,26 @@ class SimpleGraph(activity.Activity): alert.show() - return boolean, file_path, metadata['title'] + return matches_mime_type, file_path, metadata['title'] def __import_stopwatch_cb(self, widget): - boolean, file_path, title = self._object_chooser( + matches_mime_type, file_path, title = self._object_chooser( STOPWATCH_MIME_TYPE, _('StopWatch')) - if boolean: + if matches_mime_type: f = open(file_path) - reader = StopWatch(f) - - stopwatchs_list, count = reader.get_stopwatchs_with_marks() + reader = StopWatchReader(f) self.labels_and_values.model.clear() self.chart_data = [] - self.v_label.entry.set_text(_('Time')) - - if count == 1: - num, name = stopwatchs_list[0] - self.h_label.entry.set_text(_('Mark')) - - self.set_title(name) - chart_data = reader.marks_to_chart_data(num - 1) + chart_data = reader.get_chart_data() - elif count == 0 or count > 1: - self.set_title(title) - self.h_label.entry.set_text(_('StopWatch')) + h, v = reader.get_labels_name() - chart_data = reader.times_to_chart_data() + self.v_label.entry.set_text(h) + self.h_label.entry.set_text(v) # Load the data for row in chart_data: @@ -525,15 +515,18 @@ class SimpleGraph(activity.Activity): f.close() def __import_measure_cb(self, widget): - boolean, file_path, title = self._object_chooser(CSV_MIME_TYPE, + matches_mime_type, file_path, title = self._object_chooser( + CSV_MIME_TYPE, _('Measure')) - if boolean: + if matches_mime_type: f = open(file_path) - reader = Measure(f) + reader = MeasureReader(f) + + h, v = reader.get_labels_name() - self.v_label.entry.set_text(_('Values')) - self.h_label.entry.set_text(_('Samples')) + self.v_label.entry.set_text(h) + self.h_label.entry.set_text(v) self.chart_data = [] self.labels_and_values.model.clear() |