From 70f57c4ce7113f2741381946708a146f27964958 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 11 Dec 2010 09:55:07 -0500 Subject: [PATCH] filled out Command.parseCommandLine() --- Command.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Command.py b/Command.py index 1f2f29a..2861c7e 100644 --- a/Command.py +++ b/Command.py @@ -1,4 +1,6 @@ +from datetime import datetime + class Command: def __init__(self, timenow, cmdline): self.time = timenow @@ -6,4 +8,29 @@ class Command: 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