Skip to content

Commit

Permalink
refs #121, renamed functions for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
synkarius committed Nov 2, 2015
1 parent d94b67e commit dc1e9df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion caster/lib/dfplus/additions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class IntegerContentST(IntegerContentBase):
builders = [int_0, int_1_9, int_10_19, int_20_99,
int_100s, int_100big, int_1000s, int_1000000s]
if "en" in language.language_map and settings.SETTINGS["miscellaneous"]["integer_remap_opt_in"]:
mapping = navigation.strange_numbers_map()
mapping = navigation.numbers_map_1_to_9()
IntegerContentST.builders[1] = MapIntBuilder(mapping)
INTEGER_CONTENT = IntegerContentST

Expand Down
2 changes: 1 addition & 1 deletion caster/lib/dfplus/state/actions2.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class FuzzyMatchAction(ContextSeeker):
default_1: speaking a next command other than a number or cancel activates the first choice in the list
;
'''
TEN = ["numb "+x for x in navigation.strange_numbers_list()+["ten"]]
TEN = ["numb "+x for x in navigation.numbers_list_1_to_9()+["ten"]]
def __init__(self, list_function, filter_function, selection_function, default_1=True, rspec="default", rdescript="unnamed command (FM)"):
def get_choices(data):
choices = list_function()
Expand Down
22 changes: 9 additions & 13 deletions caster/lib/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,7 @@ def word_number(wn):
}
Text(numbers_to_words[int(wn)]).execute()

def strange_numbers_map():
return {
"one": 1,
"torque": 2,
"traio": 3,
"fairn": 4,
"faif": 5,
"six": 6,
"seven": 7,
"eigen": 8,
"nine": 9,
}
def strange_numbers_list():
def numbers_list_1_to_9():
result=["one",
"torque",
"traio",
Expand All @@ -109,6 +97,14 @@ def strange_numbers_list():
result[7]="eight"
return result

def numbers_map_1_to_9():

This comment has been minimized.

Copy link
@chilimangoes

chilimangoes Nov 2, 2015

Collaborator

FYI, you can refactor this method as a one line comprehension like so:

return {n:s for n,s in zip(range(1, len(l)+1), l)}

This has the added benefit of working regarles of the size of l.

result = {}
l = numbers_list_1_to_9()
for i in range(0, 9):
result[l[i]] = i+1
return result


def numbers2(wnKK):
Text(str(wnKK)).execute()

Expand Down

0 comments on commit dc1e9df

Please sign in to comment.