Always use function version of print()

This commit is contained in:
Jim Paris 2013-01-03 16:58:26 -05:00
parent 41b3f3c018
commit 06e91a6a98
3 changed files with 8 additions and 13 deletions
nilmdb
cmdline
utils
tests

View File

@ -1,4 +1,5 @@
from __future__ import absolute_import
from __future__ import print_function
from nilmdb.utils.printf import *
import nilmdb.client
import sys
@ -50,7 +51,7 @@ def cmd_extract(self):
# Strip timestamp (first element). Doesn't make sense
# if we are only returning a count.
dataline = ' '.join(dataline.split(' ')[1:])
print dataline
print(dataline)
printed = True
if not printed:
if self.args.annotate:

View File

@ -5,6 +5,7 @@
# with nilmdb.Timer("flush"):
# foo.flush()
from __future__ import print_function
import contextlib
import time
@ -18,4 +19,4 @@ def Timer(name = None, tosyslog = False):
import syslog
syslog.syslog(msg)
else:
print msg
print(msg)

View File

@ -51,7 +51,7 @@ class TestCmdline(object):
"""Run a cmdline client with the specified argument string,
passing the given input. Returns a tuple with the output and
exit code"""
#print "TZ=UTC ./nilmtool.py " + arg_string
# printf("TZ=UTC ./nilmtool.py %s\n", arg_string)
class stdio_wrapper:
def __init__(self, stdin, stdout, stderr):
self.io = (stdin, stdout, stderr)
@ -298,16 +298,9 @@ class TestCmdline(object):
eq_(cmd.parse_time("hi there 20120405 1400-0400 testing! 123"), test)
eq_(cmd.parse_time("20120405 1800 UTC"), test)
eq_(cmd.parse_time("20120405 1400-0400 UTC"), test)
with assert_raises(ValueError):
print cmd.parse_time("20120405 1400-9999")
with assert_raises(ValueError):
print cmd.parse_time("hello")
with assert_raises(ValueError):
print cmd.parse_time("-")
with assert_raises(ValueError):
print cmd.parse_time("")
with assert_raises(ValueError):
print cmd.parse_time("14:00")
for badtime in [ "20120405 1400-9999", "hello", "-", "", "14:00" ]:
with assert_raises(ValueError):
x = cmd.parse_time(badtime)
eq_(cmd.parse_time("snapshot-20120405-140000.raw.gz"), test)
eq_(cmd.parse_time("prep-20120405T1400"), test)