Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/utils.py
diff options
context:
space:
mode:
authorAlan Aguiar <alanjas@hotmail.com>2012-06-04 04:31:17 (GMT)
committer Alan Aguiar <alanjas@hotmail.com>2012-06-04 04:31:17 (GMT)
commit289f612c704ebb0675d12736c06ae2de4509e58e (patch)
tree3cb74d26ee0da22189dc1bfd6ea57c05ee706fe7 /utils.py
parent654db1a43637652e7fae8b588d5f46472c6ad1c5 (diff)
re-use the icons to increase search speed
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/utils.py b/utils.py
index 17e2f4a..36a8af9 100644
--- a/utils.py
+++ b/utils.py
@@ -66,7 +66,7 @@ def get_store_list():
line = line.replace('\n', '')
l = line.split('|')
store_list.append(l)
- print store_list
+
return store_list
@@ -74,15 +74,14 @@ def get_icon(activity_id):
"""Get the icon of an specified activity"""
store_list = get_store_list()
activity_obj = store_list[activity_id]
-
- link = 'http://activities.sugarlabs.org/en-US/sugar/images/addon_icon/'
- url = link + activity_obj[0]
-
- #url = activity_obj["Icon"]
- file = "%s/icon%s" % (TMP_DIR, time.time())
-
- fileimage, headers = urllib.urlretrieve(url, file)
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(fileimage, 45, 45)
+ number = activity_obj[0]
+
+ file_image = os.path.join(TMP_DIR, "icon%s" % number)
+ if not os.path.exists(file_image):
+ url = 'http://activities.sugarlabs.org/en-US/sugar/images/addon_icon/' + number
+ f, headers = urllib.urlretrieve(url, file_image)
+
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(file_image, 45, 45)
return pixbuf