mirror of https://github.com/craigerl/aprsd.git
Cleaned up trailing whitespace
This commit is contained in:
parent
7dc1c5d8fd
commit
60fa3ffcd4
|
@ -23,38 +23,38 @@ def fuzzy(hour, minute, degree=1):
|
||||||
Supports two degrees of fuzziness. Set with degree = 1 or degree = 2
|
Supports two degrees of fuzziness. Set with degree = 1 or degree = 2
|
||||||
When degree = 1, time is in quantum of 5 minutes.
|
When degree = 1, time is in quantum of 5 minutes.
|
||||||
When degree = 2, time is in quantum of 15 minutes.'''
|
When degree = 2, time is in quantum of 15 minutes.'''
|
||||||
|
|
||||||
if degree<=0 or degree>2:
|
if degree<=0 or degree>2:
|
||||||
print 'Please use a degree of 1 or 2. Using fuzziness degree=1'
|
print 'Please use a degree of 1 or 2. Using fuzziness degree=1'
|
||||||
degree = 1
|
degree = 1
|
||||||
|
|
||||||
begin = 'It\'s '
|
begin = 'It\'s '
|
||||||
|
|
||||||
f0 = 'almost '
|
f0 = 'almost '
|
||||||
f1 = 'exactly '
|
f1 = 'exactly '
|
||||||
f2 = 'around '
|
f2 = 'around '
|
||||||
|
|
||||||
b0 = ' past '
|
b0 = ' past '
|
||||||
b1 = ' to '
|
b1 = ' to '
|
||||||
|
|
||||||
hourList = ('One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve')
|
hourList = ('One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve')
|
||||||
|
|
||||||
s1 = s2 = s3 = s4 = ''
|
s1 = s2 = s3 = s4 = ''
|
||||||
base = 5
|
base = 5
|
||||||
|
|
||||||
if degree == 1:
|
if degree == 1:
|
||||||
base = 5
|
base = 5
|
||||||
val = ('Five', 'Ten', 'Quarter', 'Twenty', 'Twenty-Five', 'Half')
|
val = ('Five', 'Ten', 'Quarter', 'Twenty', 'Twenty-Five', 'Half')
|
||||||
elif degree == 2:
|
elif degree == 2:
|
||||||
base = 15
|
base = 15
|
||||||
val = ('Quarter', 'Half')
|
val = ('Quarter', 'Half')
|
||||||
|
|
||||||
dmin = minute % base # to find whether we have to use 'almost', 'exactly' or 'around'
|
dmin = minute % base # to find whether we have to use 'almost', 'exactly' or 'around'
|
||||||
if minute > 30:
|
if minute > 30:
|
||||||
pos = int((60 - minute) / base) #position in the tuple 'val'
|
pos = int((60 - minute) / base) #position in the tuple 'val'
|
||||||
else:
|
else:
|
||||||
pos = int(minute / base)
|
pos = int(minute / base)
|
||||||
|
|
||||||
if dmin == 0:
|
if dmin == 0:
|
||||||
s1 = f1
|
s1 = f1
|
||||||
pos = pos - 1
|
pos = pos - 1
|
||||||
|
@ -66,9 +66,9 @@ def fuzzy(hour, minute, degree=1):
|
||||||
s1 = f0
|
s1 = f0
|
||||||
if minute > 30:
|
if minute > 30:
|
||||||
pos = pos -1
|
pos = pos -1
|
||||||
|
|
||||||
s2 = val[pos]
|
s2 = val[pos]
|
||||||
|
|
||||||
if minute <= base/2: # Case like "It's around/exactly Ten"
|
if minute <= base/2: # Case like "It's around/exactly Ten"
|
||||||
s2 = s3 = ''
|
s2 = s3 = ''
|
||||||
s4 = hourList[hour - 12 - 1]
|
s4 = hourList[hour - 12 - 1]
|
||||||
|
@ -82,7 +82,7 @@ def fuzzy(hour, minute, degree=1):
|
||||||
else:
|
else:
|
||||||
s3 = b0 # past
|
s3 = b0 # past
|
||||||
s4 = hourList[hour - 12 - 1]
|
s4 = hourList[hour - 12 - 1]
|
||||||
|
|
||||||
return begin + s1 + s2 + s3 + s4
|
return begin + s1 + s2 + s3 + s4
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -90,13 +90,13 @@ def main():
|
||||||
stm = time.localtime()
|
stm = time.localtime()
|
||||||
h = stm.tm_hour
|
h = stm.tm_hour
|
||||||
m = stm.tm_min
|
m = stm.tm_min
|
||||||
|
|
||||||
if len(sys.argv)>=2:
|
if len(sys.argv)>=2:
|
||||||
try:
|
try:
|
||||||
deg = int(sys.argv[1])
|
deg = int(sys.argv[1])
|
||||||
except:
|
except:
|
||||||
print 'Please use a degree of 1 or 2. Using fuzziness degree=1'
|
print 'Please use a degree of 1 or 2. Using fuzziness degree=1'
|
||||||
|
|
||||||
if len(sys.argv)>=3:
|
if len(sys.argv)>=3:
|
||||||
tm = sys.argv[2].split(':')
|
tm = sys.argv[2].split(':')
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue