Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
4d24b117
Z
zendata
项目概览
易企天创
/
zendata
大约 1 年 前同步成功
通知
17
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4d24b117
编写于
3月 12, 2021
作者:
陈
陈琦
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
close task#36671 文本支持支持重复语法[a,b,c]{5!}
上级
0afdd340
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
110 addition
and
55 deletion
+110
-55
.zd.conf
.zd.conf
+1
-1
demo/20_use_results.yaml
demo/20_use_results.yaml
+2
-2
demo/default.yaml
demo/default.yaml
+1
-1
src/gen/parser.go
src/gen/parser.go
+28
-20
src/gen/text.go
src/gen/text.go
+44
-12
test/test-refer-multi.yaml
test/test-refer-multi.yaml
+22
-0
test/test.yaml
test/test.yaml
+3
-13
ui/src/components/FieldRefer.vue
ui/src/components/FieldRefer.vue
+4
-1
ui/src/locales/lang/en-US.js
ui/src/locales/lang/en-US.js
+2
-2
ui/src/locales/lang/zh-CN.js
ui/src/locales/lang/zh-CN.js
+3
-3
未找到文件。
.zd.conf
浏览文件 @
4d24b117
Version
=
1
.
8
Version
=
1
.
8
Language
=
zh
Language
=
zh
demo/20_use_results.yaml
浏览文件 @
4d24b117
fields
:
fields
:
-
field
:
first
-
field
:
first
range
:
16_from_instance.yaml{10}
range
:
16_from_instance.yaml{10}
# 注意此处{10}为取10条记录,非重复语法。
prefix
:
"
From
16.yaml
\t
"
prefix
:
"
From
16.yaml
\t
"
postfix
:
"
\t
|
\t
"
postfix
:
"
\t
|
\t
"
-
field
:
second
-
field
:
second
range
:
17_from_excel.yaml{5}
range
:
17_from_excel.yaml{5}
# 注意此处{5}为取5条记录,非重复语法。
prefix
:
"
From
17.yaml:
\t
"
prefix
:
"
From
17.yaml:
\t
"
demo/default.yaml
浏览文件 @
4d24b117
...
@@ -104,7 +104,7 @@ fields:
...
@@ -104,7 +104,7 @@ fields:
postfix
:
"
\t
"
postfix
:
"
\t
"
-
field
:
field_yaml
# 引用其他的定义文件整体内容。
-
field
:
field_yaml
# 引用其他的定义文件整体内容。
range
:
01_range.yaml{3}
# 相对当前文件路径。
range
:
01_range.yaml{3}
# 相对当前文件路径
,注意此处{3}为取5条记录,非重复语法
。
postfix
:
"
\t
"
postfix
:
"
\t
"
-
field
:
field_use_config
# 引用其他的config定义文件。
-
field
:
field_use_config
# 引用其他的config定义文件。
...
...
src/gen/parser.go
浏览文件 @
4d24b117
...
@@ -83,41 +83,29 @@ func ParseDesc(desc string) (items []string) {
...
@@ -83,41 +83,29 @@ func ParseDesc(desc string) (items []string) {
step =>1
step =>1
repeat =>2
repeat =>2
*/
*/
func
ParseRangeSection
(
item
string
)
(
entry
string
,
step
string
,
repeat
int
,
repeatTag
string
)
{
func
ParseRangeSection
(
rang
string
)
(
entry
string
,
step
string
,
repeat
int
,
repeatTag
string
)
{
item
=
strings
.
TrimSpace
(
item
)
rang
=
strings
.
TrimSpace
(
rang
)
if
item
==
""
{
if
rang
==
""
{
repeat
=
1
repeat
=
1
return
return
}
}
runeArr
:=
[]
rune
(
item
)
runeArr
:=
[]
rune
(
rang
)
if
(
runeArr
[
0
]
==
constant
.
Backtick
&&
runeArr
[
len
(
runeArr
)
-
1
]
==
constant
.
Backtick
)
||
// `xxx`
if
(
runeArr
[
0
]
==
constant
.
Backtick
&&
runeArr
[
len
(
runeArr
)
-
1
]
==
constant
.
Backtick
)
||
// `xxx`
(
string
(
runeArr
[
0
])
==
string
(
constant
.
LeftBrackets
)
&&
// (xxx)
(
string
(
runeArr
[
0
])
==
string
(
constant
.
LeftBrackets
)
&&
// (xxx)
string
(
runeArr
[
len
(
runeArr
)
-
1
])
==
string
(
constant
.
RightBrackets
))
{
string
(
runeArr
[
len
(
runeArr
)
-
1
])
==
string
(
constant
.
RightBrackets
))
{
entry
=
item
entry
=
rang
if
repeat
==
0
{
if
repeat
==
0
{
repeat
=
1
repeat
=
1
}
}
return
return
}
}
regx
:=
regexp
.
MustCompile
(
`\{(.*)!?\}`
)
repeat
,
repeatTag
,
rangWithoutRepeat
:=
ParseRepeat
(
rang
)
arr
:=
regx
.
FindStringSubmatch
(
item
)
tag
:=
""
if
len
(
arr
)
==
2
{
str
:=
strings
.
TrimSpace
(
arr
[
1
])
if
str
[
len
(
str
)
-
1
:
]
==
"!"
{
tag
=
str
[
len
(
str
)
-
1
:
]
str
=
strings
.
TrimSpace
(
str
[
:
len
(
str
)
-
1
])
}
repeat
,
_
=
strconv
.
Atoi
(
str
)
}
repeatTag
=
tag
itemWithoutRepeat
:=
regx
.
ReplaceAllString
(
item
,
""
)
sectionArr
:=
strings
.
Split
(
item
WithoutRepeat
,
":"
)
sectionArr
:=
strings
.
Split
(
rang
WithoutRepeat
,
":"
)
entry
=
sectionArr
[
0
]
entry
=
sectionArr
[
0
]
if
len
(
sectionArr
)
==
2
{
if
len
(
sectionArr
)
==
2
{
step
=
strings
.
TrimSpace
(
strings
.
ToLower
(
sectionArr
[
1
]))
step
=
strings
.
TrimSpace
(
strings
.
ToLower
(
sectionArr
[
1
]))
...
@@ -127,7 +115,7 @@ func ParseRangeSection(item string) (entry string, step string, repeat int, repe
...
@@ -127,7 +115,7 @@ func ParseRangeSection(item string) (entry string, step string, repeat int, repe
pattern
:=
"
\\
d+"
pattern
:=
"
\\
d+"
isNum
,
_
:=
regexp
.
MatchString
(
pattern
,
step
)
isNum
,
_
:=
regexp
.
MatchString
(
pattern
,
step
)
if
!
isNum
&&
step
!=
"r"
{
if
!
isNum
&&
step
!=
"r"
{
entry
=
item
entry
=
rang
step
=
""
step
=
""
}
}
}
}
...
@@ -255,3 +243,23 @@ func isCharOrNumberScope(str string) bool {
...
@@ -255,3 +243,23 @@ func isCharOrNumberScope(str string) bool {
return
false
return
false
}
}
func
ParseRepeat
(
rang
string
)
(
repeat
int
,
repeatTag
,
rangeWithoutRepeat
string
)
{
repeat
=
1
regx
:=
regexp
.
MustCompile
(
`\{(.*)!?\}`
)
arr
:=
regx
.
FindStringSubmatch
(
rang
)
tag
:=
""
if
len
(
arr
)
==
2
{
str
:=
strings
.
TrimSpace
(
arr
[
1
])
if
str
[
len
(
str
)
-
1
:
]
==
"!"
{
tag
=
str
[
len
(
str
)
-
1
:
]
str
=
strings
.
TrimSpace
(
str
[
:
len
(
str
)
-
1
])
}
repeat
,
_
=
strconv
.
Atoi
(
str
)
}
repeatTag
=
tag
rangeWithoutRepeat
=
regx
.
ReplaceAllString
(
rang
,
""
)
return
}
src/gen/text.go
浏览文件 @
4d24b117
...
@@ -18,8 +18,10 @@ func CreateFieldValuesFromText(field *model.DefField, fieldValue *model.FieldWit
...
@@ -18,8 +18,10 @@ func CreateFieldValuesFromText(field *model.DefField, fieldValue *model.FieldWit
ranges
:=
strings
.
Split
(
strings
.
TrimSpace
(
field
.
Range
),
","
)
ranges
:=
strings
.
Split
(
strings
.
TrimSpace
(
field
.
Range
),
","
)
for
_
,
rang
:=
range
ranges
{
for
_
,
rang
:=
range
ranges
{
rang
=
strings
.
TrimSpace
(
rang
)
rang
=
strings
.
TrimSpace
(
rang
)
repeat
,
repeatTag
,
rangWithoutRepeat
:=
ParseRepeat
(
rang
)
// get file and step string
// get file and step string
sectionArr
:=
strings
.
Split
(
rang
,
":"
)
sectionArr
:=
strings
.
Split
(
rang
WithoutRepeat
,
":"
)
file
:=
sectionArr
[
0
]
file
:=
sectionArr
[
0
]
stepStr
:=
"1"
stepStr
:=
"1"
if
len
(
sectionArr
)
==
2
{
if
len
(
sectionArr
)
==
2
{
...
@@ -59,20 +61,50 @@ func CreateFieldValuesFromText(field *model.DefField, fieldValue *model.FieldWit
...
@@ -59,20 +61,50 @@ func CreateFieldValuesFromText(field *model.DefField, fieldValue *model.FieldWit
// get index for data retrieve
// get index for data retrieve
numbs
:=
GenerateIntItems
(
0
,
(
int64
)(
len
(
list
)
-
1
),
step
,
rand
,
1
,
""
)
numbs
:=
GenerateIntItems
(
0
,
(
int64
)(
len
(
list
)
-
1
),
step
,
rand
,
1
,
""
)
// get data by index
// gen data by index
index
:=
0
count
:=
0
for
_
,
numb
:=
range
numbs
{
if
repeatTag
==
""
{
item
:=
list
[
numb
.
(
int64
)]
for
_
,
numb
:=
range
numbs
{
item
:=
list
[
numb
.
(
int64
)]
if
strings
.
TrimSpace
(
item
)
==
""
{
// ignore empty line
continue
}
if
index
>=
constant
.
MaxNumb
{
for
i
:=
0
;
i
<
repeat
;
i
++
{
break
fieldValue
.
Values
=
append
(
fieldValue
.
Values
,
item
)
}
if
strings
.
TrimSpace
(
item
)
==
""
{
count
++
continue
if
count
>=
constant
.
MaxNumb
{
break
}
}
count
++
if
count
>=
constant
.
MaxNumb
{
break
}
}
}
}
else
if
repeatTag
==
"!"
{
for
i
:=
0
;
i
<
repeat
;
i
++
{
for
_
,
numb
:=
range
numbs
{
item
:=
list
[
numb
.
(
int64
)]
if
strings
.
TrimSpace
(
item
)
==
""
{
// ignore empty line
continue
}
fieldValue
.
Values
=
append
(
fieldValue
.
Values
,
item
)
count
++
if
count
>=
constant
.
MaxNumb
{
break
}
}
fieldValue
.
Values
=
append
(
fieldValue
.
Values
,
item
)
count
++
index
=
index
+
1
if
count
>=
constant
.
MaxNumb
{
break
}
}
}
}
}
}
...
...
test/test-refer-multi.yaml
0 → 100755
浏览文件 @
4d24b117
title
:
test
desc
:
描述
version
:
1.0
fields
:
-
field
:
refer_text
range
:
res/num.txt:2, ../demo/user.txt:R
postfix
:
"
\t
"
-
field
:
refer_content
range
:
../demo/15_from_range.yaml{3}, ../demo/16_from_instance.yaml{10}
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
refer_ranges
from
:
zentao.number.v1.yaml
use
:
small{3},netmask
postfix
:
"
\t
"
-
field
:
refer_instance
from
:
ip.v1.yaml
use
:
privateA{3},privateB{5}
postfix
:
"
\t
"
\ No newline at end of file
test/test.yaml
浏览文件 @
4d24b117
...
@@ -2,21 +2,11 @@ title: test
...
@@ -2,21 +2,11 @@ title: test
desc
:
描述
desc
:
描述
version
:
1.0
version
:
1.0
fields
:
fields
:
-
field
:
refer_text
#
- field: refer_text
range
:
res/num.txt
, ../demo/user.txt:R
# range: res/num.txt{2!}
, ../demo/user.txt:R
postfix
:
"
\t
"
#
postfix: "\t"
-
field
:
refer_content
-
field
:
refer_content
range
:
../demo/15_from_range.yaml{3}, ../demo/16_from_instance.yaml{10}
range
:
../demo/15_from_range.yaml{3}, ../demo/16_from_instance.yaml{10}
prefix
:
"
"
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
refer_ranges
from
:
zentao.number.v1.yaml
use
:
small{3},netmask
postfix
:
"
\t
"
-
field
:
refer_instance
from
:
ip.v1.yaml
use
:
privateA{3},privateB{5}
postfix
:
"
\t
"
postfix
:
"
\t
"
\ No newline at end of file
ui/src/components/FieldRefer.vue
浏览文件 @
4d24b117
...
@@ -7,9 +7,9 @@
...
@@ -7,9 +7,9 @@
<a-select-option
value=
"config"
>
{{
$t
(
'
msg.config
'
)
}}
</a-select-option>
<a-select-option
value=
"config"
>
{{
$t
(
'
msg.config
'
)
}}
</a-select-option>
<a-select-option
value=
"ranges"
>
{{
$t
(
'
msg.ranges
'
)
}}
</a-select-option>
<a-select-option
value=
"ranges"
>
{{
$t
(
'
msg.ranges
'
)
}}
</a-select-option>
<a-select-option
value=
"instances"
>
{{
$t
(
'
msg.instances
'
)
}}
</a-select-option>
<a-select-option
value=
"instances"
>
{{
$t
(
'
msg.instances
'
)
}}
</a-select-option>
<a-select-option
value=
"yaml"
>
{{
$t
(
'
msg.exec
'
)
}}
</a-select-option>
<a-select-option
value=
"excel"
>
{{
$t
(
'
msg.excel
'
)
}}
</a-select-option>
<a-select-option
value=
"excel"
>
{{
$t
(
'
msg.excel
'
)
}}
</a-select-option>
<a-select-option
value=
"text"
>
{{
$t
(
'
msg.text
'
)
}}
</a-select-option>
<a-select-option
value=
"text"
>
{{
$t
(
'
msg.text
'
)
}}
</a-select-option>
<a-select-option
value=
"yaml"
>
{{
$t
(
'
msg.exec
'
)
}}
</a-select-option>
<a-select-option
value=
"value"
>
{{
$t
(
'
form.expr
'
)
}}
</a-select-option>
<a-select-option
value=
"value"
>
{{
$t
(
'
form.expr
'
)
}}
</a-select-option>
</a-select>
</a-select>
</a-form-model-item>
</a-form-model-item>
...
@@ -181,6 +181,9 @@ export default {
...
@@ -181,6 +181,9 @@ export default {
onReferTypeChanged
()
{
onReferTypeChanged
()
{
console
.
log
(
'
onReferTypeChanged
'
)
console
.
log
(
'
onReferTypeChanged
'
)
if
(
this
.
refer
.
type
===
'
text
'
)
{
this
.
refer
.
step
=
1
}
this
.
listReferFileForSelection
(
this
.
refer
.
type
,
false
)
this
.
listReferFileForSelection
(
this
.
refer
.
type
,
false
)
},
},
onReferFileChanged
()
{
onReferFileChanged
()
{
...
...
ui/src/locales/lang/en-US.js
浏览文件 @
4d24b117
...
@@ -51,8 +51,8 @@ const locale = {
...
@@ -51,8 +51,8 @@ const locale = {
'
msg.instances
'
:
'
Instances
'
,
'
msg.instances
'
:
'
Instances
'
,
'
msg.excel
'
:
'
Excel
'
,
'
msg.excel
'
:
'
Excel
'
,
'
msg.excel.sheet
'
:
'
Excel Sheet
'
,
'
msg.excel.sheet
'
:
'
Excel Sheet
'
,
'
msg.text
'
:
'
Text
'
,
'
msg.text
'
:
'
Text
Content
'
,
'
msg.exec
'
:
'
Execution
'
,
'
msg.exec
'
:
'
Yaml Result
'
,
'
msg.file
'
:
'
File
'
,
'
msg.file
'
:
'
File
'
,
'
msg.design.title
'
:
'
TestData Design
'
,
'
msg.design.title
'
:
'
TestData Design
'
,
...
...
ui/src/locales/lang/zh-CN.js
浏览文件 @
4d24b117
...
@@ -46,13 +46,13 @@ const locale = {
...
@@ -46,13 +46,13 @@ const locale = {
'
msg.no
'
:
'
否
'
,
'
msg.no
'
:
'
否
'
,
'
msg.data
'
:
'
数据
'
,
'
msg.data
'
:
'
数据
'
,
'
msg.config
'
:
'
字段
'
,
'
msg.config
'
:
'
配置
'
,
'
msg.ranges
'
:
'
序列
'
,
'
msg.ranges
'
:
'
序列
'
,
'
msg.instances
'
:
'
实例
'
,
'
msg.instances
'
:
'
实例
'
,
'
msg.excel
'
:
'
Excel
'
,
'
msg.excel
'
:
'
Excel
'
,
'
msg.excel.sheet
'
:
'
Excel表格
'
,
'
msg.excel.sheet
'
:
'
Excel表格
'
,
'
msg.text
'
:
'
文本
'
,
'
msg.text
'
:
'
文本
内容
'
,
'
msg.exec
'
:
'
执行
'
,
'
msg.exec
'
:
'
Yaml结果
'
,
'
msg.file
'
:
'
文件
'
,
'
msg.file
'
:
'
文件
'
,
'
msg.design.title
'
:
'
测试数据设计
'
,
'
msg.design.title
'
:
'
测试数据设计
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录