Command constructor: default_time optional
This commit is contained in:
parent
67a04df59a
commit
78cb101357
@ -3,7 +3,10 @@ from datetime import datetime, timedelta
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
class Command:
|
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.time = default_time
|
||||||
self.command = 'start'
|
self.command = 'start'
|
||||||
self.argstr = ''
|
self.argstr = ''
|
||||||
|
5
dwtt
5
dwtt
@ -3,7 +3,6 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from CmdWindow import CmdWindow
|
from CmdWindow import CmdWindow
|
||||||
from Command import Command
|
from Command import Command
|
||||||
@ -24,8 +23,6 @@ def main(argv):
|
|||||||
usage()
|
usage()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
timenow = datetime.now()
|
|
||||||
|
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt == "--help":
|
if opt == "--help":
|
||||||
usage()
|
usage()
|
||||||
@ -41,7 +38,7 @@ def main(argv):
|
|||||||
ds = DataStore(timedbfile)
|
ds = DataStore(timedbfile)
|
||||||
|
|
||||||
cmdline = doCmdWindow()
|
cmdline = doCmdWindow()
|
||||||
cmd = Command(timenow, cmdline)
|
cmd = Command(cmdline)
|
||||||
print "Command:", cmd
|
print "Command:", cmd
|
||||||
|
|
||||||
def doCmdWindow():
|
def doCmdWindow():
|
||||||
|
2
test
2
test
@ -10,7 +10,7 @@ def testcmd(cmdline, cmd, argstr):
|
|||||||
global n_tests, n_pass
|
global n_tests, n_pass
|
||||||
n_tests += 1
|
n_tests += 1
|
||||||
print "Testing command line '%s'" % cmdline
|
print "Testing command line '%s'" % cmdline
|
||||||
c = Command(datetime.now(), cmdline)
|
c = Command(cmdline)
|
||||||
if c.command == cmd and c.argstr == argstr:
|
if c.command == cmd and c.argstr == argstr:
|
||||||
n_pass += 1
|
n_pass += 1
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user