From aa1613217ccc988300a8fb77b9c9a8c7b06b57f2 Mon Sep 17 00:00:00 2001 From: Thomas Jourdan Date: Sun, 14 Feb 2010 16:59:54 +0000 Subject: clean up before release --- diff --git a/MANIFEST b/MANIFEST index 4fb910d..ebc8070 100644 --- a/MANIFEST +++ b/MANIFEST @@ -145,7 +145,6 @@ exon_buzzword.py exon_color.py exon_direction.py exon_position.py -htmltextview.py ka_controller.py ka_debug.py ka_extensionpoint.py diff --git a/NEWS b/NEWS index 6d42c48..9357ac8 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,14 @@ An introduction to Kandid can be found at sugarlabs.org . http://wiki.sugarlabs.org/go/Activities/Kandid +v4: February 2010 +Images generated by Kandid can be exported as PNG images to the journal. + You can open an exported image with an image manipulation program. +The details of a generated image can be explained. +Improving color scheme +Cancel obsolete rendering task during start up. + This may reduce time when starting from journal. + v3: January 2010 Some new views added to Kandid: Starting anew will show the 'Getting started' view. diff --git a/activity.py b/activity.py index 5b8d336..3c498c7 100644 --- a/activity.py +++ b/activity.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -20,7 +20,6 @@ from gettext import gettext as _ import gtk gtk.gdk.threads_init() import sys -import os import traceback import telepathy @@ -110,7 +109,7 @@ class KandidActivity(activity.Activity): # Buddy object for you found_buddies = set([]) try: - self.owner = self.pservice.get_owner() +#!! self.owner = self.pservice.get_owner() self.connect('shared', self._on_shared) self.connect('joined', self._on_joined) diff --git a/ep_buzzwordconstraint_sugar.py b/ep_buzzwordconstraint_sugar.py index e0e2e1b..9719068 100644 --- a/ep_buzzwordconstraint_sugar.py +++ b/ep_buzzwordconstraint_sugar.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ep_colorconstraint_bw.py b/ep_colorconstraint_bw.py index 5e09f8d..027795b 100644 --- a/ep_colorconstraint_bw.py +++ b/ep_colorconstraint_bw.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -61,6 +61,6 @@ class BwColorConstraint(model_locus.Locus): """Explain current values. pre: len(rgba) == 4 """ - part1 = 'black' if abs(rgba[0]) < EPSILON else 'white' - part2 = ', %d%% opaque' % (100*rgba[3]) if alpha else '' - return part1 + part2 + part1 = _('black') if abs(rgba[0]) < EPSILON else _('white') + part2 = _(', %d%% opaque') % (100*rgba[3]) if alpha else '' + return _('Color is reduced to black and white, ') + part1 + part2 diff --git a/ep_colorconstraint_gray.py b/ep_colorconstraint_gray.py index b074005..78c5902 100644 --- a/ep_colorconstraint_gray.py +++ b/ep_colorconstraint_gray.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -58,6 +58,6 @@ class GrayColorConstraint(model_locus.Locus): pre: len(rgba) == 4 """ if alpha: - return '%d%% gray, %d%% opaque' % (100*rgba[0], 100*rgba[3]) + return _('%d%% gray, %d%% opaque') % (100*rgba[0], 100*rgba[3]) else: - return '%d%% gray' % (100*rgba[0]) + return _('Color is reduced to shades of gray, %d%% gray') % (100*rgba[0]) diff --git a/ep_colorconstraint_none.py b/ep_colorconstraint_none.py index dc6cddd..753f865 100644 --- a/ep_colorconstraint_none.py +++ b/ep_colorconstraint_none.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -64,8 +64,8 @@ class NoneColorConstraint(model_locus.Locus): pre: len(rgba) == 4 """ if alpha: - return '%d%% red, %d%% green, %d%% blue, %d%% opaque' \ + return _('%d%% red, %d%% green, %d%% blue, %d%% opaque') \ % (100*rgba[0], 100*rgba[1], 100*rgba[2], 100*rgba[3]) else: - return '%d%% red, %d%% green, %d%% blue' \ + return _('%d%% red, %d%% green, %d%% blue') \ % (100*rgba[0], 100*rgba[1], 100*rgba[2]) diff --git a/ep_colorgamut_analogous.py b/ep_colorgamut_analogous.py index 8d48004..f88c795 100644 --- a/ep_colorgamut_analogous.py +++ b/ep_colorgamut_analogous.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -75,7 +75,7 @@ class AnalogousColorGamut(model_locus.Locus): color.rgba = (rgb[0], rgb[1], rgb[2], rgba[3]) def explain(self, formater): - formater.text_item('Analogous color scheme') + formater.text_item(_('Analogous color scheme')) def copy(self): """The AnalogousColorGamut copy constructor diff --git a/ep_colorgamut_complement.py b/ep_colorgamut_complement.py index bff2334..720ef9f 100644 --- a/ep_colorgamut_complement.py +++ b/ep_colorgamut_complement.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -70,7 +70,7 @@ class ComplementaryColorGamut(model_locus.Locus): color.rgba = (rgb[0], rgb[1], rgb[2], rgba[3]) def explain(self, formater): - formater.text_item('Complementary color scheme') + formater.text_item(_('Complementary color scheme')) def copy(self): """The ComplementaryColorGamut copy constructor diff --git a/ep_colorgamut_monchrome.py b/ep_colorgamut_monchrome.py index 8bef90b..2dc4b9e 100644 --- a/ep_colorgamut_monchrome.py +++ b/ep_colorgamut_monchrome.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -"""Extension point for color constraints. -This module handles a continuous red, green, blue and alpha color space.""" - import random import colorsys import model_random @@ -69,7 +66,7 @@ class MonochromeColorGamut(model_locus.Locus): color.rgba = (rgb[0], rgb[1], rgb[2], rgba[3]) def explain(self, formater): - formater.text_item('Monochromatic color scheme') + formater.text_item(_('Monochromatic color scheme')) def copy(self): """The MonochromeColorGamut copy constructor diff --git a/ep_colorgamut_splitcomplementary.py b/ep_colorgamut_splitcomplementary.py index 4ef3cc0..6efb5dc 100644 --- a/ep_colorgamut_splitcomplementary.py +++ b/ep_colorgamut_splitcomplementary.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -75,7 +75,7 @@ class SplitComplementaryColorGamut(model_locus.Locus): color.rgba = (rgb[0], rgb[1], rgb[2], rgba[3]) def explain(self, formater): - formater.text_item('Split complementary color scheme') + formater.text_item(_('Split complementary color scheme')) def copy(self): """The SplitComplementaryColorGamut copy constructor diff --git a/ep_colorgamut_triadic.py b/ep_colorgamut_triadic.py index 222e49d..77025b5 100644 --- a/ep_colorgamut_triadic.py +++ b/ep_colorgamut_triadic.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -74,7 +74,7 @@ class TriadicColorGamut(model_locus.Locus): color.rgba = (rgb[0], rgb[1], rgb[2], rgba[3]) def explain(self, formater): - formater.text_item('Triadic color scheme') + formater.text_item(_('Triadic color scheme')) def copy(self): """The TriadicColorGamut copy constructor diff --git a/ep_directionconstraint_vector.py b/ep_directionconstraint_vector.py index fc8a727..16793ec 100644 --- a/ep_directionconstraint_vector.py +++ b/ep_directionconstraint_vector.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ep_exporter_png.py b/ep_exporter_png.py index 7fd2ed2..4404153 100644 --- a/ep_exporter_png.py +++ b/ep_exporter_png.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ep_formater_html.py b/ep_formater_html.py index 232f1a1..471c5a2 100644 --- a/ep_formater_html.py +++ b/ep_formater_html.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ep_layer_filledspline.py b/ep_layer_filledspline.py index a006ded..06ccd9f 100644 --- a/ep_layer_filledspline.py +++ b/ep_layer_filledspline.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -203,18 +203,20 @@ class FilledSpline(model_layer.Layer): ctx.stroke() def explain(self, formater): + formater.begin_list(_('Layer ') + self.__class__.__name__) super(FilledSpline, self).explain(formater) self.colorgamut.explain(formater) - formater.color_item(self.linecolor, 'line color:') - formater.text_item('line width: ' + str(self.line_width)) - formater.text_item('roundness: ' + str(self.roundness)) - formater.color_item(self.fillcolor, 'fill color:') - formater.position_item(self.center, 'center:') + formater.color_item(self.linecolor, _('line color:')) + formater.text_item(_('line width: ') + str(self.line_width)) + formater.text_item(_('roundness: ') + str(self.roundness)) + formater.color_item(self.fillcolor, _('fill color:')) + formater.position_item(self.center, _('center:')) text, surface, descr = self.sampler.explain() if surface is not None: - formater.surface_item(surface, 'sampling points: ' + text, descr) + formater.surface_item(surface, _('sampling points: ') + text, descr) else: formater.text_item(text) + formater.end_list() def copy(self): """The FilledSpline diagram layers copy constructor. diff --git a/ep_layer_letterpress.py b/ep_layer_letterpress.py index d3c793c..e625eaa 100644 --- a/ep_layer_letterpress.py +++ b/ep_layer_letterpress.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -225,19 +225,21 @@ class LetterPress(model_layer.Layer): traceback.print_exc(file=sys.__stderr__) def explain(self, formater): + formater.begin_list(_('Layer ') + self.__class__.__name__) super(LetterPress, self).explain(formater) - formater.text_list('buzzwords: ', self.buzzwords.wordlist) - formater.color_item(self.textcolor, 'text color:') - formater.text_item('Font: ' + self.family + formater.text_list(_('buzzwords: '), self.buzzwords.wordlist) + formater.color_item(self.textcolor, _('text color:')) + formater.text_item(_('Font: ') + self.family + ', ' + LetterPress.font_style[self.style] + ', ' + str(self.size) + ', ' + str(self.weight)) - formater.position_item(self.center, 'center:') + formater.position_item(self.center, _('center:')) text, surface, descr = self.sampler.explain() if surface is not None: - formater.surface_item(surface, 'sampling points: ' + text, descr) + formater.surface_item(surface, _('sampling points: ') + text, descr) else: formater.text_item(text) + formater.end_list() def copy(self): """The LetterPress diagram layers copy constructor. diff --git a/ep_layer_markovchain.py b/ep_layer_markovchain.py index b30591b..6b07c42 100644 --- a/ep_layer_markovchain.py +++ b/ep_layer_markovchain.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -289,20 +289,22 @@ class MarkovChainLayer(model_layer.Layer): return next_cell_state def explain(self, formater): + formater.begin_list(_('Layer ') + self.__class__.__name__) super(MarkovChainLayer, self).explain(formater) self.colorgamut.explain(formater) - formater.color_array(self.cell_colors, 'cell colors:') - formater.text_item('number of states: ' + str(self.states)) + formater.color_array(self.cell_colors, _('cell colors:')) + formater.text_item(_('number of states: ') + str(self.states)) text, surface, descr = self.sampler.explain() if surface is not None: - formater.surface_item(surface, 'sampling points: ' + text, descr) + formater.surface_item(surface, _('sampling points: ') + text, descr) else: formater.text_item(text) text, surface, descr = self.stamp.explain() if surface is not None: - formater.surface_item(surface, 'stamp: ' + text, descr) + formater.surface_item(surface, _('stamp: ') + text, descr) else: formater.text_item(text) + formater.end_list() def copy(self): """The Markov chain layer copy constructor diff --git a/ep_layer_voronoidiagram.py b/ep_layer_voronoidiagram.py index 1cc586e..48697b4 100644 --- a/ep_layer_voronoidiagram.py +++ b/ep_layer_voronoidiagram.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -271,23 +271,25 @@ class VoronoiDiagramLayer(model_layer.Layer): # return dx if dx > dy else dy def explain(self, formater): + formater.begin_list(_('Layer ') + self.__class__.__name__) super(VoronoiDiagramLayer, self).explain(formater) self.colorgamut.explain(formater) - formater.text_item('Natural logarithm of order p used in Minkowski distance: ' + formater.text_item(_('Natural logarithm of order p used in Minkowski distance: ') + str(self.order)) - formater.position_array(self.sites_point, 'center points for sites:') + formater.position_array(self.sites_point, _('center points for sites:')) self.colorgamut.explain(formater) - formater.color_array(self.sites_color, 'site colors:') + formater.color_array(self.sites_color, _('site colors:')) text, surface, descr = self.sampler.explain() if surface is not None: - formater.surface_item(surface, 'sampling points: ' + text, descr) + formater.surface_item(surface, _('sampling points: ') + text, descr) else: formater.text_item(text) text, surface, descr = self.stamp.explain() if surface is not None: - formater.surface_item(surface, 'stamp: ' + text, descr) + formater.surface_item(surface, _('stamp: ') + text, descr) else: formater.text_item(text) + formater.end_list() def copy(self): """The Voronoi diagram layers copy constructor. diff --git a/ep_merger_combine.py b/ep_merger_combine.py index b8849a1..85cdca4 100644 --- a/ep_merger_combine.py +++ b/ep_merger_combine.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -168,15 +168,15 @@ class CombineMerger(model_allele.Allele): ctx.restore() def explain_left(self, formater): - formater.text_item('Compositing drawing operator for left node: ' \ + formater.text_item(_('Compositing drawing operator for left node: ') \ + self.OPERATOR_NAMES[self.left_operator]) - formater.text_item('Alpha blending of left node: ' \ + formater.text_item(_('Alpha blending of left node: ') \ + str(self.left_alphablending)) def explain_right(self, formater): - formater.text_item('Compositing drawing operator for right node: ' \ + formater.text_item(_('Compositing drawing operator for right node: ') \ + self.OPERATOR_NAMES[self.right_operator]) - formater.text_item('Alpha blending of right node: ' \ + formater.text_item(_('Alpha blending of right node: ') \ + str(self.right_alphablending)) def copy(self): diff --git a/ep_merger_mask.py b/ep_merger_mask.py index b35ff0a..89737dc 100644 --- a/ep_merger_mask.py +++ b/ep_merger_mask.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -147,13 +147,13 @@ class MaskMerger(model_allele.Allele): ctx.restore() def explain_left(self, formater): - formater.text_item('Compositing drawing operator for left node: ' \ + formater.text_item(_('Compositing drawing operator for left node: ') \ + self.OPERATOR_NAMES[self.left_operator]) - formater.text_item('Alpha blending of left node: ' \ + formater.text_item(_('Alpha blending of left node: ') \ + str(self.left_alphablending)) def explain_right(self, formater): - formater.text_item('Compositing used right node as a mask surface.') + formater.text_item(_('Compositing used right node as a mask surface.')) def copy(self): """A copy constructor. diff --git a/ep_modifier_border.py b/ep_modifier_border.py index cd124c6..4e02abb 100644 --- a/ep_modifier_border.py +++ b/ep_modifier_border.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -113,14 +113,13 @@ class BorderModifier(model_allele.Allele): single_treenode.render(task, ctx, width, height) ctx.restore() - def explain(self): - """ - post: len(__return__) == 3 - """ - return u'Border modifier, border weight=' + unicode(self.border_weight) \ - + u' alpha=' + unicode(self.border_alpha), \ - None, \ - None + + def explain(self, task, formater, single_layer, single_treenode): + formater.text_item(_('Border modifier, border weight=') + + unicode(self.border_weight) \ + + _(' alpha=') + unicode(self.border_alpha)) + single_layer.explain(formater) + single_treenode.explain(task, formater) def copy(self): """A copy constructor. diff --git a/ep_modifier_flip.py b/ep_modifier_flip.py index c377442..a6ffaf7 100644 --- a/ep_modifier_flip.py +++ b/ep_modifier_flip.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -86,20 +86,19 @@ class FlipModifier(model_allele.Allele): single_treenode.render(task, ctx, width, height) ctx.restore() - def explain(self): - """ - post: len(__return__) == 3 - """ - if self.xFlip and self.yFlip: - text = u'Flip modifier: flip horizontally and vertically.' - elif self.xFlip: - text = u'Flip modifier: flip horizontally.' - elif self.yFlip: - text = u'Flip modifier: flip vertically.' + def explain(self, task, formater, single_layer, single_treenode): + if self.xFlip < 0.0 and self.yFlip < 0.0: + text = _('Flip modifier: flip horizontally and vertically.') + elif self.xFlip < 0.0: + text = _('Flip modifier: flip horizontally.') + elif self.yFlip < 0.0: + text = _('Flip modifier: flip vertically.') else: - text = u'Flip modifier: did not flip.' - return text, None, None - + text = _('Flip modifier: did not flip.') + formater.text_item(text) + single_layer.explain(formater) + single_treenode.explain(task, formater) + def copy(self): """A copy constructor. post: isinstance(__return__, FlipModifier) diff --git a/ep_modifier_mask.py b/ep_modifier_mask.py index 439206b..70c0d43 100644 --- a/ep_modifier_mask.py +++ b/ep_modifier_mask.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -123,17 +123,14 @@ class MaskModifier(model_allele.Allele): single_treenode.render(task, ctx, width, height) ctx.restore() - def explain(self): - """ - post: len(__return__) == 3 - """ - return u'Mask modifier, center=' + self.center.explain() \ - + u' direction=' + self.direction.explain() \ - + u' alpha1=' + unicode(self.alpha1) \ - + u' alpha2=' + unicode(self.alpha2), \ - None, \ - None - + def explain(self, task, formater, single_layer, single_treenode): + formater.text_item(_('Mask modifier, center=') + self.center.explain() \ + + _(' direction=') + self.direction.explain() + + _(' alpha1=') + unicode(self.alpha1) + + _(' alpha2=') + unicode(self.alpha2)) + single_layer.explain(formater) + single_treenode.explain(task, formater) + def copy(self): """A copy constructor. post: isinstance(__return__, MaskModifier) diff --git a/ep_modifier_rectangulartile.py b/ep_modifier_rectangulartile.py index 9cdaa90..25c7c28 100644 --- a/ep_modifier_rectangulartile.py +++ b/ep_modifier_rectangulartile.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -98,14 +98,12 @@ class RectangularTileModifier(model_allele.Allele): ctx.restore() ctx.restore() - def explain(self): - """ - post: len(__return__) == 3 - """ - return u'Rectangular tile modifier: %d*x, %d*y' \ - % (self.x_tiles, self.y_tiles), \ - None, \ - None + def explain(self, task, formater, single_layer, single_treenode): + formater.text_item(_('Rectangular tile modifier: %d*x, %d*y') + % (self.x_tiles, self.y_tiles)) + single_layer.explain(formater) + single_treenode.explain(task, formater) + def copy(self): """A copy constructor. diff --git a/ep_page_details.py b/ep_page_details.py index e3a8778..c7336dd 100644 --- a/ep_page_details.py +++ b/ep_page_details.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ep_page_gettingstarted.py b/ep_page_gettingstarted.py index 9698d18..1ff3f32 100644 --- a/ep_page_gettingstarted.py +++ b/ep_page_gettingstarted.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ep_page_intro.py b/ep_page_intro.py index 9d5ad81..6b0c747 100644 --- a/ep_page_intro.py +++ b/ep_page_intro.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ep_page_status.py b/ep_page_status.py index 23f991a..b66ae39 100644 --- a/ep_page_status.py +++ b/ep_page_status.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ep_page_zoom.py b/ep_page_zoom.py index 61e5af2..3df411c 100644 --- a/ep_page_zoom.py +++ b/ep_page_zoom.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ep_positionconstraint_centered.py b/ep_positionconstraint_centered.py index 52a7c22..28ac1cc 100644 --- a/ep_positionconstraint_centered.py +++ b/ep_positionconstraint_centered.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ep_positionconstraint_none.py b/ep_positionconstraint_none.py index c0ec64f..61c5156 100644 --- a/ep_positionconstraint_none.py +++ b/ep_positionconstraint_none.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ep_sampler_randomwalk.py b/ep_sampler_randomwalk.py index 837b8c3..7951928 100644 --- a/ep_sampler_randomwalk.py +++ b/ep_sampler_randomwalk.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -115,7 +115,7 @@ class RandomWalkSampler(model_allele.Allele): """ post: len(__return__) == 3 """ - return u'Random walk sampler: %d points' \ + return _('Random walk sampler: %d points') \ % (len(self.direction_steps)), \ None, \ None diff --git a/ep_sampler_rectilineargrid.py b/ep_sampler_rectilineargrid.py index f4cc0a0..46182b1 100644 --- a/ep_sampler_rectilineargrid.py +++ b/ep_sampler_rectilineargrid.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -113,7 +113,7 @@ class RectilinearGridSampler(model_allele.Allele): """ post: len(__return__) == 3 """ - return u'Rectilinear grid sampler: %d*x, %d*y' \ + return _('Rectilinear grid sampler: %d*x, %d*y') \ % (self.x_tiles, self.y_tiles), \ None, \ None diff --git a/ep_sampler_squaregrid.py b/ep_sampler_squaregrid.py index b4912f2..8004a52 100644 --- a/ep_sampler_squaregrid.py +++ b/ep_sampler_squaregrid.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -96,7 +96,7 @@ class SquareGridSampler(model_allele.Allele): """ post: len(__return__) == 3 """ - return u'Squarish grid sampler: %d*%d' \ + return _('Squarish grid sampler: %d*%d') \ % (self.tiles, self.tiles), \ None, \ None diff --git a/ep_stamp_filledcyclic.py b/ep_stamp_filledcyclic.py index 85d4284..a42b58b 100644 --- a/ep_stamp_filledcyclic.py +++ b/ep_stamp_filledcyclic.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -117,7 +117,7 @@ class FilledCyclicStamp(model_allele.Allele): """ post: len(__return__) == 3 """ - return u'Square root of number of edges: ' + str(self.order), \ + return _('Square root of number of edges: ') + str(self.order), \ None, \ None diff --git a/ep_stamp_glyph.py b/ep_stamp_glyph.py index 1231ce3..064c174 100644 --- a/ep_stamp_glyph.py +++ b/ep_stamp_glyph.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -91,7 +91,6 @@ def classify_unichrtab(): return _unichar_category def select_by(category_list): - global _unichar_category selected = [] for ux in range(len(unichrtab)): uc = unichr(unichrtab[ux]) @@ -232,8 +231,8 @@ class GlyphStamp(model_allele.Allele): """ post: len(__return__) == 3 """ - text = u'Font: ' + self.family + ', ' + unicode(self.size) + ', ' + \ - 'A collection of characters from category : ' + \ + text = _('Font: ') + self.family + ', ' + unicode(self.size) + ', ' + \ + _('A collection of characters from category : ') + \ unicode(self.category_list) return text, \ None, \ diff --git a/ep_stamp_svg.py b/ep_stamp_svg.py index 34503e8..dc37ed4 100644 --- a/ep_stamp_svg.py +++ b/ep_stamp_svg.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -177,7 +177,7 @@ class SvgStamp(model_allele.Allele): """ post: len(__return__) == 3 """ - return u'Theme is %s. Patterns are in SVG format: ' % self.theme, \ + return _('Theme is %s. Patterns are in SVG format: ') % self.theme, \ None, \ None diff --git a/exon_buzzword.py b/exon_buzzword.py index 65f3f8d..db4a2b5 100644 --- a/exon_buzzword.py +++ b/exon_buzzword.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/exon_color.py b/exon_color.py index bd8e192..c91d8f2 100644 --- a/exon_color.py +++ b/exon_color.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -77,8 +77,14 @@ class Color(model_allele.Allele): """Set red, green, blue and alpha to random values.""" cpool = model_constraintpool.ConstraintPool.get_pool() constraints = cpool.get(self, COLOR_CONSTRAINT) - self.constraint = ka_extensionpoint.create(random.choice(constraints), - self.path) + #TODO prefer a single constraint + #TODO Remove pushing colorconstraint_none by a more generalized solution + if 'colorconstraint_none' in constraints and random.random() < 0.5: + self.constraint = ka_extensionpoint.create(random.choice(['colorconstraint_none']), + self.path) + else: + self.constraint = ka_extensionpoint.create(random.choice(constraints), + self.path) self.rgba = self.constraint.randomize() def mutate(self): diff --git a/exon_direction.py b/exon_direction.py index c381f09..dd911d7 100644 --- a/exon_direction.py +++ b/exon_direction.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -100,7 +100,7 @@ class Direction(model_allele.Allele): def explain(self): """Returns a string describing details.""" - return u'%4.3f, %4.3f' % (self.radian, self.offset) + return '%4.3f, %4.3f' % (self.radian, self.offset) @staticmethod def make_icon(direction_list, width, height): diff --git a/exon_position.py b/exon_position.py index 439f0ab..f937a3c 100644 --- a/exon_position.py +++ b/exon_position.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -100,7 +100,7 @@ class Position(model_allele.Allele): def explain(self): """Returns a string describing details.""" - return u'%4.3f, %4.3f' % (self.x_pos, self.y_pos) + return '%4.3f, %4.3f' % (self.x_pos, self.y_pos) @staticmethod def make_icon(position_list, width, height): diff --git a/ka_controller.py b/ka_controller.py index a1aa8c7..5603936 100644 --- a/ka_controller.py +++ b/ka_controller.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -14,11 +14,8 @@ # 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 -from sugar.activity import activityfactory -import os import gtk -import gtk.glade import gobject import cairo import model_population @@ -335,29 +332,9 @@ class KandidController(object): """ ka_debug.info('on_explain_activate [%s]' % args[0].get_name()) protozoon = self.model.protozoans[name_to_index(args[0].get_name())] -#!! folder = os.path.join(self.activity_root, 'tmp') -#!! file_path = 'file://' + self.explain('html', protozoon, 'index', folder) -#!! result = webbrowser.open(file_path) -#!! ka_debug.info('webbrowser.open: [%s] %s' % (file_path, str(result))) -#!! #Start up a new instance of the Web activity. -#!! ka_debug.info('webbrowser.open: [%s]' % (file_path)) -#!! activityfactory.create_with_uri('org.laptop.WebActivity', file_path) if self._details_controller is not None: self._details_controller.start_calculation(protozoon) -#!! def explain(self, ep_key, protozoon, base_name, base_folder): -#!! formater = ka_extensionpoint.create('formater_'+ep_key, -#!! base_name, -#!! protozoon.get_unique_id(), -#!! base_folder) -#!! class DummyTask: -#!! def __init__(self): -#!! self.quit = False -#!! protozoon.explain(DummyTask(), formater) -#!! file_path = formater.get_absolutename(ep_key) -#!! formater.write_html_file(file_path) -#!! return file_path - def on_favorite_activate(self, *args): """Set best ranking for this protozoon. pre: len(args) >= 1 diff --git a/ka_debug.py b/ka_debug.py index 5fd8fcf..af89244 100644 --- a/ka_debug.py +++ b/ka_debug.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -16,12 +16,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import logging -import sys -import traceback import os import time -"""Add support for design by contract to all classes except blacklist.""" +#Add support for design by contract to all classes except blacklist. + # default path for testing on local machine DEBUG_ACTIVITY_PATH = '/home/strom/minimal/activities/Kandid.activity' DEBUG_PROFILE_PATH = '/home/strom/.sugar/1/' @@ -90,6 +89,7 @@ def dot_ref(anchor, ref): return result def print_call_stack(): +# import traceback # try: # raise TypeError("") # except TypeError: diff --git a/ka_extensionpoint.py b/ka_extensionpoint.py index 558b8e9..aae9353 100644 --- a/ka_extensionpoint.py +++ b/ka_extensionpoint.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -54,10 +54,6 @@ def create(extension_key, *params): if str(type(value)) == "": a_class = getattr(a_module, key) return a_class(*params) -# if len(params) == 0: -# return a_class() -# elif len(params) == 1: -# return a_class(params[0]) def _add(extension_type, extension_class): if extension_type not in _extension_types: diff --git a/ka_factory.py b/ka_factory.py index e97a0d2..7b033c3 100644 --- a/ka_factory.py +++ b/ka_factory.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ka_html_page.py b/ka_html_page.py index a250fc7..139af42 100644 --- a/ka_html_page.py +++ b/ka_html_page.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -26,15 +26,9 @@ try: import gnome gnome.init('Hulahop', '1.0') -#!! import gobject -#!! import gtk import hulahop hulahop.set_app_version(os.environ['SUGAR_BUNDLE_VERSION']) hulahop.startup(os.path.join(env.get_profile_path(), 'gecko')) -#!! import xpcom -#!! from xpcom.nsError import * -#!! from xpcom import components -#!! from xpcom.components import interfaces from hulahop.webview import WebView except: ka_debug.err('failed importing hulahop [%s] [%s]' % \ @@ -65,17 +59,12 @@ class HtmlPage(object): #!! from XOCom import XOCom #!! self.xocom = XOCom(self.control_sending_text) #REMEMBER THAT I HAVE STILL TO SEND THE ARGUMENT IN THE XOCOM CLASS #!! self._htmlview = self.xocom.create_webview() -#!! self._htmlview = hulahop.webview.WebView() self._htmlview = WebView() -#!! self._htmlview = WebView() except: ka_debug.err('failed creating hulahop [%s] [%s]' % \ (sys.exc_info()[0], sys.exc_info()[1])) traceback.print_exc(file=sys.__stderr__) -#!! def control_sending_text(self): -#!! pass - def autoconnect_events(self): """Auto connect introduction view.""" events = { diff --git a/ka_importer.py b/ka_importer.py index a8f97f7..18ff184 100644 --- a/ka_importer.py +++ b/ka_importer.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ka_incoming.py b/ka_incoming.py index 99afe56..29da665 100644 --- a/ka_incoming.py +++ b/ka_incoming.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ka_status.py b/ka_status.py index 18af81e..bac84aa 100644 --- a/ka_status.py +++ b/ka_status.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/ka_task.py b/ka_task.py index e114533..825ce59 100644 --- a/ka_task.py +++ b/ka_task.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -45,8 +45,8 @@ class GeneratorTask(object): GeneratorTask._internal_task_count += 1 GeneratorTask._internal_task_list[task.work_for] = task - ka_debug.info('enter task: [%s], count aprox.= %u' % \ - (task.work_for, GeneratorTask._internal_task_count)) +# ka_debug.info('enter task: [%s], count aprox.= %u' % \ +# (task.work_for, GeneratorTask._internal_task_count)) GeneratorTask._internal_task_list_lock.release() ka_status.Status.instance(). \ set(ka_status.TOPIC_TASK, ka_status.SUB_UNFINISHED, @@ -69,8 +69,8 @@ class GeneratorTask(object): GeneratorTask._internal_leave_condition.notifyAll() GeneratorTask._internal_leave_condition.release() - ka_debug.info('leave task: [%s], count aprox.= %u' % \ - (work_for, GeneratorTask._internal_task_count)) +# ka_debug.info('leave task: [%s], count aprox.= %u' % \ +# (work_for, GeneratorTask._internal_task_count)) GeneratorTask._internal_task_list_lock.release() ka_status.Status.instance(). \ set(ka_status.TOPIC_TASK, ka_status.SUB_UNFINISHED, diff --git a/ka_widget.py b/ka_widget.py index 95e092d..6752823 100644 --- a/ka_widget.py +++ b/ka_widget.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/kandid.py b/kandid.py index d5521c4..35b01b4 100644 --- a/kandid.py +++ b/kandid.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # This source code is based on the helloworld.py example from # PyGTK 2.0 Tutorial. see: http://www.pygtk.org/pygtk2tutorial/ # diff --git a/kandidtube.py b/kandidtube.py index c0db871..8be7211 100644 --- a/kandidtube.py +++ b/kandidtube.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -15,14 +15,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -import sys import traceback +import sys import hashlib import base64 from dbus.service import method, signal from dbus.gobject_service import ExportedGObject -import telepathy +#!!import telepathy import ka_debug import ka_status @@ -63,10 +63,18 @@ class KandidTube(ExportedGObject): (handle, buddy.props.nick)) self._participating_buddies |= set([buddy.props.nick]) for handle in removed: - buddy = self._get_buddy(handle) + nickname = '?' + buddy = None + try: + buddy = self._get_buddy(handle) + nickname = buddy.props.nick + except: + ka_debug.err('get buddy failed [%s] [%s]' % \ + (sys.exc_info()[0], sys.exc_info()[1])) + traceback.print_exc(file=sys.__stderr__) if buddy is not None: - ka_debug.info('Buddy [%s] was removed' % buddy.props.nick) - self._participating_buddies -= set([buddy.props.nick]) + ka_debug.info('Buddy [%s] was removed' % nickname) + self._participating_buddies -= set([nickname]) self._status.set(ka_status.TOPIC_COLLABORATION, ka_status.SUB_BUDDIES_PARTICIPATING, self._participating_buddies) diff --git a/model_allele.py b/model_allele.py index e7fdac3..057756c 100644 --- a/model_allele.py +++ b/model_allele.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/model_constraintpool.py b/model_constraintpool.py index c683159..ecdfc1f 100644 --- a/model_constraintpool.py +++ b/model_constraintpool.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/model_layer.py b/model_layer.py index f30020a..bf6baae 100644 --- a/model_layer.py +++ b/model_layer.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -19,7 +19,6 @@ import random import cairo import model_random import model_allele -import model_constraintpool from gettext import gettext as _ ## Cairo's compositing operators @@ -50,34 +49,20 @@ class Layer(model_allele.Allele): """Layer constructor""" super(Layer, self).__init__(trunk) self.random_seed = 1512 -# self.operator = cairo.OPERATOR_OVER - -# def dump(self): -# return (repr(type(self)), id(self), -# self.random_seed, -# self.OPERATOR_NAMES[self.operator], -# ) def __eq__(self, other): """Equality based on the cells color components.""" equal = isinstance(other, Layer) \ and self.random_seed == other.random_seed -# and self.operator == other.operator return equal def randomize(self): """Randomize the layers components.""" -# cpool = model_constraintpool.ConstraintPool.get_pool() self.random_seed = random.randint(1, 65535) -# operator_constraint = cpool.get(self, OPERATOR_CONSTRAINT) -# self.operator = random.choice(operator_constraint) def mutate(self): """Make small random changes to the layers components.""" -# if model_random.is_mutating(): -# cpool = model_constraintpool.ConstraintPool.get_pool() -# operator_constraint = cpool.get(self, OPERATOR_CONSTRAINT) -# self.operator = random.choice(operator_constraint) + pass def swap_places(self): """Layer is an abstract class. Call swap_places() on sub classes only. @@ -97,11 +82,9 @@ class Layer(model_allele.Allele): pre: isinstance(other, Layer) pre: cross_lenght >= 0 """ - cross_sequence = model_random.crossing_sequence(cross_lenght + 2) + cross_sequence = model_random.crossing_sequence(cross_lenght + 1) new_one.random_seed = self.random_seed \ if cross_sequence[cross_lenght] else other.random_seed -# new_one.operator = self.operator \ -# if cross_sequence[cross_lenght+1] else other.operator return cross_sequence def render(self, task, ctx, width, height): @@ -119,8 +102,8 @@ class Layer(model_allele.Allele): ctx.set_operator(cairo.OPERATOR_SOURCE) def explain(self, formater): - formater.text_item('Painters algorithm: ' + self.__class__.__name__) - formater.text_item('Seed value for random generator: ' \ + formater.text_item(_('Painters algorithm: ') + self.__class__.__name__) + formater.text_item(_('Seed value for random generator: ') \ + str(self.random_seed)) def copy(self): @@ -133,4 +116,3 @@ class Layer(model_allele.Allele): pre: isinstance(new_one, Layer) """ new_one.random_seed = self.random_seed -# new_one.operator = self.operator diff --git a/model_locus.py b/model_locus.py index 2e9b686..e574f2d 100644 --- a/model_locus.py +++ b/model_locus.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/model_population.py b/model_population.py index 0af5bd1..b29fb49 100644 --- a/model_population.py +++ b/model_population.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -14,6 +14,7 @@ # 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 ka_extensionpoint #import simplejson as json import pickle @@ -30,7 +31,8 @@ STATE_INIT = 'I' STATE_RANDOMIZED = 'R' STATE_EVOLVED = 'E' -MAGIC_NUMBER = 'mk01' +MAGIC_NUMBER = 'mk' +VERSION_NUMBER = '01' class KandidModel(object): """ @@ -229,25 +231,31 @@ class KandidModel(object): return new_at return -1 - -def from_buffer(buffer): +def _get_my_revision(): + revision = ka_extensionpoint.revision_number + return str(revision) if revision > 9 else '0' + str(revision) + +def from_buffer(input_buffer): # ka_debug.info('read from_buffer') obj = None try: - if buffer.startswith(MAGIC_NUMBER): - obj = pickle.loads(zlib.decompress(buffer[4:])) + if input_buffer.startswith(MAGIC_NUMBER): + obj = pickle.loads(zlib.decompress(input_buffer[4:])) + if not input_buffer.startswith(MAGIC_NUMBER+_get_my_revision()): + obj = obj.copy() else: ka_debug.err('missing magic number') except: - ka_debug.err('failed reading buffer [%s] [%s]' % \ + ka_debug.err('failed reading input buffer [%s] [%s]' % \ (sys.exc_info()[0], sys.exc_info()[1])) traceback.print_exc(file=sys.__stderr__) - return obj.copy() + return obj def to_buffer(obj): # ka_debug.info('write %s to_buffer' % type(obj)) try: - return MAGIC_NUMBER + zlib.compress(pickle.dumps(obj, protocol=2)) + return MAGIC_NUMBER + _get_my_revision() \ + + zlib.compress(pickle.dumps(obj, protocol=2)) except: ka_debug.err('failed writing buffer [%s] [%s]' % \ (sys.exc_info()[0], sys.exc_info()[1])) diff --git a/model_protozoon.py b/model_protozoon.py index 59b2820..b63195f 100644 --- a/model_protozoon.py +++ b/model_protozoon.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -107,24 +107,24 @@ class Protozoon(model_allele.Allele): def explain(self, task, formater): """Explain all layers and mergers.""" # begin with header - titel = 'protozoon ' + self.get_unique_id() + titel = _('protozoon ') + self.get_unique_id() formater.header(titel) # display combined layers width = height = 256 surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) ctx = cairo.Context(surface) -# ctx.set_operator(cairo.OPERATOR_SOURCE) -# ctx.set_source_rgb(0, 0, 0) -# ctx.paint() + ctx.set_operator(cairo.OPERATOR_SOURCE) + ctx.set_source_rgb(0, 0, 0) + ctx.paint() self.render(task, ctx, width, height) - formater.surface_item(surface, 'Final image, all layers are combined', titel) + formater.surface_item(surface, _('Final image, all layers are combined'), titel) + #explain background color + formater.color_item(self.background, _('background color:'), alpha=False) + # explain all layers from top to bottom self.treenode.explain(task, formater) - #explain background color - formater.color_item(self.background, 'background color:', alpha=False) - # stop with footer formater.footer() diff --git a/model_random.py b/model_random.py index 1d656bd..261913b 100644 --- a/model_random.py +++ b/model_random.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 diff --git a/model_treenode.py b/model_treenode.py index 71f2e33..5aa4b45 100644 --- a/model_treenode.py +++ b/model_treenode.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -301,44 +301,44 @@ class TreeNode(model_allele.Allele): width = height = 256 # explain layers for current node and its child nodes - depth = _count_slash(self.path) leaf = (self.left_treenode is None) and (self.right_treenode is None) # preview - title = 'Combined layers of subtree ' + self.path - title = 'Leaf ' + self.path if leaf else title - formater.begin_list(title) +#ex title = 'Leaf ' if leaf else 'Combined layers of subtree' +#ex formater.begin_list(title) # preview this node self._preview(task, self, formater, width, height) # explain details - formater.begin_list('Details for ' + title) if leaf: # explain the leafs layer self.layer.explain(formater) elif (self.left_treenode is not None) and (self.right_treenode is not None): + formater.begin_list(_('Details for merging node ') + self.path) # explain how layers are combined - formater.color_item(self.left_background, 'left background color:', alpha=True) + formater.color_item(self.left_background, + _('left background color:'), + alpha=True) self.merger.explain_left(formater) self.left_treenode.explain(task, formater) - formater.color_item(self.right_background, 'right background color:', alpha=True) + formater.color_item(self.right_background, + _('right background color:'), + alpha=True) self.merger.explain_right(formater) self.right_treenode.explain(task, formater) + formater.end_list() else: + formater.begin_list(_('Details for modifying node ') + self.path) # preview this node self._preview(task, self.layer, formater, width, height) - text, surface, descr = self.modifier.explain() - if surface is not None: - formater.surface_item(surface, 'modifier : ' + text, descr) - else: - formater.text_item(text) - # explain child node if self.left_treenode is not None: - self.left_treenode.explain(task, formater) + self.modifier.explain(task, formater, + self.layer, self.left_treenode) if self.right_treenode is not None: - self.right_treenode.explain(task, formater) - formater.end_list() + self.modifier.explain(task, formater, + self.layer, self.right_treenode) + formater.end_list() - formater.end_list() +#ex formater.end_list() def _preview(self, task, source, formater, width, height): surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) @@ -348,7 +348,7 @@ class TreeNode(model_allele.Allele): TreeNode._paint_checker_board(ctx) ctx.save() source.render(task, ctx, width, height) - formater.surface_item(surface, self.__class__.__name__, self.__class__.__name__) + formater.surface_item(surface, 'Tree node ' + self.path, self.path) ctx.restore() def copy(self): diff --git a/po/Kandid.pot b/po/Kandid.pot index ffe330b..6f23925 100644 --- a/po/Kandid.pot +++ b/po/Kandid.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-02-09 22:00+0100\n" +"POT-Creation-Date: 2010-02-14 17:52+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -20,6 +20,109 @@ msgstr "" msgid "Kandid" msgstr "" +#: ep_modifier_rectangulartile.py:102 +#, python-format +msgid "Rectangular tile modifier: %d*x, %d*y" +msgstr "" + +#: ep_sampler_rectilineargrid.py:116 +#, python-format +msgid "Rectilinear grid sampler: %d*x, %d*y" +msgstr "" + +#: ep_layer_filledspline.py:206 ep_layer_markovchain.py:292 +#: ep_layer_letterpress.py:228 ep_layer_voronoidiagram.py:274 +msgid "Layer " +msgstr "" + +#: ep_layer_filledspline.py:209 +msgid "line color:" +msgstr "" + +#: ep_layer_filledspline.py:210 +msgid "line width: " +msgstr "" + +#: ep_layer_filledspline.py:211 +msgid "roundness: " +msgstr "" + +#: ep_layer_filledspline.py:212 +msgid "fill color:" +msgstr "" + +#: ep_layer_filledspline.py:213 ep_layer_letterpress.py:236 +msgid "center:" +msgstr "" + +#: ep_layer_filledspline.py:216 ep_layer_markovchain.py:299 +#: ep_layer_letterpress.py:239 ep_layer_voronoidiagram.py:284 +msgid "sampling points: " +msgstr "" + +#: ep_colorconstraint_none.py:67 +#, python-format +msgid "%d%% red, %d%% green, %d%% blue, %d%% opaque" +msgstr "" + +#: ep_colorconstraint_none.py:70 +#, python-format +msgid "%d%% red, %d%% green, %d%% blue" +msgstr "" + +#: ep_stamp_svg.py:180 +#, python-format +msgid "Theme is %s. Patterns are in SVG format: " +msgstr "" + +#: ep_colorgamut_monchrome.py:69 +msgid "Monochromatic color scheme" +msgstr "" + +#: ep_stamp_glyph.py:234 ep_layer_letterpress.py:232 +msgid "Font: " +msgstr "" + +#: ep_stamp_glyph.py:235 +msgid "A collection of characters from category : " +msgstr "" + +#: ep_modifier_flip.py:91 +msgid "Flip modifier: flip horizontally and vertically." +msgstr "" + +#: ep_modifier_flip.py:93 +msgid "Flip modifier: flip horizontally." +msgstr "" + +#: ep_modifier_flip.py:95 +msgid "Flip modifier: flip vertically." +msgstr "" + +#: ep_modifier_flip.py:97 +msgid "Flip modifier: did not flip." +msgstr "" + +#: ep_merger_mask.py:150 ep_merger_combine.py:171 +msgid "Compositing drawing operator for left node: " +msgstr "" + +#: ep_merger_mask.py:152 ep_merger_combine.py:173 +msgid "Alpha blending of left node: " +msgstr "" + +#: ep_merger_mask.py:156 +msgid "Compositing used right node as a mask surface." +msgstr "" + +#: ep_modifier_border.py:118 +msgid "Border modifier, border weight=" +msgstr "" + +#: ep_modifier_border.py:120 +msgid " alpha=" +msgstr "" + #: ep_page_gettingstarted.py:56 msgid "Getting started" msgstr "" @@ -36,19 +139,59 @@ msgstr "" msgid "getting_started" msgstr "" -#: activity.py:181 +#: model_layer.py:105 +msgid "Painters algorithm: " +msgstr "" + +#: model_layer.py:106 +msgid "Seed value for random generator: " +msgstr "" + +#: model_treenode.py:316 +msgid "Details for merging node " +msgstr "" + +#: model_treenode.py:319 +msgid "left background color:" +msgstr "" + +#: model_treenode.py:324 +msgid "right background color:" +msgstr "" + +#: model_treenode.py:330 +msgid "Details for modifying node " +msgstr "" + +#: ep_stamp_filledcyclic.py:120 +msgid "Square root of number of edges: " +msgstr "" + +#: activity.py:180 msgid "Activity is shared." msgstr "" -#: activity.py:190 activity.py:237 +#: activity.py:189 activity.py:236 #, python-format msgid "I am '%s', my handle in that group is %u." msgstr "" -#: activity.py:233 +#: activity.py:232 msgid "Joined an existing shared activity." msgstr "" +#: model_protozoon.py:110 +msgid "protozoon " +msgstr "" + +#: model_protozoon.py:121 +msgid "Final image, all layers are combined" +msgstr "" + +#: model_protozoon.py:123 +msgid "background color:" +msgstr "" + #: ka_status.py:39 msgid "Collaboration" msgstr "" @@ -101,6 +244,95 @@ msgstr "" msgid "Running" msgstr "" +#: ep_colorgamut_triadic.py:77 +msgid "Triadic color scheme" +msgstr "" + +#: ep_merger_combine.py:177 +msgid "Compositing drawing operator for right node: " +msgstr "" + +#: ep_merger_combine.py:179 +msgid "Alpha blending of right node: " +msgstr "" + +#: ep_layer_markovchain.py:295 +msgid "cell colors:" +msgstr "" + +#: ep_layer_markovchain.py:296 +msgid "number of states: " +msgstr "" + +#: ep_layer_markovchain.py:304 ep_layer_voronoidiagram.py:289 +msgid "stamp: " +msgstr "" + +#: ep_layer_letterpress.py:230 +msgid "buzzwords: " +msgstr "" + +#: ep_layer_letterpress.py:231 +msgid "text color:" +msgstr "" + +#: ep_colorgamut_splitcomplementary.py:78 +msgid "Split complementary color scheme" +msgstr "" + +#: ep_sampler_randomwalk.py:118 +#, python-format +msgid "Random walk sampler: %d points" +msgstr "" + +#: ep_sampler_squaregrid.py:99 +#, python-format +msgid "Squarish grid sampler: %d*%d" +msgstr "" + +#: ep_colorconstraint_gray.py:61 +#, python-format +msgid "%d%% gray, %d%% opaque" +msgstr "" + +#: ep_colorconstraint_gray.py:63 +#, python-format +msgid "Color is reduced to shades of gray, %d%% gray" +msgstr "" + +#: ep_modifier_mask.py:127 +msgid "Mask modifier, center=" +msgstr "" + +#: ep_modifier_mask.py:128 +msgid " direction=" +msgstr "" + +#: ep_modifier_mask.py:129 +msgid " alpha1=" +msgstr "" + +#: ep_modifier_mask.py:130 +msgid " alpha2=" +msgstr "" + +#: ep_colorconstraint_bw.py:64 +msgid "black" +msgstr "" + +#: ep_colorconstraint_bw.py:64 +msgid "white" +msgstr "" + +#: ep_colorconstraint_bw.py:65 +#, python-format +msgid ", %d%% opaque" +msgstr "" + +#: ep_colorconstraint_bw.py:66 +msgid "Color is reduced to black and white, " +msgstr "" + #: ka_widget.py:59 msgid "Breed" msgstr "" @@ -152,3 +384,23 @@ msgstr "" #: ka_widget.py:82 msgid "Decline protozoon" msgstr "" + +#: ep_colorgamut_analogous.py:78 +msgid "Analogous color scheme" +msgstr "" + +#: ep_layer_voronoidiagram.py:277 +msgid "Natural logarithm of order p used in Minkowski distance: " +msgstr "" + +#: ep_layer_voronoidiagram.py:279 +msgid "center points for sites:" +msgstr "" + +#: ep_layer_voronoidiagram.py:281 +msgid "site colors:" +msgstr "" + +#: ep_colorgamut_complement.py:73 +msgid "Complementary color scheme" +msgstr "" diff --git a/test_enumerator.py b/test_enumerator.py index a74c1de..ff1f39e 100644 --- a/test_enumerator.py +++ b/test_enumerator.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -14,71 +14,90 @@ # 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 ep_merger_combine +import traceback +import sys import cairo import ka_debug import ka_factory import model_random import ka_extensionpoint +import ep_merger_combine import model_protozoon import model_constraintpool class VariantEnumerator(object): + + def __init__(self): + self.exception_counter = 0 def explain_permutation(self): model_random.set_flurry(9) cpool = model_constraintpool.ConstraintPool.get_pool() + for layer_key in ka_factory.get_factory('layer').keys(): + for modifier_key in ka_factory.get_factory('modifier').keys(): + cpool.clear_all() + cpool.set('*', 'colorconstraint', ['colorconstraint_none', ]) + cpool.set('*', 'layernumberofconstraint', [1, 3]) + cpool.set('*', 'layertypeconstraint', + ['letterpress', 'markovchain']) + cpool.set('*', 'layertypeconstraint', layer_key) + cpool.set('*', 'modifiertypeconstraint', modifier_key) + cpool.set('*', 'operatorconstraint', [cairo.OPERATOR_OVER]) + self._explain_protozon(layer_key, modifier_key) + for operator_key in ep_merger_combine.CombineMerger.OPERATORS: for merger_key in ka_factory.get_factory('merger').keys(): cpool.clear_all() - cpool.set('/Protozoon', 'layernumberofconstraint', [4, 4]) - cpool.set('/Protozoon', 'layertypeconstraint', - ['image', 'markovchain']) - cpool.set('/Protozoon/ImageLayer', 'operatorconstraint', - [operator_key]) - cpool.set('/Protozoon/MarkovChainLayer', 'operatorconstraint', - [operator_key]) - cpool.set('/Protozoon', 'mergertypeconstraint', merger_key) + cpool.set('*', 'colorconstraint', ['colorconstraint_none', ]) + cpool.set('*', 'layernumberofconstraint', [3, 3]) + cpool.set('*', 'layertypeconstraint', + ['letterpress', 'markovchain']) + cpool.set('*', 'operatorconstraint', [operator_key]) + cpool.set('*', 'mergertypeconstraint', merger_key) self._explain_protozon( ep_merger_combine.CombineMerger.OPERATOR_NAMES[operator_key], merger_key) for layer_key in ka_factory.get_factory('layer').keys(): for merger_key in ka_factory.get_factory('merger').keys(): cpool.clear_all() - cpool.set('/Protozoon', 'layernumberofconstraint', [3, 3]) - cpool.set('/Protozoon', 'layertypeconstraint', layer_key) - cpool.set('/Protozoon', 'mergertypeconstraint', merger_key) - cpool.set('/Protozoon/ImageLayer', 'operatorconstraint', - [cairo.OPERATOR_OVER]) - cpool.set('/Protozoon/MarkovChainLayer', 'operatorconstraint', - [cairo.OPERATOR_OVER]) - cpool.set('/Protozoon/ReferencePattern', 'operatorconstraint', - [cairo.OPERATOR_OVER]) - cpool.set('/Protozoon/LetterPress', 'operatorconstraint', - [cairo.OPERATOR_OVER]) + cpool.set('*', 'colorconstraint', ['colorconstraint_none', ]) + cpool.set('*', 'layernumberofconstraint', [3, 2]) + cpool.set('*', 'layertypeconstraint', layer_key) + cpool.set('*', 'mergertypeconstraint', merger_key) + cpool.set('*', 'operatorconstraint', [cairo.OPERATOR_OVER]) self._explain_protozon(layer_key, merger_key) def _explain_protozon(self, key1, key2): - a_protozoon = model_protozoon.Protozoon() - a_protozoon.randomize() - - base_name = 'index' - base_folder = '/dev/shm/' - explain_id = '_' + key1 + '_' + key2 - ep_list = ka_extensionpoint.list_extensions('formater') - formater = ka_extensionpoint.create(ep_list[0], - base_name, - explain_id, - base_folder) - a_protozoon.explain(formater) - file_path = formater.get_absolutename('html') - formater.write_html_file(file_path) + try: + a_protozoon = model_protozoon.Protozoon() + a_protozoon.randomize() + + base_name = 'index' + base_folder = '/dev/shm/' + explain_id = '_' + key1 + '_' + key2 + ep_list = ka_extensionpoint.list_extensions('formater') + formater = ka_extensionpoint.create(ep_list[0], + base_name, + explain_id, + base_folder) + class DummyTask: + def __init__(self): + self.quit = False + a_protozoon.explain(DummyTask(), formater) + file_path = formater.get_absolutename('html') + formater.write_html_file(file_path) + except: + self.exception_counter += 1 + ka_debug.err('failed rendering [%s] [%s] [%s]' % \ + (explain_id, sys.exc_info()[0], sys.exc_info()[1])) + traceback.print_exc(file=sys.__stderr__) def explain(): vae = VariantEnumerator() vae.explain_permutation() + return vae.exception_counter if __name__ == '__main__': explain() \ No newline at end of file diff --git a/test_suite.py b/test_suite.py index a76b732..f5a37ab 100644 --- a/test_suite.py +++ b/test_suite.py @@ -1,5 +1,5 @@ # coding: UTF-8 -# Copyright 2009 Thomas Jourdan +# Copyright 2009, 2010 Thomas Jourdan # # 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 @@ -662,12 +662,11 @@ class TestKandidModel(unittest.TestCase): self.assertTrue(tc in string.ascii_uppercase) file_path = ep_page_intro.IntroController.get_localized_path(locale, territory) - cont = htmltextview.HtmlTextView.get_localized_content(file_path) - self.assertEqual(0, cont.find('')) + self.assertTrue(file_path.endswith('/Kandid.activity/locale/' + + locale + '/intro.html')) def test_render2(self): - return #TODO - test_enumerator.explain() + self.assertEqual(0, test_enumerator.explain()) def test_status(self): status = ka_status.Status() -- cgit v0.9.1