Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
zendata
提交
860494a3
Z
zendata
项目概览
LinuxSuRen
/
zendata
与 Fork 源项目一致
Fork自
易企天创 / zendata
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
860494a3
编写于
7月 24, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
close task #7508
上级
dc113f05
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
34 addition
and
175 deletion
+34
-175
.gitignore
.gitignore
+1
-0
data/system/ip/private.yaml
data/system/ip/private.yaml
+0
-15
data/system/misc/timetamp.yaml
data/system/misc/timetamp.yaml
+0
-42
data/system/name/chinese-name.yaml
data/system/name/chinese-name.yaml
+0
-42
data/system/name/english-name.yaml
data/system/name/english-name.yaml
+0
-42
demo/number_ranges.yaml
demo/number_ranges.yaml
+0
-15
demo/test.yaml
demo/test.yaml
+9
-3
src/gen/res.go
src/gen/res.go
+24
-16
未找到文件。
.gitignore
浏览文件 @
860494a3
...
...
@@ -8,3 +8,4 @@
/data/.cache/.data.db-wal
/demo/out/
/test/output/
/data/_test/
data/system/ip/private.yaml
已删除
100644 → 0
浏览文件 @
dc113f05
title
:
私有IP
desc
:
author
:
zentao
version
:
1.0
field
:
privateIP
instances
:
-
instance
:
all
fields
:
-
field
:
part
from
:
system.ip.v1.yaml
use
:
privateA, privateB, privateC
prefix
:
"
"
postfix
:
"
/24"
data/system/misc/timetamp.yaml
浏览文件 @
860494a3
title
:
IP地址
desc
:
含有多种实现的示例。
author
:
wwccss
version
:
1.0
field
:
ip
instances
:
-
instance
:
privateC
note
:
C类IP地址
prefix
:
192.168.
fields
:
-
field
:
part3
range
:
0-254
postfix
:
.
-
field
:
part4
range
:
1-254
-
instance
:
privateB
note
:
B类IP地址
prefix
:
172.
fields
:
-
field
:
part2
range
:
16-31
postfix
:
.
-
field
:
part3
range
:
0-254
postfix
:
.
-
field
:
part4
range
:
1-254
-
instance
:
privateA
note
:
A类IP地址
prefix
:
10.
fields
:
-
field
:
part2
range
:
0-254
postfix
:
.
-
field
:
part3
range
:
0-254
postfix
:
.
-
field
:
part4
range
:
1-254
\ No newline at end of file
data/system/name/chinese-name.yaml
浏览文件 @
860494a3
title
:
IP地址
desc
:
含有多种实现的示例。
author
:
wwccss
version
:
1.0
field
:
ip
instances
:
-
instance
:
privateC
note
:
C类IP地址
prefix
:
192.168.
fields
:
-
field
:
part3
range
:
0-254
postfix
:
.
-
field
:
part4
range
:
1-254
-
instance
:
privateB
note
:
B类IP地址
prefix
:
172.
fields
:
-
field
:
part2
range
:
16-31
postfix
:
.
-
field
:
part3
range
:
0-254
postfix
:
.
-
field
:
part4
range
:
1-254
-
instance
:
privateA
note
:
A类IP地址
prefix
:
10.
fields
:
-
field
:
part2
range
:
0-254
postfix
:
.
-
field
:
part3
range
:
0-254
postfix
:
.
-
field
:
part4
range
:
1-254
\ No newline at end of file
data/system/name/english-name.yaml
浏览文件 @
860494a3
title
:
IP地址
desc
:
含有多种实现的示例。
author
:
wwccss
version
:
1.0
field
:
ip
instances
:
-
instance
:
privateC
note
:
C类IP地址
prefix
:
192.168.
fields
:
-
field
:
part3
range
:
0-254
postfix
:
.
-
field
:
part4
range
:
1-254
-
instance
:
privateB
note
:
B类IP地址
prefix
:
172.
fields
:
-
field
:
part2
range
:
16-31
postfix
:
.
-
field
:
part3
range
:
0-254
postfix
:
.
-
field
:
part4
range
:
1-254
-
instance
:
privateA
note
:
A类IP地址
prefix
:
10.
fields
:
-
field
:
part2
range
:
0-254
postfix
:
.
-
field
:
part3
range
:
0-254
postfix
:
.
-
field
:
part4
range
:
1-254
\ No newline at end of file
demo/number_ranges.yaml
已删除
100644 → 0
浏览文件 @
dc113f05
title
:
number
desc
:
数字分组
author
:
wwccss
version
:
1.0
field
:
number
note
:
数值类型数据
prefix
:
"
'"
postfix
:
"
'"
loop
:
2
loopfix
:
"
,"
ranges
:
small
:
1-9
medium
:
11-99
large
:
10001-99999
demo/test.yaml
浏览文件 @
860494a3
...
...
@@ -20,8 +20,14 @@ fields:
prefix
:
"
["
# 复写前缀
postfix
:
"
]"
# 特殊字符加引号,否则无法解析
-
field
:
field_nested_
inst
# 引用的instanc
e使用多层嵌套的use定义
from
:
system.
ip.private.yaml
# 引用data/system/ip/v1
.yaml
-
field
:
field_nested_
range
# 引用的rang
e使用多层嵌套的use定义
from
:
system.
misc.number.yaml
# 引用data/system/misc/number
.yaml
use
:
all
# 使用该文件中定义的privateC和privateB两个实例。
prefix
:
"
["
# 复写前缀
postfix
:
"
]"
# 特殊字符加引号,否则无法解析
-
field
:
field_nested_refer
# 引用的instance使用多层嵌套的use定义
from
:
_test.ip.private.yaml
use
:
all
prefix
:
"
["
postfix
:
"
]"
\ No newline at end of file
src/gen/res.go
浏览文件 @
860494a3
...
...
@@ -71,13 +71,10 @@ func getResProp(from string) (string, string) { // from resource
resPath
:=
resFile
if
!
filepath
.
IsAbs
(
resPath
)
{
resPath
=
vari
.
ConfigDir
+
resFile
if
!
fileUtils
.
FileExist
(
resPath
)
{
resPath
=
vari
.
DefaultDir
+
resFile
resPath
=
vari
.
ExeDir
+
constant
.
ResDir
+
resFile
// used res should be in data folder
if
!
fileUtils
.
FileExist
(
resPath
)
{
resPath
=
""
}
}
}
else
{
if
!
fileUtils
.
FileExist
(
resPath
)
{
resPath
=
""
...
...
@@ -148,16 +145,22 @@ func getResForInstances(insts model.ResInsts) map[string][]string {
for
_
,
inst
:=
range
insts
.
Instances
{
for
_
,
instField
:=
range
inst
.
Fields
{
// prepare referred parent instances if needed
if
instField
.
Use
!=
""
{
// refer to another
instance
parent
:=
getRoot
Instant
(
instField
)
if
instField
.
Use
!=
""
{
// refer to another
def
parent
Ranges
,
parentInstants
:=
getRootRangeOr
Instant
(
instField
)
groupedValueParent
:=
map
[
string
][]
string
{}
for
_
,
child
:=
range
parent
.
Instances
{
field
:=
convertInstantToField
(
parent
,
child
)
if
len
(
parentInstants
.
Instances
)
>
0
{
for
_
,
child
:=
range
parentInstants
.
Instances
{
field
:=
convertInstantToField
(
parentInstants
,
child
)
// gen values
group
:=
child
.
Instance
groupedValueParent
[
group
]
=
GenerateForField
(
&
field
,
constant
.
Total
,
false
)
}
}
else
if
len
(
parentRanges
.
Ranges
)
>
0
{
groupedValueParent
=
getResForRanges
(
parentRanges
)
}
vari
.
Res
[
instField
.
From
]
=
groupedValueParent
}
}
...
...
@@ -172,7 +175,7 @@ func getResForInstances(insts model.ResInsts) map[string][]string {
return
groupedValue
}
func
getRoot
Instant
(
inst
model
.
DefField
)
(
parentInsts
model
.
ResInsts
)
{
func
getRoot
RangeOrInstant
(
inst
model
.
DefField
)
(
parentRanges
model
.
ResRanges
,
parentInsts
model
.
ResInsts
)
{
resFile
,
_
:=
getResProp
(
inst
.
From
)
yamlContent
,
err
:=
ioutil
.
ReadFile
(
resFile
)
...
...
@@ -181,9 +184,14 @@ func getRootInstant(inst model.DefField) (parentInsts model.ResInsts) {
return
}
err
=
yaml
.
Unmarshal
(
yamlContent
,
&
parentInsts
)
if
err
==
nil
&&
parentInsts
.
Instances
!=
nil
&&
len
(
parentInsts
.
Instances
)
>
0
{
// instances
err1
:=
yaml
.
Unmarshal
(
yamlContent
,
&
parentRanges
)
if
err1
!=
nil
||
parentInsts
.
Instances
==
nil
||
len
(
parentInsts
.
Instances
)
==
0
{
// instances
err2
:=
yaml
.
Unmarshal
(
yamlContent
,
&
parentInsts
)
if
err2
!=
nil
||
parentRanges
.
Ranges
==
nil
||
len
(
parentRanges
.
Ranges
)
==
0
{
// ranges
logUtils
.
Screen
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_parse_file"
,
resFile
))
return
}
}
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录