diff options
Diffstat (limited to 'kayleevc')
-rw-r--r-- | kayleevc/gui.py | 8 | ||||
-rw-r--r-- | kayleevc/numbers.py | 19 | ||||
-rw-r--r-- | kayleevc/util.py | 3 |
3 files changed, 21 insertions, 9 deletions
diff --git a/kayleevc/gui.py b/kayleevc/gui.py index 3369e33..27085a8 100644 --- a/kayleevc/gui.py +++ b/kayleevc/gui.py @@ -10,9 +10,11 @@ from gi.repository import GObject gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gdk + class GTKTrayInterface(GObject.GObject): __gsignals__ = { - 'command' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_STRING,)) + 'command' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, + (GObject.TYPE_STRING,)) } idle_text = "Kaylee - Idle" listening_text = "Kaylee - Listening" @@ -106,9 +108,11 @@ class GTKTrayInterface(GObject.GObject): def set_icon_inactive(self): self.statusicon.set_from_file(self.icon_inactive) + class GTKInterface(GObject.GObject): __gsignals__ = { - 'command' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_STRING,)) + 'command': (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, + (GObject.TYPE_STRING,)) } def __init__(self, args, continuous): diff --git a/kayleevc/numbers.py b/kayleevc/numbers.py index 6d41b63..cb52728 100644 --- a/kayleevc/numbers.py +++ b/kayleevc/numbers.py @@ -6,8 +6,10 @@ import re -# Define the mappings from words to numbers + class NumberParser: + """Parses integers from English strings""" + zero = { 'zero': 0 } @@ -81,12 +83,7 @@ class NumberParser: self.number_words.append(word) def parse_number(self, text_line): - """ - Parse numbers from natural language into ints - - TODO: Throw more exceptions when invalid numbers are detected. Only - allow certian valueless words within numbers. Support zero. - """ + """Parse a number from English into an int""" value = 0 partial_value = 0 last_list = None @@ -136,6 +133,13 @@ class NumberParser: return value def parse_all_numbers(self, text_line): + """ + Parse all numbers from English to ints + + Returns a tuple whose first element is text_line with all English + numbers replaced with "%d", and whose second element is a list + containing all the parsed numbers as ints. + """ nums = [] t_numless = '' @@ -168,6 +172,7 @@ class NumberParser: return (t_numless.strip(), nums) + if __name__ == '__main__': np = NumberParser() # Get the words to translate diff --git a/kayleevc/util.py b/kayleevc/util.py index 5c93b7f..8e33629 100644 --- a/kayleevc/util.py +++ b/kayleevc/util.py @@ -13,6 +13,7 @@ import requests from gi.repository import GLib + class Config: """Keep track of the configuration of Kaylee""" # Name of the program, for later use @@ -93,6 +94,7 @@ class Config: # Make an empty options namespace self.options = Namespace() + class Hasher: """Keep track of hashes for Kaylee""" @@ -123,6 +125,7 @@ class Hasher: with open(self.config.hash_file, 'w') as f: json.dump(self.hashes, f) + class LanguageUpdater: """ Handles updating the language using the online lmtool. |