Update Advanced Search again!

bzr-revno: 342
This commit is contained in:
Tim Bentley 2009-02-23 19:03:26 +00:00
parent 5fc7e69cb2
commit 8a01d651c0
1 changed files with 26 additions and 18 deletions

View File

@ -497,7 +497,6 @@ class BiblePlugin(Plugin, PluginUtils):
start_verse="" start_verse=""
end_verse="" end_verse=""
search.replace(" ", " ") search.replace(" ", " ")
search = search.rstrip()
original = search original = search
message = None message = None
# Remove book # Remove book
@ -508,6 +507,7 @@ class BiblePlugin(Plugin, PluginUtils):
break break
search = search.replace("v", ":") # allow V or v for verse instead of : search = search.replace("v", ":") # allow V or v for verse instead of :
search = search.replace("V", ":") # allow V or v for verse instead of : search = search.replace("V", ":") # allow V or v for verse instead of :
search = search.strip()
co = search.find(":") co = search.find(":")
if co == -1: # no : found if co == -1: # no : found
i = search.rfind(" ") i = search.rfind(" ")
@ -522,21 +522,29 @@ class BiblePlugin(Plugin, PluginUtils):
else: else:
start_chapter = chapter start_chapter = chapter
else: # more complex else: # more complex
co = search.find(":") #find first print search
start_chapter = search[:co] #first chapter is before colon sp = search.split("-") #find first
search = search [co+1:] #remove first chapter and colon print sp, len(sp)
hi = search.find("-") sp1 = sp[0].split(":")
if hi != -1: print sp1, len(sp1)
start_verse= search[:hi] if len(sp1) == 1:
search = search[hi+1:] start_chapter = sp1[0]
co = search.find(":") start_verse = 1
if co != -1:
end_chapter= search[:co].rstrip()
end_verse = search[co+1:].rstrip()
else:
end_verse = search.rstrip()
else: else:
end_verse = search.rstrip() start_chapter = sp1[0]
start_verse = sp1[1]
if len(sp)== 1:
end_chapter = start_chapter
end_verse = start_verse
else:
sp1 = sp[1].split(":")
print sp1, len(sp1)
if len(sp1) == 1:
end_chapter = sp1[0]
end_verse = 1
else:
end_chapter = sp1[0]
end_verse = sp1[1]
if end_chapter == "": if end_chapter == "":
end_chapter = start_chapter.rstrip() end_chapter = start_chapter.rstrip()
if start_verse == "": if start_verse == "":
@ -548,9 +556,9 @@ class BiblePlugin(Plugin, PluginUtils):
end_verse = 99 end_verse = 99
if start_chapter == "": if start_chapter == "":
message = "No chapter found for search" message = "No chapter found for search"
#print "message = " + str(message) print "message = " + str(message)
#print "search = " + str(original) print "search = " + str(original)
#print "results = " + str(book) + " @ "+ str(start_chapter)+" @ "+ str(end_chapter)+" @ "+ str(start_verse)+ " @ "+ str(end_verse) print "results = " + str(book) + " @ "+ str(start_chapter)+" @ "+ str(end_chapter)+" @ "+ str(start_verse)+ " @ "+ str(end_verse)
if message == None: if message == None:
self.search_results = None self.search_results = None