changeset 230:7b71406a5baf

text_x_arnica: refactored get_quotes
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 02 Sep 2008 10:07:13 +0200
parents 6cc67d4f27cb
children c8897e9950a1
files data/plugin/parser/text_x_arnica.py
diffstat 1 files changed, 7 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/parser/text_x_arnica.py	Tue Sep 02 09:21:28 2008 +0200
+++ b/data/plugin/parser/text_x_arnica.py	Tue Sep 02 10:07:13 2008 +0200
@@ -328,15 +328,10 @@
         @param files: file names of images
         @param quotes: text alias for image file
         """
-        ddict = {}
-        if quotes['image']:
-            i = 0
-            for txt in quotes['image']:
-                ddict[txt] = quotes['alias'][i]
-                i += 1
+
         for attfile in files:
             # only files not thumb_key or webnails
-            self.description.append(ddict.get(attfile, attfile))
+            self.description.append(quotes.get(attfile, attfile))
             self.high_resolution_image.append(attfile)
             fname, ext = os.path.splitext(attfile)
             key = cache.key(self.request, itemname=self.pagename, attachname=attfile)
@@ -369,19 +364,12 @@
         quotes = self.raw.split('\n')
         quotes = [quote.strip() for quote in quotes]
         quotes = [quote[2:] for quote in quotes if quote.startswith('* ')]
-        image = []
-        text = []
+        image_alias = {}
         for line in quotes:
             if line.startswith('[[') and line.endswith(']]'):
                 img, alias = line[2:-2].split('|', 1)
-                alias = alias.strip()
-                alias = self.formatter.text(alias)
-                text.append(alias)
-                image.append(img.strip())
-        return {
-            'alias': text,
-            'image': image,
-        }
+                image_alias[img.strip()] = self.formatter.text(alias.strip())
+        return image_alias
 
     def select_files(self, formatter):
         """ select files """
@@ -394,11 +382,11 @@
         image_dict = {}
         quotes = self.get_quotes()
         if self.only_items:
-            files = quotes['image']
+            files = quotes.keys()
             all_files = [fn for fn in files if wikiutil.isPicture(fn) and
                          AttachFile.exists(self.request, self.pagename, fn)]
             if self.sort_by_alias:
-                alias_text = quotes['alias']
+                alias_text = quotes.values()
                 i = 0
                 for attfile in all_files:
                     image_dict[alias_text[i]] = attfile