[Add]增加VT_setting中关于小数位显示的配置

This commit is contained in:
vn.py 2018-03-21 12:51:49 +08:00
parent 162b4cc7b6
commit f43c4b010c
2 changed files with 27 additions and 20 deletions

View File

@ -7,13 +7,10 @@
import os
import decimal
import json
import traceback
from datetime import datetime
from math import isnan
from vtGlobal import globalSetting
MAX_NUMBER = 10000000000000
MAX_DECIMAL = globalSetting.get('maxDecimal', 4)
#----------------------------------------------------------------------
def safeUnicode(value):
@ -93,6 +90,29 @@ def getJsonPath(name, moduleFile):
jsonPathDict[name] = moduleJsonPath
return moduleJsonPath
# 加载全局配置
#----------------------------------------------------------------------
def loadJsonSetting(settingFileName):
"""加载JSON配置"""
settingFilePath = getJsonPath(settingFileName, __file__)
setting = {}
try:
with open(settingFilePath, 'rb') as f:
setting = f.read()
if type(setting) is not str:
setting = str(setting, encoding='utf8')
setting = json.loads(setting)
except:
traceback.print_exc()
return setting
# 函数常量
MAX_NUMBER = 10000000000000
globalSetting = loadJsonSetting('VT_setting.json')
MAX_DECIMAL = globalSetting.get('maxDecimal', 4)

View File

@ -7,20 +7,7 @@
import os
import traceback
import json
from .vtFunction import getJsonPath
from .vtFunction import loadJsonSetting
settingFileName = "VT_setting.json"
settingFilePath = getJsonPath(settingFileName, __file__)
globalSetting = {} # 全局配置字典
try:
with open(settingFilePath, 'rb') as f:
setting = f.read()
if type(setting) is not str:
setting = str(setting, encoding='utf8')
globalSetting = json.loads(setting)
except:
traceback.print_exc()
globalSetting = loadJsonSetting(settingFileName)