chrono.py: 0 est équivalent à la chaine vide
This commit is contained in:
parent
9c5b46b372
commit
6130c2ff7f
|
@ -32,6 +32,12 @@ def playSound(name=None):
|
|||
|
||||
def isnum(i):
|
||||
return type(i) in (IntType, LongType)
|
||||
RE_NUM = re.compile(r'\d+$')
|
||||
def numof(s):
|
||||
if isnum(s): return s
|
||||
elif s is None: return None
|
||||
elif RE_NUM.match(str(s)) is not None: return int(str(s))
|
||||
else: return s
|
||||
|
||||
DEFAULT_TIMEOUT = '5'
|
||||
|
||||
|
@ -99,11 +105,13 @@ class Chrono:
|
|||
return Timedelta(seconds=timeout)
|
||||
|
||||
def set_timeout(self, timeout=None):
|
||||
if timeout == '': timeout = None
|
||||
if timeout is not None and not isnum(timeout):
|
||||
tmp = parse_desthour(str(timeout))
|
||||
if tmp is None: tmp = parse_timeout(timeout)
|
||||
if tmp is None: tmp = int(timeout) * 60
|
||||
timeout = tmp
|
||||
if timeout == 0: timeout = None
|
||||
self.timeout = timeout
|
||||
if timeout is None: self.initial = '00:00'
|
||||
else: self.initial = self.__format(self.__delta(timeout))
|
||||
|
@ -334,7 +342,6 @@ d'arrivée, et que la durée est calculée automatiquement""")
|
|||
|
||||
timeout = o.timeout
|
||||
if timeout is None: timeout = DEFAULT_TIMEOUT
|
||||
elif timeout == '': timeout = None
|
||||
o.timeout = timeout
|
||||
|
||||
run_chronometre(o.timeout, o.autostart)
|
||||
|
|
Loading…
Reference in New Issue