explicit string encoding when writing to file in python3
This commit is contained in:
@@ -21,7 +21,7 @@ def substitute(build, output_dir):
|
|||||||
# populate template
|
# populate template
|
||||||
populated = template.render(build=build, time=time)
|
populated = template.render(build=build, time=time)
|
||||||
with open(os.path.join(output_dir, 'buildInformation.m'), 'wb') as f:
|
with open(os.path.join(output_dir, 'buildInformation.m'), 'wb') as f:
|
||||||
f.write(populated)
|
f.write(populated.encode('utf-8'))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
"""
|
"""
|
||||||
|
@@ -22,7 +22,7 @@ def substitute(cv, output_dir):
|
|||||||
# populate template
|
# populate template
|
||||||
populated = template.render(cv=cv, time=time)
|
populated = template.render(cv=cv, time=time)
|
||||||
with open(os.path.join(output_dir, 'mex.m'), 'wb') as f:
|
with open(os.path.join(output_dir, 'mex.m'), 'wb') as f:
|
||||||
f.write(populated)
|
f.write(populated.encode('utf-8'))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
"""
|
"""
|
||||||
|
@@ -105,27 +105,27 @@ class MatlabWrapperGenerator(object):
|
|||||||
for method in namespace.methods:
|
for method in namespace.methods:
|
||||||
populated = tfunction.render(fun=method, time=time, includes=namespace.name)
|
populated = tfunction.render(fun=method, time=time, includes=namespace.name)
|
||||||
with open(output_source_dir+'/'+method.name+'.cpp', 'wb') as f:
|
with open(output_source_dir+'/'+method.name+'.cpp', 'wb') as f:
|
||||||
f.write(populated)
|
f.write(populated.encode('utf-8'))
|
||||||
if namespace.name in doc and method.name in doc[namespace.name]:
|
if namespace.name in doc and method.name in doc[namespace.name]:
|
||||||
populated = tdoc.render(fun=method, doc=doc[namespace.name][method.name], time=time)
|
populated = tdoc.render(fun=method, doc=doc[namespace.name][method.name], time=time)
|
||||||
with open(output_class_dir+'/'+method.name+'.m', 'wb') as f:
|
with open(output_class_dir+'/'+method.name+'.m', 'wb') as f:
|
||||||
f.write(populated)
|
f.write(populated.encode('utf-8'))
|
||||||
# classes
|
# classes
|
||||||
for clss in namespace.classes:
|
for clss in namespace.classes:
|
||||||
# cpp converter
|
# cpp converter
|
||||||
populated = tclassc.render(clss=clss, time=time)
|
populated = tclassc.render(clss=clss, time=time)
|
||||||
with open(output_private_dir+'/'+clss.name+'Bridge.cpp', 'wb') as f:
|
with open(output_private_dir+'/'+clss.name+'Bridge.cpp', 'wb') as f:
|
||||||
f.write(populated)
|
f.write(populated.encode('utf-8'))
|
||||||
# matlab classdef
|
# matlab classdef
|
||||||
populated = tclassm.render(clss=clss, time=time)
|
populated = tclassm.render(clss=clss, time=time)
|
||||||
with open(output_class_dir+'/'+clss.name+'.m', 'wb') as f:
|
with open(output_class_dir+'/'+clss.name+'.m', 'wb') as f:
|
||||||
f.write(populated)
|
f.write(populated.encode('utf-8'))
|
||||||
|
|
||||||
# create a global constants lookup table
|
# create a global constants lookup table
|
||||||
const = dict(constants(todict(parse_tree.namespaces)))
|
const = dict(constants(todict(parse_tree.namespaces)))
|
||||||
populated = tconst.render(constants=const, time=time)
|
populated = tconst.render(constants=const, time=time)
|
||||||
with open(output_dir+'/cv.m', 'wb') as f:
|
with open(output_dir+'/cv.m', 'wb') as f:
|
||||||
f.write(populated)
|
f.write(populated.encode('utf-8'))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user