from datetime import datetime class Command: def __init__(self, timenow, cmdline): self.time = timenow self.command = 'start' self.parseCommandLine(cmdline) def parseCommandLine(self, cmdline): COMMANDS = { 'out' : 1, 'report' : 1, 'show' : 1, 'fill' : 1, 'adjust' : 1 } parts = cmdline.split(None, 1) if len(parts) > 1: timespec = parts[0].strip() if timespec[0] == '@': self.time = self.parseTimeSpec(timespec[1:]) parts = parts[1:] if len(parts) == 1: command = parts[0].strip() rest = '' else: command, rest = parts if command in COMMANDS: self.command = command self.argstr = rest.strip() else: self.argstr = ' '.join([command, rest]).strip() def parseTimeSpec(self, timespec): pass