Permalink
Browse files

python 3 compatibility

  • Loading branch information...
1 parent bd2b577 commit 452770331217f46f37d2de976fb5d8b0b24fb831 @dirk-thomas dirk-thomas committed Oct 23, 2013
View
@@ -87,7 +87,8 @@ def compute_md5_text(msg_context, spec):
sub_md5 = compute_md5(msg_context, sub_spec)
buff.write("%s %s\n"%(sub_md5, name))
- return buff.getvalue().strip() # remove trailing new line
+ value = buff.getvalue().strip() # remove trailing new line
+ return value.encode()
def _compute_hash(msg_context, spec, hash):
"""
@@ -71,7 +71,7 @@ def _generate_from_spec(input_file, output_dir, template_dir, msg_context, spec,
if not os.path.isfile(template_file):
ofile.close()
os.remove(output_file)
- raise RuntimeError, "Template file %s not found in template dir %s" % (template_file_name, template_dir)
+ raise RuntimeError("Template file %s not found in template dir %s" % (template_file_name, template_dir))
interpreter.file(open(template_file)) #todo try
interpreter.shutdown()
@@ -171,7 +171,7 @@ def generate_module(package_name, output_dir, template_dir, template_dict):
if not os.path.isfile(template_file):
ofile.close()
os.remove(output_file)
- raise RuntimeError, "Template file %s not found in template dir %s" % (template_file_name, template_dir)
+ raise RuntimeError("Template file %s not found in template dir %s" % (template_file_name, template_dir))
interpreter.file(open(template_file)) #todo try
interpreter.shutdown()
@@ -105,7 +105,7 @@ def test_compute_md5_text():
tests = _load_md5_tests('md5text')
# text file #1 is the reference
- for k, files in tests.iteritems():
+ for k, files in tests.items():
print("running tests", k)
ref_file = [f for f in files if f.endswith('%s1.txt'%k)]
if not ref_file:
@@ -124,7 +124,7 @@ def test_md5_equals():
search_path = get_search_path()
tests = _load_md5_tests('same')
- for k, files in tests.iteritems():
+ for k, files in tests.items():
print("running tests", k)
md5sum = _compute_md5(msg_context, files[0])
for f in files[1:]:
@@ -135,7 +135,7 @@ def test_md5_not_equals():
msg_context = MsgContext.create_default()
tests = _load_md5_tests('different')
- for k, files in tests.iteritems():
+ for k, files in tests.items():
print("running tests", k)
md5s = set()
md6md5sum = _compute_md5(msg_context, files[0])
@@ -158,7 +158,7 @@ def test_load_msg_from_string():
from genmsg.msg_loader import load_msg_from_string, MsgContext
context = MsgContext.create_default()
msgspec = load_msg_from_string(context, "Header header", 'test_pkg/HeaderTest')
- print msgspec
+ print(msgspec)
assert msgspec.has_header()
assert msgspec.types == ['std_msgs/Header']
assert msgspec.names == ['header']
View
@@ -89,7 +89,7 @@ def test_parse_type():
def test_Constant():
import genmsg.msgs
- vals = [random.randint(0, 1000) for i in xrange(0, 3)]
+ vals = [random.randint(0, 1000) for i in range(0, 3)]
type_, name, val = [str(x) for x in vals]
x = genmsg.msgs.Constant(type_, name, val, str(val))
assert type_ == x.type

0 comments on commit 4527703

Please sign in to comment.