Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST3
-rw-r--r--NEWS6
-rw-r--r--activity.py1
-rw-r--r--activity/activity.info1
-rw-r--r--activity/mimetypes.xml7
-rw-r--r--ep_layer_letterpress.py41
-rw-r--r--ep_merger_mask.py2
-rw-r--r--htmltextview.py1
-rw-r--r--ka_importer.py46
-rw-r--r--ka_widget.py4
-rw-r--r--locale/de/intro.html2
-rw-r--r--locale/en/intro.html2
-rw-r--r--model_population.py20
-rw-r--r--po/msg_compile.sh10
-rwxr-xr-xsetup.py20
-rw-r--r--test_suite.py26
16 files changed, 78 insertions, 114 deletions
diff --git a/MANIFEST b/MANIFEST
index d82ea6d..fd55894 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,6 @@
activity/activity.info
+activity/mimetypes.xml
+activity/application-x-kandid-project.svg
activity/activity-kandid.svg
locale/en/activity.linfo
locale/en/intro.html
@@ -50,7 +52,6 @@ ka_controller.py
ka_debug.py
ka_extensionpoint.py
ka_factory.py
-ka_importer.py
ka_incoming.py
ka_task.py
ka_widget.py
diff --git a/NEWS b/NEWS
index bdfd335..c51b087 100644
--- a/NEWS
+++ b/NEWS
@@ -1,2 +1,6 @@
-+
+An introduction to Kandid can be found at sugarlabs.org .
+http://wiki.sugarlabs.org/go/Activities/Kandid
+
+v2: December 2009
+first public release
diff --git a/activity.py b/activity.py
index 7166087..be50755 100644
--- a/activity.py
+++ b/activity.py
@@ -49,6 +49,7 @@ class KandidActivity(activity.Activity):
activity.Activity.__init__(self, handle)
self._print_greetings(handle)
self._name = handle
+ self.metadata['mime_type'] = 'application/x-kandid-activity'
# Set title for our Activity
self.set_title('Kandid')
diff --git a/activity/activity.info b/activity/activity.info
index 02adca3..7792349 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -5,3 +5,4 @@ class = activity.KandidActivity
icon = activity-kandid
activity_version = 2
show_launcher = yes
+mime_types = application/x-kandid-activity; \ No newline at end of file
diff --git a/activity/mimetypes.xml b/activity/mimetypes.xml
new file mode 100644
index 0000000..83077ec
--- /dev/null
+++ b/activity/mimetypes.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <mime-type type="application/x-kandid-activity">
+ <comment xml:lang="en">Kandid Activity</comment>
+ <glob pattern="*.kandid"/>
+ </mime-type>
+</mime-info>
diff --git a/ep_layer_letterpress.py b/ep_layer_letterpress.py
index f1da61c..73400c1 100644
--- a/ep_layer_letterpress.py
+++ b/ep_layer_letterpress.py
@@ -14,6 +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
+import traceback
+import sys
import random
import pango
@@ -199,23 +201,28 @@ class LetterPress(model_layer.Layer):
px = self.center.x_pos + points[di][0]
py = self.center.y_pos + points[di][1]
- layout = pango_ctx.create_layout()
- fi = (fi+1) % len(self.family)
- desc = pango.FontDescription(self.family[fi])
- desc.set_size(int(self.size * width * 0.01 * pango.SCALE))
- desc.set_style(self.style)
- desc.set_weight(self.weight)
- layout.set_text(word.encode('utf-8'))
- layout.set_font_description(desc)
- layout.set_alignment(pango.ALIGN_CENTER)
- rgba = self.textcolor.rgba
- pango_ctx.set_source_rgba(rgba[0], rgba[1], rgba[2], rgba[3])
- pango_ctx.update_layout(layout)
-
- pixel_size = layout.get_pixel_size()
- dx, dy = 0.5 * pixel_size[0], 0.9 * pixel_size[1]
- pango_ctx.move_to((width * px) - dx, (height * py) - dy)
- pango_ctx.show_layout(layout)
+ try:
+ layout = pango_ctx.create_layout()
+ fi = (fi+1) % len(self.family)
+ desc = pango.FontDescription(self.family[fi])
+ desc.set_size(int(self.size * width * 0.01 * pango.SCALE))
+ desc.set_style(self.style)
+ desc.set_weight(self.weight)
+ layout.set_text(word.encode('utf-8'))
+ layout.set_font_description(desc)
+ layout.set_alignment(pango.ALIGN_CENTER)
+ rgba = self.textcolor.rgba
+ pango_ctx.set_source_rgba(rgba[0], rgba[1], rgba[2], rgba[3])
+ pango_ctx.update_layout(layout)
+
+ pixel_size = layout.get_pixel_size()
+ dx, dy = 0.5 * pixel_size[0], 0.9 * pixel_size[1]
+ pango_ctx.move_to((width * px) - dx, (height * py) - dy)
+ pango_ctx.show_layout(layout)
+ except:
+ traceback.print_exc(file=sys.__stderr__)
+ ka_debug.err('failed on pango [%s] [%s]' % \
+ (sys.exc_info()[0], sys.exc_info()[1]))
def explain(self, formater):
super(LetterPress, self).explain(formater)
diff --git a/ep_merger_mask.py b/ep_merger_mask.py
index 3322387..2f8f057 100644
--- a/ep_merger_mask.py
+++ b/ep_merger_mask.py
@@ -153,7 +153,7 @@ class MaskMerger(model_allele.Allele):
+ str(self.left_alphablending))
def explain_right(self, formater):
- pass
+ formater.text_item('Compositing used right node as a mask surface.')
def copy(self):
"""A copy constructor.
diff --git a/htmltextview.py b/htmltextview.py
index 7c9dac8..7198c4d 100644
--- a/htmltextview.py
+++ b/htmltextview.py
@@ -438,7 +438,6 @@ class HtmlTextView(gtk.TextView):
self.set_pixels_above_lines(3)
self.set_pixels_below_lines(3)
- print self.get_visible_rect().width
self.set_left_margin(HtmlTextView.LEFT_MARGIN)
def __size_allocate_event(self, widget, event):
diff --git a/ka_importer.py b/ka_importer.py
deleted file mode 100644
index ece269f..0000000
--- a/ka_importer.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# coding: UTF8
-# Copyright 2009 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
-# 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 os
-
-_rgb_image_list = []
-_alpha_image_list = []
-
-def _populate_image_list():
- #TODO use correct folder for user files
- image_path = '/home/strom/.sugar/1/net.sourceforge.kandid/instance'
- if 'SUGAR_BUNDLE_PATH' in os.environ:
- from sugar.activity import activity
- image_path = os.path.join(activity.get_activity_root(), 'instance')
- for element in os.listdir(image_path):
- if element.endswith('.png') or element.endswith('.PNG'):
- abs_name = os.path.join(image_path, element)
- if os.path.isfile(abs_name):
- if element.find('.alpha.') == -1:
- _rgb_image_list.append(abs_name)
- else:
- _alpha_image_list.append(abs_name)
-
-def get_rgb_image_list():
- if len(_rgb_image_list) == 0:
- _populate_image_list()
- return _rgb_image_list
-
-def get_alpha_image_list():
- if len(_alpha_image_list) == 0:
- _populate_image_list()
- return _alpha_image_list
diff --git a/ka_widget.py b/ka_widget.py
index e0f486e..676ff86 100644
--- a/ka_widget.py
+++ b/ka_widget.py
@@ -146,8 +146,8 @@ class KandidWidget(object):
@staticmethod
def get_localization():
""" returns localization and territory
- post: len(locale) >= 2
- post: len(territory) >= 2
+ post: len(__return__[0]) >= 2
+ post: len(__return__[1]) >= 2
"""
languages = []
territory, locale= '', ''
diff --git a/locale/de/intro.html b/locale/de/intro.html
index 943ee67..2a9d90d 100644
--- a/locale/de/intro.html
+++ b/locale/de/intro.html
@@ -109,7 +109,7 @@
in your population.
An other possibility is to decline or to ignore an incoming image.
Here you see white and pink colored images send from a friend.
- Maybe he prefers bright color. It is your desicission to integrate these
+ Maybe he prefers bright color. It is your decision to integrate these
to your 'earth tones' image population or just to ignore it.
<br/><img src="file:intro/incoming-protozoon-colormap.png" /><br/>
</li>
diff --git a/locale/en/intro.html b/locale/en/intro.html
index 943ee67..2a9d90d 100644
--- a/locale/en/intro.html
+++ b/locale/en/intro.html
@@ -109,7 +109,7 @@
in your population.
An other possibility is to decline or to ignore an incoming image.
Here you see white and pink colored images send from a friend.
- Maybe he prefers bright color. It is your desicission to integrate these
+ Maybe he prefers bright color. It is your decision to integrate these
to your 'earth tones' image population or just to ignore it.
<br/><img src="file:intro/incoming-protozoon-colormap.png" /><br/>
</li>
diff --git a/model_population.py b/model_population.py
index e3733e2..4e557e0 100644
--- a/model_population.py
+++ b/model_population.py
@@ -340,26 +340,6 @@ def write_file(file_path, model):
finally:
if out_file:
out_file.close()
- plain_file = None
- try:
- #import json
- plain_file = open(file_path+'.dot', 'w')
-# json_writer = KandidJsonWriter()
-# plain = json_writer.write(model)
-# plain = json.dumps(model, cls=KandidEncoder, indent=2)
- #plain_file.write(plain)
- ka_debug.dot_start()
- result = 'digraph persister_objects { rankdir=LR; ranksep="5.0"; node [shape=none,fontname=Sans, fontsize=9, fixedsize=true, height=0.05, width=1.0];\n'
- result += model.dot()
- result += '\n}'
- plain_file.write(result)
- except:
- traceback.print_exc(file=sys.__stderr__)
- ka_debug.err('failed writing [%s] [%s] [%s]' % \
- (file_path, sys.exc_info()[0], sys.exc_info()[1]))
- finally:
- if plain_file:
- plain_file.close()
def all_uniqe_reference(sequ):
# Brute force is all that's left.
diff --git a/po/msg_compile.sh b/po/msg_compile.sh
new file mode 100644
index 0000000..fd752b0
--- /dev/null
+++ b/po/msg_compile.sh
@@ -0,0 +1,10 @@
+cd ~/minimal/activities/Kandid.activity/po
+mkdir -vp ../locale/en/LC_MESSAGES
+msgfmt en.po --output='../locale/en/LC_MESSAGES/net.sourceforge.kandid.mo'
+
+mkdir -vp ../locale/de/LC_MESSAGES
+cp -vu ../locale/en/activity.linfo ../locale/de/
+msgfmt de.po --output='../locale/de/LC_MESSAGES/net.sourceforge.kandid.mo'
+
+find ../locale -name *.mo -ls
+find ../locale -name *.linfo -ls
diff --git a/setup.py b/setup.py
index adaba65..6ed89aa 100755
--- a/setup.py
+++ b/setup.py
@@ -1,20 +1,4 @@
-# coding: UTF8
-# Copyright 2009 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
-# 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
-
+#!/usr/bin/env python
from sugar.activity import bundlebuilder
-
bundlebuilder.start()
+
diff --git a/test_suite.py b/test_suite.py
index 444eb58..cd575b9 100644
--- a/test_suite.py
+++ b/test_suite.py
@@ -38,6 +38,7 @@ import exon_color
import exon_buzzword
import exon_direction
import exon_position
+import kandid
EPSILON = 0.00001
_test_task_completed_count = 0
@@ -88,18 +89,21 @@ class TestKandidModel(unittest.TestCase):
ka_task.GeneratorTask(self.task_2, self.on_completed).start()
time.sleep(5)
self.assertTrue(ka_task.GeneratorTask.is_completed())
- time.sleep(5)
- self.assertEqual(1, _test_task_completed_count)
+ #TODO gtk main loop is not running. on_completed will not be executed
+ #self.assertEqual(1, _test_task_completed_count)
def task_1(self, *args, **kwargs):
ka_task.GeneratorTask.leave()
+ print 'leave 1', _test_task_completed_count
def task_2(self, *args, **kwargs):
raise Exception
+ print 'leave 2', _test_task_completed_count
def on_completed(self, *args):
global _test_task_completed_count
_test_task_completed_count +=1
+ print 'on_completed', _test_task_completed_count
def test_merger(self):
self._run_ep_breed_test('merger')
@@ -443,6 +447,9 @@ class TestKandidModel(unittest.TestCase):
new_indices = model.breed()
self.assertTrue(5 in new_indices)
self.assertTrue(1 in new_indices)
+ model.fitness[2] = 0.0
+ new_indices = model.random()
+ self.assertTrue(2 in new_indices)
model.fitness[7] = 0.0
model.fitness[5] = 1.0
@@ -465,9 +472,18 @@ class TestKandidModel(unittest.TestCase):
ka_debug.dot_start()
result = 'digraph persister_objects { rankdir=LR; ranksep="5.0"; node [shape=none,fontname=Sans, fontsize=9, fixedsize=true, height=0.05, width=1.0];\n'
result += model.dot()
- result += '\n}'
- self.assertEqual(0, result.count('=red'))
-
+ result += '\n}'
+ plain_file = open(kandid.TESTMODEL+'.dot', 'w')
+ if plain_file:
+ plain_file.write(result)
+ plain_file.close()
+ red_count = result.count('color=red')
+ unicode_count = result.count('"unicode ')
+ self.assertTrue(unicode_count > red_count)
+
+ model_population.write_file(kandid.TESTMODEL, model)
+ recalled_model = model_population.read_file(kandid.TESTMODEL)
+
def test_incomming1(self):
incoming = ka_incoming.KandidIncoming(3)
self.assertEqual(0, len(incoming.incoming_protozoans))