diff options
author | Assim Deodia <assim.deodia@gmail.com> | 2008-07-03 16:50:55 (GMT) |
---|---|---|
committer | Assim Deodia <assim.deodia@gmail.com> | 2008-07-03 16:50:55 (GMT) |
commit | 2b70f37fbd9eba4413dbb80351104aa9b6f3ea66 (patch) | |
tree | dc6ffc8db34296160db6c13c97acb8e5c8abfd65 | |
parent | 374c6b082614bfdb26ce6241ab1d7e18dad5acb3 (diff) |
LaS init function modified
-rw-r--r-- | dict.py | 22 | ||||
-rw-r--r-- | las.py | 7 | ||||
-rw-r--r-- | ls.py | 7 | ||||
-rwxr-xr-x | sugar-speechd | bin | 0 -> 22166 bytes |
4 files changed, 17 insertions, 19 deletions
@@ -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" @@ -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 @@ -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 Binary files differnew file mode 100755 index 0000000..c5f271a --- /dev/null +++ b/sugar-speechd |