← Back to team overview

team4alfanous team mailing list archive

[Branch ~team4alfanous/alfanous/alfanous-git] Rev 319: fix a problem in the interval start of results when there is only one results, total=1

 

------------------------------------------------------------
revno: 319
committer: Assem Chelli <assem.ch@xxxxxxxxx>
timestamp: Fri 2012-08-24 09:58:42 +0100
message:
  fix a problem in the interval start of results when there is only one results, total=1
modified:
  src/alfanous/Outputs.py


--
lp:alfanous
https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git

Your team Alfanous team is subscribed to branch lp:alfanous.
To unsubscribe from this branch go to https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git/+edit-subscription
=== modified file 'src/alfanous/Outputs.py'
--- src/alfanous/Outputs.py	2012-08-20 15:51:46 +0000
+++ src/alfanous/Outputs.py	2012-08-24 08:58:42 +0000
@@ -24,6 +24,7 @@
 FIXME vocalization_dict[terms[1]], test key existance before use
 TODO include suggestions with search results
 TODO +flag language
+FIXME how to select the translation attached to results, what ID? 
 
 """
 
@@ -353,7 +354,7 @@
 		range = self._defaults["maxrange"] if range > self._defaults["maxrange"] else range;
 		interval_end = offset + range
 		end = interval_end if interval_end < len( res ) else len( res )
-		start = offset if offset < len( res ) else -1
+		start = offset if offset <= len( res ) else -1
 		reslist = [] if end == 0 or start == -1 else list( res )[start-1:end]
 		output = {}
 
@@ -483,7 +484,7 @@
 		              		"id":r["aya_id"],
 		              		"text":  Gword_tamdid( H( V( r["aya_"] ) ) ) if script == "standard"
 		              			else  Gword_tamdid( H( r["uth_"] ) ),
-		                	"translation": trad_text[r["gid"]] if ( translation != "None" and translation ) else None,
+						"translation": trad_text[r["gid"]] if ( translation != "None" and translation and trad_text.has_key(r["gid"])) else None,
 		                	"recitation": None if not recitation else u"http://www.everyayah.com/data/"; + self._recitations[recitation]["subfolder"].encode( "utf-8" ) + "/%03d%03d.mp3" % ( r["sura_id"], r["aya_id"] ),
 		                	"prev_aya":{
 						    "id":adja_ayas[r["gid"] - 1]["aya_id"],