From 67e87cbc96fa5e188343dfb013b48dfbc3dc631c Mon Sep 17 00:00:00 2001 From: chenxi Date: Wed, 10 May 2023 17:03:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=A1=A8=E5=B7=A5=E5=85=B7=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=B8=83=E5=B0=94=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tools/tranexcel/type2.py | 9 ++++++++- Tools/tranexcel2/type2.py | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) 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