Command constructor: default_time optional

This commit is contained in:
Josh Holtrop 2011-01-01 17:51:04 -05:00
parent 67a04df59a
commit 78cb101357
3 changed files with 7 additions and 7 deletions

View File

@ -3,7 +3,10 @@ from datetime import datetime, timedelta
import re
class Command:
def __init__(self, default_time, cmdline):
def __init__(self, cmdline, default_time = None):
if default_time is None:
self.time = datetime.now()
else:
self.time = default_time
self.command = 'start'
self.argstr = ''

5
dwtt
View File

@ -3,7 +3,6 @@
import os
import sys
import getopt
from datetime import datetime
from CmdWindow import CmdWindow
from Command import Command
@ -24,8 +23,6 @@ def main(argv):
usage()
sys.exit(1)
timenow = datetime.now()
for opt, arg in opts:
if opt == "--help":
usage()
@ -41,7 +38,7 @@ def main(argv):
ds = DataStore(timedbfile)
cmdline = doCmdWindow()
cmd = Command(timenow, cmdline)
cmd = Command(cmdline)
print "Command:", cmd
def doCmdWindow():

2
test
View File

@ -10,7 +10,7 @@ def testcmd(cmdline, cmd, argstr):
global n_tests, n_pass
n_tests += 1
print "Testing command line '%s'" % cmdline
c = Command(datetime.now(), cmdline)
c = Command(cmdline)
if c.command == cmd and c.argstr == argstr:
n_pass += 1
else: