How to use the pydeps.timestring.MalformedTimeString function in pydeps

To help you get started, we’ve selected a few pydeps examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MorganBorman / cxsbs / pydeps / timestring.py View on Github external
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")
github MorganBorman / cxsbs / pydeps / timestring.py View on Github external
#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)
github MorganBorman / cxsbs / pydeps / timestring.py View on Github external
"""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))