From 2b70f37fbd9eba4413dbb80351104aa9b6f3ea66 Mon Sep 17 00:00:00 2001 From: Assim Deodia Date: Thu, 03 Jul 2008 16:50:55 +0000 Subject: LaS init function modified --- diff --git a/dict.py b/dict.py index 47032be..799912b 100644 --- a/dict.py +++ b/dict.py @@ -1,23 +1,22 @@ #!/bin/env python import sys import random +import sqlite3 # Provides the API to control the dictionary. global __debug -global DBname -global word_list - - __debug = True -DBname = "dict.db" -word_list = [] + class Dict: - def __init__(self): + def __init__(self, sqliteDB = None): - import sqlite3 - self.conn = sqlite3.connect(DBname, isolation_level=None) + if sqliteDB == None: + return False + global DBname + DBname = sqliteDB + self.conn = sqlite3.connect(sqliteDB, isolation_level=None) # Turn on autocommit mode # Set isolation_level to "IMMEDIATE" self.conn.isolation_level = "IMMEDIATE" @@ -49,11 +48,14 @@ class Dict: randids = random.sample(self.wordid_list , numwords) return randids + + def get_DB_name(self): + return class Word: def __init__(self, identifier=None, value= None): - import sqlite3 + self.conn = sqlite3.connect(DBname, isolation_level=None) # Turn on autocommit mode # Set isolation_level to "IMMEDIATE" diff --git a/las.py b/las.py index f9bb3be..3423e8a 100644 --- a/las.py +++ b/las.py @@ -44,7 +44,7 @@ class _GetchWindows: class Listenspell(): - def __init__(self): + def __init__(self, SQLiteDB): self.skill_level = 0 self.level_threshold = 5 @@ -52,12 +52,11 @@ class Listenspell(): self.words_played = 0 self.words_correct = 0 self.init = False - self.dict_obj = Dict() + self.dict_obj = Dict(SQLiteDB) #Always intitiate first Dict object then Word object self.word_obj = Word() def start_speechd(self): # Currently not in use have to manually start sugar-speechd - import os pid = os.fork() if pid: return @@ -122,7 +121,6 @@ class Listenspell(): def get_word_info(self,wordid, attribute): if self.word_obj.get_wordid() != wordid: self.word_obj.__init__(identifier = "wordid", value= wordid) - print "Hello Again" self.words_played = self.words_played + 1 if attribute == "def": @@ -147,7 +145,6 @@ class Listenspell(): def get_key(self): for longestinput in range(15): inkey = _Getch() - import sys for i in xrange(sys.maxint): k=inkey() if k<>'':break diff --git a/ls.py b/ls.py index 52b0a34..ce0521c 100644 --- a/ls.py +++ b/ls.py @@ -106,7 +106,7 @@ def get_skill_level(): if __name__=='__main__': - las = Listenspell() + las = Listenspell("dict.db") las.clear_screen() las.play_sound("begin") @@ -131,7 +131,7 @@ if __name__=='__main__': ## print pronouncelist wordid = wordidlist[index] result = play_word(wordid) - print "Your score is " + str(las.getpoints()) + print "Your score is " + str(las.get_points()) if result == True: if las.get_words_correct == 7: @@ -149,5 +149,4 @@ if __name__=='__main__': gameover = True las.say_text("Game Over") print "Game Over." - las.exit_game() - + las.exit_game() \ No newline at end of file diff --git a/sugar-speechd b/sugar-speechd new file mode 100755 index 0000000..c5f271a --- /dev/null +++ b/sugar-speechd Binary files differ -- cgit v0.9.1