Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
5d2076c8
Z
zendata
项目概览
易企天创
/
zendata
9 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
5d2076c8
编写于
8月 25, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support ranges in [] like [a-z,0-9]:R
上级
1fa5a1a2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
291 addition
and
225 deletion
+291
-225
demo/test/misc.yaml
demo/test/misc.yaml
+7
-0
demo/test/test.yaml
demo/test/test.yaml
+69
-69
src/gen/floatVal.go
src/gen/floatVal.go
+19
-1
src/gen/list.go
src/gen/list.go
+4
-1
src/gen/parser.go
src/gen/parser.go
+40
-2
yaml/base/domain/domain.v1.yaml
yaml/base/domain/domain.v1.yaml
+152
-152
未找到文件。
demo/test/misc.yaml
浏览文件 @
5d2076c8
...
...
@@ -24,6 +24,13 @@ fields:
postfix
:
"
\t
"
# width: 25
-
field
:
test3
range
:
[
a
,
b
,
c
]
postfix
:
"
\t
"
-
field
:
test4
range
:
[
a-z
,
0-9
]
:R
-
field
:
field_with_children
fields
:
-
field
:
child1
...
...
demo/test/test.yaml
浏览文件 @
5d2076c8
...
...
@@ -114,72 +114,72 @@ fields:
prefix
:
"
["
postfix
:
"
]
\t
"
# - field: test20
# from: base.domain.domain.v1.yaml
# use: one_number_at_common
# prefix: ""
# postfix: "\t"
# - field: test21
# from: base.domain.domain.v1.yaml
# use: one_number_at_cn
# prefix: ""
# postfix: "\t"
# - field: test22
# from: base.domain.domain.v1.yaml
# use: one_number_at_new
# prefix: ""
# postfix: "\t"
#
# - field: test23
# from: base.domain.domain.v1.yaml
# use: one_letter_at_common
# prefix: ""
# postfix: "\t"
# - field: test24
# from: base.domain.domain.v1.yaml
# use: one_letter_at_cn
# prefix: ""
# postfix: "\t"
# - field: test25
# from: base.domain.domain.v1.yaml
# use: one_letter_at_new
# prefix: ""
# postfix: "\t"
#
# - field: test26
# from: base.domain.domain.v1.yaml
# use: numbers_at_common
# prefix: ""
# postfix: "\t"
# - field: test27
# from: base.domain.domain.v1.yaml
# use: numbers_at_cn
# prefix: ""
# postfix: "\t"
# - field: test28
# from: base.domain.domain.v1.yaml
# use: numbers_at_new
# prefix: ""
# postfix: "\t"
#
# - field: test29
# from: base.domain.domain.v1.yaml
# use: mixed_at_common
# prefix: ""
# postfix: "\t"
# - field: test30
# from: base.domain.domain.v1.yaml
# use: mixed_at_cn
# prefix: ""
# postfix: "\t"
# - field: test31
# from: base.domain.domain.v1.yaml
# use: mixed_at_new
# prefix: ""
# postfix: "\t"
#
# - field: test32
# from: base.domain.esp.v1.yaml
# use: esp
# prefix: ""
# postfix: "\t"
\ No newline at end of file
-
field
:
test20
from
:
base.domain.domain.v1.yaml
use
:
one_number_at_common
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test21
from
:
base.domain.domain.v1.yaml
use
:
one_number_at_cn
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test22
from
:
base.domain.domain.v1.yaml
use
:
one_number_at_new
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test23
from
:
base.domain.domain.v1.yaml
use
:
one_letter_at_common
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test24
from
:
base.domain.domain.v1.yaml
use
:
one_letter_at_cn
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test25
from
:
base.domain.domain.v1.yaml
use
:
one_letter_at_new
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test26
from
:
base.domain.domain.v1.yaml
use
:
numbers_at_common
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test27
from
:
base.domain.domain.v1.yaml
use
:
numbers_at_cn
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test28
from
:
base.domain.domain.v1.yaml
use
:
numbers_at_new
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test29
from
:
base.domain.domain.v1.yaml
use
:
mixed_at_common
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test30
from
:
base.domain.domain.v1.yaml
use
:
mixed_at_cn
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test31
from
:
base.domain.domain.v1.yaml
use
:
mixed_at_new
prefix
:
"
"
postfix
:
"
\t
"
-
field
:
test32
from
:
base.domain.esp.v1.yaml
use
:
esp
prefix
:
"
"
postfix
:
"
\t
"
\ No newline at end of file
src/gen/floatVal.go
浏览文件 @
5d2076c8
...
...
@@ -73,7 +73,7 @@ func GenerateFloatItemsByStep(start float64, end float64, step interface{}, repe
// return arr
//}
func
g
etPrecision
(
base
float64
,
step
interface
{})
int
{
func
G
etPrecision
(
base
float64
,
step
interface
{})
int
{
val
:=
base
+
step
.
(
float64
)
str1
:=
strconv
.
FormatFloat
(
base
,
'f'
,
-
1
,
64
)
...
...
@@ -87,4 +87,22 @@ func getPrecision(base float64, step interface{}) int {
}
else
{
return
len
(
str2
)
-
index2
-
1
}
}
func
InterfaceToStr
(
val
interface
{})
string
{
str
:=
"n/a"
switch
val
.
(
type
)
{
case
int64
:
str
=
strconv
.
FormatInt
(
val
.
(
int64
),
10
)
case
float64
:
precision
:=
GetPrecision
(
val
.
(
float64
),
0
)
str
=
strconv
.
FormatFloat
(
val
.
(
float64
),
'f'
,
precision
,
64
)
case
byte
:
str
=
string
(
val
.
(
byte
))
case
string
:
str
=
val
.
(
string
)
default
:
}
return
str
}
\ No newline at end of file
src/gen/list.go
浏览文件 @
5d2076c8
...
...
@@ -115,7 +115,7 @@ func CheckRangeType(startStr string, endStr string, stepStr string) (string, int
rand
=
true
}
precision
:=
g
etPrecision
(
float1
,
step
)
precision
:=
G
etPrecision
(
float1
,
step
)
if
(
float1
>
float2
&&
step
.
(
float64
)
>
0
)
||
(
float1
<
float2
&&
step
.
(
float64
)
<
0
)
{
step
=
-
1
*
step
.
(
float64
)
...
...
@@ -147,6 +147,9 @@ func CheckRangeType(startStr string, endStr string, stepStr string) (string, int
func
CreateValuesFromLiteral
(
field
*
model
.
DefField
,
desc
string
,
stepStr
string
,
repeat
int
)
(
items
[]
interface
{})
{
elemArr
:=
ParseDesc
(
desc
)
step
,
_
:=
strconv
.
Atoi
(
stepStr
)
if
step
==
0
{
step
=
1
}
total
:=
0
if
field
.
Path
!=
""
&&
stepStr
==
"r"
{
...
...
src/gen/parser.go
浏览文件 @
5d2076c8
...
...
@@ -2,6 +2,7 @@ package gen
import
(
"fmt"
"github.com/easysoft/zendata/src/model"
"github.com/easysoft/zendata/src/utils/const"
stringUtils
"github.com/easysoft/zendata/src/utils/string"
"regexp"
...
...
@@ -121,11 +122,37 @@ func ParseRangeSectionDesc(str string) (typ string, desc string) {
return
}
if
string
(
desc
[
0
])
==
string
(
constant
.
LeftBrackets
)
&&
// [a-z,1-9,userA,UserB]
string
(
desc
[
len
(
desc
)
-
1
])
==
string
(
constant
.
RightBrackets
)
{
desc
=
removeBoundary
(
desc
)
arr
:=
strings
.
Split
(
desc
,
","
)
temp
:=
""
for
_
,
item
:=
range
arr
{
if
isBoundaryStr
(
item
)
{
tempField
:=
model
.
DefField
{}
values
:=
CreateValuesFromInterval
(
&
tempField
,
item
,
"1"
,
1
)
for
_
,
val
:=
range
values
{
temp
+=
InterfaceToStr
(
val
)
+
","
}
}
else
{
temp
+=
item
+
","
}
}
temp
=
strings
.
TrimSuffix
(
temp
,
","
)
desc
=
string
(
constant
.
LeftBrackets
)
+
temp
+
string
(
constant
.
RightBrackets
)
typ
=
"literal"
return
}
if
strings
.
Contains
(
desc
,
","
)
||
strings
.
Contains
(
desc
,
"`"
)
||
!
strings
.
Contains
(
desc
,
"-"
)
{
typ
=
"literal"
}
else
{
temp
:=
strings
.
ReplaceAll
(
desc
,
string
(
constant
.
LeftBrackets
),
""
)
temp
=
strings
.
ReplaceAll
(
temp
,
string
(
constant
.
RightBrackets
),
""
)
temp
:=
removeBoundary
(
desc
)
if
isBoundaryStr
(
temp
)
{
typ
=
"interval"
...
...
@@ -138,8 +165,19 @@ func ParseRangeSectionDesc(str string) (typ string, desc string) {
return
}
func
removeBoundary
(
str
string
)
string
{
str
=
strings
.
TrimLeft
(
str
,
string
(
constant
.
LeftBrackets
))
str
=
strings
.
TrimRight
(
str
,
string
(
constant
.
RightBrackets
))
return
str
}
func
isBoundaryStr
(
str
string
)
bool
{
arr
:=
strings
.
Split
(
str
,
"-"
)
if
len
(
arr
)
<
2
{
return
false
}
left
:=
strings
.
TrimSpace
(
arr
[
0
])
right
:=
strings
.
TrimSpace
(
arr
[
1
])
...
...
yaml/base/domain/domain.v1.yaml
浏览文件 @
5d2076c8
...
...
@@ -5,166 +5,166 @@ version: 1.0
field
:
domain
instances
:
-
instance
:
one_number_at_common
note
:
单数字域名
fields
:
-
field
:
part1
range
:
1-9
rand
:
true
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
all
-
instance
:
one_number_at_cn
note
:
单数字CN域名
prefix
:
fields
:
-
field
:
part1
range
:
1-9
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
cn
-
instance
:
one_number_at_new
note
:
单数字新域名
prefix
:
fields
:
-
field
:
part1
range
:
1-9
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
new
-
instance
:
one_letter_at_common
note
:
单字母域名
prefix
:
fields
:
-
field
:
part1
range
:
a-z
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
all
-
instance
:
one_letter_at_cn
note
:
单字母CN域名
prefix
:
fields
:
-
field
:
part1
range
:
a-z
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
cn
-
instance
:
one_letter_at_new
note
:
单字母新域名
prefix
:
fields
:
-
field
:
part1
range
:
a-z
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
new
-
instance
:
numbers_at_common
note
:
纯数字域名
prefix
:
fields
:
-
field
:
part1
range
:
0-9
loop
:
5-8
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
all
-
instance
:
numbers_at_cn
note
:
纯数字CN域名
prefix
:
fields
:
-
field
:
part1
range
:
0-9
loop
:
5-8
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
cn
-
instance
:
numbers_at_new
note
:
纯数字新域名
prefix
:
fields
:
-
field
:
part1
range
:
a-z
loop
:
5-8
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
new
-
instance
:
letters_at_common
note
:
纯字母域名
prefix
:
fields
:
-
field
:
part1
range
:
a-z
loop
:
5-8
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
all
-
instance
:
letters_at_cn
note
:
纯字母CN域名
prefix
:
fields
:
-
field
:
part1
range
:
a-z
loop
:
5-8
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
cn
-
instance
:
letters_at_new
note
:
纯字母新域名
prefix
:
fields
:
-
field
:
part1
range
:
a-z
loop
:
5-8
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
new
#
- instance: one_number_at_common
#
note: 单数字域名
#
fields:
#
- field: part1
#
range: 1-9
#
rand: true
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: all
#
- instance: one_number_at_cn
#
note: 单数字CN域名
#
prefix:
#
fields:
#
- field: part1
#
range: 1-9
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: cn
#
- instance: one_number_at_new
#
note: 单数字新域名
#
prefix:
#
fields:
#
- field: part1
#
range: 1-9
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: new
#
#
- instance: one_letter_at_common
#
note: 单字母域名
#
prefix:
#
fields:
#
- field: part1
#
range: a-z
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: all
#
- instance: one_letter_at_cn
#
note: 单字母CN域名
#
prefix:
#
fields:
#
- field: part1
#
range: a-z
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: cn
#
- instance: one_letter_at_new
#
note: 单字母新域名
#
prefix:
#
fields:
#
- field: part1
#
range: a-z
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: new
#
#
- instance: numbers_at_common
#
note: 纯数字域名
#
prefix:
#
fields:
#
- field: part1
#
range: 0-9
#
loop: 5-8
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: all
#
- instance: numbers_at_cn
#
note: 纯数字CN域名
#
prefix:
#
fields:
#
- field: part1
#
range: 0-9
#
loop: 5-8
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: cn
#
- instance: numbers_at_new
#
note: 纯数字新域名
#
prefix:
#
fields:
#
- field: part1
#
range: a-z
#
loop: 5-8
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: new
#
#
- instance: letters_at_common
#
note: 纯字母域名
#
prefix:
#
fields:
#
- field: part1
#
range: a-z
#
loop: 5-8
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: all
#
- instance: letters_at_cn
#
note: 纯字母CN域名
#
prefix:
#
fields:
#
- field: part1
#
range: a-z
#
loop: 5-8
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: cn
#
- instance: letters_at_new
#
note: 纯字母新域名
#
prefix:
#
fields:
#
- field: part1
#
range: a-z
#
loop: 5-8
#
postfix: "."
#
- field: part2
#
from: base.domain.postfix.v1.yaml
#
use: new
-
instance
:
mixed_at_common
note
:
字母和数字域名
prefix
:
fields
:
-
field
:
part1
range
:
a-z,0-9
range
:
[
a-z
,
0-9
]
:R
loop
:
5-8
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
all
-
instance
:
mixed_at_cn
note
:
字母和数字CN域名
prefix
:
fields
:
-
field
:
part1
range
:
a-z,0-9
loop
:
5-8
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
cn
-
instance
:
mixed_at_new
note
:
字母和数字新域名
prefix
:
fields
:
-
field
:
part1
range
:
a-z,0-9
loop
:
5-8
postfix
:
"
."
-
field
:
part2
from
:
base.domain.postfix.v1.yaml
use
:
new
\ No newline at end of file
# - instance: mixed_at_cn
# note: 字母和数字CN域名
# prefix:
# fields:
# - field: part1
# range: a-z,0-9
# loop: 5-8
# postfix: "."
# - field: part2
# from: base.domain.postfix.v1.yaml
# use: cn
# - instance: mixed_at_new
# note: 字母和数字新域名
# prefix:
# fields:
# - field: part1
# range: a-z,0-9
# loop: 5-8
# postfix: "."
# - field: part2
# from: base.domain.postfix.v1.yaml
# use: new
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录