diff --git a/Tools/tranexcel/type2.py b/Tools/tranexcel/type2.py index 3354ee348..5dae901b4 100644 --- a/Tools/tranexcel/type2.py +++ b/Tools/tranexcel/type2.py @@ -4,7 +4,7 @@ import util import base64 -SIMPLE_TYPE = ['int', 'long', 'string', 'str', 'float', 'double', 'atom', 'int32', 'int64'] +SIMPLE_TYPE = ['int', 'long', 'string', 'str', 'float', 'double', 'atom', 'int32', 'int64', 'bool'] ERL_TYPE_MAPPING = { 'int': 'integer', 'int32': 'integer', @@ -63,6 +63,13 @@ def format_data(value, t): if value == 'null': return 0.0 raise Exception('数据应该是小数: %s' % value) + elif t == 'bool': + try: + return str(value).lower() + except ValueError: + if value == 'null': + return 'false' + raise Exception('数据应该是布尔: %s' % value) return value diff --git a/Tools/tranexcel2/type2.py b/Tools/tranexcel2/type2.py index 3354ee348..5dae901b4 100644 --- a/Tools/tranexcel2/type2.py +++ b/Tools/tranexcel2/type2.py @@ -4,7 +4,7 @@ import util import base64 -SIMPLE_TYPE = ['int', 'long', 'string', 'str', 'float', 'double', 'atom', 'int32', 'int64'] +SIMPLE_TYPE = ['int', 'long', 'string', 'str', 'float', 'double', 'atom', 'int32', 'int64', 'bool'] ERL_TYPE_MAPPING = { 'int': 'integer', 'int32': 'integer', @@ -63,6 +63,13 @@ def format_data(value, t): if value == 'null': return 0.0 raise Exception('数据应该是小数: %s' % value) + elif t == 'bool': + try: + return str(value).lower() + except ValueError: + if value == 'null': + return 'false' + raise Exception('数据应该是布尔: %s' % value) return value