Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
may not return a ('=' )
"""
try:
tokenList = map(str, timeString)
def notWhiteSpace(str):
return not str.isspace()
tokenList = filter(notWhiteSpace, tokenList)
tokenList = simplify(tokenList)
return parseStrictTokenList(tokenList)
except ValueError:
raise MalformedTimeString("Value error")
#print token
if token[0] == '=':
token = token[1:]
#get the unit
unit = token[-1]
#chop the unit off the token
token = token[:-1]
#use python's eval to turn the possibly signed number string into an integer
number = float(token)
#get the unit multiplier and if necessary raise an invalid unit error
try:
unitMult = units[unit]
except KeyError:
raise MalformedTimeString('Invalid Unit')
return int(unitMult*number)
"""given a list of strings each following the format '' return a tuple with the overall sign and number of seconds"""
secondCount = 0
overallSign = '+'
for token in tokenList:
if token[0] == '=':
overallSign = '='
secondCount += parseStrictToken(token)
if overallSign != '=':
if secondCount < 0:
overallSign = '-'
else:
overallSign = '+'
else:
if secondCount < 0:
raise MalformedTimeString('Absolute negative time')
return (overallSign, abs(secondCount))