From 78cb10135796a154e11b49ee886603127da28d9a Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 1 Jan 2011 17:51:04 -0500 Subject: [PATCH] Command constructor: default_time optional --- Command.py | 7 +++++-- dwtt | 5 +---- test | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Command.py b/Command.py index 18b9435..6fb6a5c 100644 --- a/Command.py +++ b/Command.py @@ -3,8 +3,11 @@ from datetime import datetime, timedelta import re class Command: - def __init__(self, default_time, cmdline): - self.time = default_time + 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 = '' self.parseCommandLine(cmdline) diff --git a/dwtt b/dwtt index 17da4aa..3b5f8ca 100755 --- a/dwtt +++ b/dwtt @@ -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(): diff --git a/test b/test index e43c0c0..3aa0cc3 100755 --- a/test +++ b/test @@ -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: