Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 3 compatibility #36

Merged
merged 1 commit into from
Nov 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/genmsg/gentools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/genmsg/template_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions test/test_genmsg_gentools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:]:
Expand All @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion test/test_genmsg_msg_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion test/test_genmsg_msgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down