Esempio n. 1
0
def on_resume( args, config ):
	with Worklog( when = args.day, config = config ) as worklog:
		start = resolve_at_or_ago( args, date = worklog.when )
		descriptions = list()
		for description in reversed( [ task.description for task in worklog if isinstance( task, Task ) ] ):
			if description not in descriptions:
				descriptions.append( description )
		# when using resume, it means we're no longer working on the description that is now the first
		# item in this list, because of how we've sorted it. It is quite inconvenient for the first
		# choice to be the one we know for sure the user won't pick, bump it to the end of the line
		most_recent_description = descriptions.pop( 0 )
		descriptions.append( most_recent_description )
		for idx, description in enumerate( descriptions ):
			print( '[{:d}] {}'.format( idx, description ) )
		description = None
		while description is None:
			try:
				idx = int( input( "Which description: " ) )
				description = descriptions[idx]
				for task in worklog:
					if task.description == description:
						ticket = task.ticket
			except KeyboardInterrupt:
				raise Abort()
			except EOFError:
				raise Abort()
			except ( ValueError, IndexError ):
				print( 'Must be an integer between 0 and {:d}'.format( len( descriptions ) ) )
		worklog.insert( Task( start = start, ticket = ticket, description = description, logged = True, config = config ) )
	print( Report( worklog, config ) )
Esempio n. 2
0
def on_start( args, config ):
	with Worklog( when = args.day, config = config ) as worklog:
		start = resolve_at_or_ago( args, date = worklog.when )
		ticket = args.ticket
		description = ' '.join( args.description )
		while len( description.strip() ) == 0:
			try:
				description = input( 'Task description: ' )
			except KeyboardInterrupt:
				raise Abort()
			except EOFError:
				raise Abort()
		worklog.insert( Task( start = start, ticket = ticket, description = description, logged = False, config = config ) )
	print( Report( worklog, config ) )
Esempio n. 3
0
def on_stop( args, config ):
	with Worklog( when = args.day, config = config ) as worklog:
		worklog.insert( GoHome( start = resolve_at_or_ago( args, date = worklog.when ) ) )
	print( Report( worklog, config ) )
Esempio n. 4
0
def on_report( args, config ):
	with Worklog( when = args.day, config = config ) as worklog:
		print( Report( worklog, config ) )
Esempio n. 5
0
def report( args, config ):
	with Worklog( when = args.day, config = config ) as worklog:
		report = Report( worklog, config )
	return report