Fix python2 error in template_explorer.py (#471)

If template_explorer.py was imported in python2, it would fail because
it uses unicode_literals which would ultimately cause passing an unicode
string as the first argument to the 'type' built-in function.

This commit fixes this by converting the unicode to string before it is
passed to the 'type' function.

Fixes #456
This commit is contained in:
Radomír Bosák 2017-03-09 20:59:03 +01:00
parent 095369f705
commit ca2d9f072f

View file

@ -36,7 +36,7 @@ def __exporter_from_file(template_file):
"""Create a template class from a file""" """Create a template class from a file"""
name = os.path.basename(template_file).replace(".template", "") name = os.path.basename(template_file).replace(".template", "")
template = Template.from_file(template_file) template = Template.from_file(template_file)
return type("{}Exporter".format(name.title()), (GenericTemplateExporter, ), { return type(str("{}Exporter".format(name.title())), (GenericTemplateExporter, ), {
"names": [name], "names": [name],
"extension": template.extension, "extension": template.extension,
"template": template "template": template