mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
python2.7 compatibility on code generator
This commit is contained in:
@@ -26,9 +26,10 @@ class Base(object):
|
|||||||
import platform
|
import platform
|
||||||
if tuple(map(int, platform.python_version_tuple())) < (2, 8):
|
if tuple(map(int, platform.python_version_tuple())) < (2, 8):
|
||||||
from io import open as unicode_open
|
from io import open as unicode_open
|
||||||
|
unicode_type = unicode
|
||||||
else:
|
else:
|
||||||
unicode_open = open
|
unicode_open = open
|
||||||
unicode = lambda x, *args, **kwargs: x
|
unicode_type = lambda x, *args, **kwargs: x
|
||||||
f = unicode_open(self.file_name, 'w', encoding='utf-8')
|
f = unicode_open(self.file_name, 'w', encoding='utf-8')
|
||||||
f.write(unicode(repr(self), encoding='utf-8', errors='ignore'))
|
f.write(unicode_type(repr(self), encoding='utf-8', errors='ignore'))
|
||||||
f.close()
|
f.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user