提交 5a4d8efe 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

fix issue#3354

上级 31655734
......@@ -7,6 +7,7 @@ field: privateIP
instances:
- instance: all
note: 引用所有內置IP
fields:
- field: part1
from: system.ip.v1.yaml
......
......@@ -144,42 +144,32 @@ func GetAbsDir(path string) string {
}
func ConvertResPath(path string) (resType, resFile, sheet string) {
index := strings.LastIndex(path, ".yaml")
if index > -1 { // yaml, system.ip.v1.yaml
left := path[:index]
left = strings.ReplaceAll(left, ".", constant.PthSep)
resName := strings.ReplaceAll(path, ".", constant.PthSep)
resFile = left + ".yaml"
resPath := AddRootPath(resName) + ".yaml"
if FileExist(resPath) {
resType = "yaml"
} else { // excel, system.address.v1
//index = strings.LastIndex(path, ".")
//left := path[:index]
//left = strings.ReplaceAll(left, ".", constant.PthSep)
//resFile = left + ".xlsx"
resType = "excel"
resFile = strings.ReplaceAll(path, ".", constant.PthSep) + ".xlsx"
}
resFile = resPath
resFile = AddRootPath(resFile)
} else {
resType = "excel"
// excel file including sheet name like system.address.v1.china
if resType == "excel" && !FileExist(resFile) {
path = strings.ReplaceAll(path, ".", constant.PthSep)
resFile = path[:strings.LastIndex(path, constant.PthSep)] + ".xlsx"
resFile = resName + ".xlsx"
resFile = AddRootPath(resFile)
sheet = path[strings.LastIndex(path, constant.PthSep)+1:]
if FileExist(AddRootPath(resName + ".xlsx")) { // no sheet name
sheet = ""
} else {
resFile = resName[:strings.LastIndex(resName, constant.PthSep)] + ".xlsx"
resFile = AddRootPath(resFile)
sheet = path[strings.LastIndex(resName, constant.PthSep)+1:]
}
}
return
}
func AddRootPath(path string) string {
if strings.Index(path, "system") > -1 {
path = vari.ExeDir + "data" + constant.PthSep + path
} else {
path = vari.ExeDir + constant.PthSep + path
}
path = vari.ExeDir + "data" + constant.PthSep + path
return path
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册