Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
zendata
提交
f365cbb5
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 搜索 >>
提交
f365cbb5
编写于
7月 24, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix a issue about the res path
上级
fe8d0cc8
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
18 addition
and
153 deletion
+18
-153
.gitignore
.gitignore
+1
-1
README.md
README.md
+2
-2
demo/default.yaml
demo/default.yaml
+0
-139
demo/number.yaml
demo/number.yaml
+0
-0
res/en/sample.yaml
res/en/sample.yaml
+3
-3
res/zh/messages.json
res/zh/messages.json
+0
-0
res/zh/sample.yaml
res/zh/sample.yaml
+3
-3
res/zh/usage.txt
res/zh/usage.txt
+0
-0
src/gen/res.go
src/gen/res.go
+7
-3
src/utils/const/const.go
src/utils/const/const.go
+2
-2
未找到文件。
.gitignore
浏览文件 @
f365cbb5
...
...
@@ -4,5 +4,5 @@
/data/.cache/.data.db-shm
/data/.cache/.data.db-wal
/demo/out/
/data/
_test
/
/data/
custom
/
/conf/
README.md
浏览文件 @
f365cbb5
...
...
@@ -2,11 +2,11 @@
zendata是一款通用的数据生成工具,您可以使用yaml文件来定义您的数据格式,然后交由zendata生成。
## 使用帮助
[
中文
](
res/
cn
/usage.txt
)
[
中文
](
res/
zh
/usage.txt
)
[
English
](
res/en/usage.txt
)
## 数据定义
[
中文
](
res/
cn
/sample.yaml
)
[
中文
](
res/
zh
/sample.yaml
)
[
English
](
res/en/sample.yaml
)
\ No newline at end of file
demo/default.yaml
已删除
100644 → 0
浏览文件 @
fe8d0cc8
title
:
zendata数据配置语法说明
desc
:
# 文件组成
# zendata以yaml格式的文件来定义各个字段的格式。
# yaml文件整体由文件说明和字段定义两部分组成。
# 文件说明
# title: 标题,可以用简短的文字概要描述该文件定义的数据类型。
# desc: 描述,可以用多行文本来详细描述该文件定义的数据类型,非必选项。
# author: 作者,非必选项。
# version:版本号,非必选项。
# 字段列表
# 字段定义部分都放在fields这个定义里面。
# 一个yaml文件可以包含一个或者多个字段。
# 字段列表以-field定义开始。
# 一个字段可以通过fields属性定义它的子字段。
# 字段定义
# field: 字段名,仅支持英文、数字、下换线和.
# range: 列表范围,最重要的定义。
# loop: 循环次数,可以定义某一字段循环多少次。
# loopfix: 每一次循环时的连接符。
# format: 支持格式化输出。
# prefix: 该字段的前缀。
# postfix: 该字段的后缀。
# length: 该字段的长度。如果不通过分隔符区分,则需要指定字段长度,单位是字节。
# leftpad: 左填充的字符。如果长度不够,可指定左填充的字符。默认是以空格左填充。
# rightpad: 右填充的字符。如果长度不够,可指定右填充的字符。
# config: 可以引用另外一个文件里面的定义。
# from: 引用某一个定义文件。
# use: 使用被引用文件中定义的若干实例。all代表使用所有。
# select: 如果引用的文件是excel表,可以查询里面的某一个字段。
# where: 如果引用的文件是excel表,可以使用查询条件。
# range定义
# 使用逗号连接不同的元素。比如 range: 1,2,3
# 元素也可以是一个区间。比如 range:1-10, A-Z
# 区间可以通过冒号:来指定步长。比如 range:1-10:2。
# 步长可以是小数。比如 range: 1-10:0.1
# 步长可以是负数。比如 range: 9-1:-1
# 区间可以通过R来指定随机。比如 range: 1-10:R,随机和步长只能二选一。
# 可以通过一个文件来指定列表。比如range: list.txt。文件名是相对路径时,以配置文件为基准计算。
# 可以通过{n}的方式来重复某一个元素。比如 range: user1{100},user2{100}
# 如果区间或者几个元素需要重复,需要用[]括起来。比如 range: [user1,user2,user3]{100}, [1-100]{10}
author
:
zentao
version
:
1.0
fields
:
-
field
:
field_common
# 默认的列表类型,通过逗号隔成若干区段。
range
:
1-10, 20-25, 27, 29,
30
# 1,2,3...,10,20,21,22...,25,27,29.30
prefix
:
int_
# 前缀
postfix
:
"
\t
"
# 后缀,特殊字符加引号,否则无法解析。
-
field
:
field_step
# 区间可以指定步长,步长可以为小数或者负数。
range
:
1-10:2, 1-2:0.1,9-1:-1
# 1,3,5,7,9,1, 1.1,1.2...,2,9,8,7,1
postfix
:
"
\t
"
-
field
:
field_random
# 通过R属性指定随机。R属性和步长不能同时出现。
range
:
1-10:R
# 1,5,8...
postfix
:
"
\t
"
-
field
:
field_file
# 从一个文件中读取列表,并指定随机。
range
:
users.txt:R
# 该文件中一行作为一个元素,并随机。
postfix
:
"
\t
"
-
field
:
field_loop
# 自循环的字段。
range
:
a-z
# a_b_c | d_e_f | g_h_i
loop
:
3
# 循环三次
loopfix
:
_
# 每次循环的连接符。
postfix
:
"
\t
"
-
field
:
field_repeat
# 通过{}定义重复的元素。
range
:
u-1{3},[u2,u3]{2},[1-3]{3}
# u-1,u1,u1,u2,u2,u3,u3,1,1,1,2,2,2,3,3,3
postfix
:
"
\t
"
-
field
:
field_format
# 通过格式化字符串输出。
range
:
1-10
# passwd 1,passwd 2,passwd 3 ... passwd10。
format
:
"
passwd%02d"
# 用%2d补零,使密码整体保持8位,%2d默认补空格。
postfix
:
"
\t
"
-
field
:
field_length
# 固定长度的字段。
range
:
1-100
# 001,002,003..., 099,100
length
:
3
# 三个字节。
leftpad
:
0
# 使用0左填充。
-
field
:
field_use_another_file
# 可以引用其他的定义文件。
config
:
numb_field.yaml
# 引用当前目录下面的numb_field.yaml文件里面的定义。
postfix
:
"
\t
"
-
field
:
field_use_ranges_file
# 引用其他的定义文件,该文件定义了多个range,他们共享了一些field层面的属性。
from
:
numb_ranges.yaml
# 引用当前目录下面的numb_field.yaml文件里面的定义。
use
:
medium
# 使用该文件中定义的medium分组。
postfix
:
"
\t
"
-
field
:
field_use_instance
# 引用其他的定义文件,该文件定义了多个实例。
from
:
system.ip.v1.yaml
# 引用data/system/ip/v1.yaml
use
:
privateC,privateB
# 使用该文件中定义的privateC和privateB两个实例。
postfix
:
"
\t
"
-
field
:
field_use_excel
# 从excel数据源里面取数据。
from
:
system.address.v1.china
# 从data/system/address/v1.xlsx文件中读取名为china的工作簿。
select
:
city
# 查询city字段。
where
:
state like '%山东%'
# 条件是 省份包含山东。
postfix
:
"
\t
"
-
field
:
field_with_children
# 嵌套字段
fields
:
-
field
:
child1
range
:
a-z
prefix
:
part1_
postfix
:
'
|'
-
field
:
child2
range
:
A-Z
prefix
:
part2_
postfix
:
'
|'
-
field
:
child_with_child
prefix
:
part3_
width
:
12
fields
:
-
field
:
field_grandson
prefix
:
int_
range
:
10-20
postfix
:
demo/number
_field
.yaml
→
demo/number.yaml
浏览文件 @
f365cbb5
文件已移动
res/en/sample.yaml
浏览文件 @
f365cbb5
...
...
@@ -98,11 +98,11 @@ fields:
leftpad
:
0
# Using 0 to pad.
-
field
:
field_use_another_file
# Other definition file can be referred.
config
:
number
_field.yaml
# Refer to the definition in number_field
.yaml of the current directory.
config
:
number
.yaml
# Refer to the definition in number
.yaml of the current directory.
postfix
:
"
\t
"
-
field
:
field_use_ranges
_file
# Other definition file can be referred, in which more than one ranges are defined.
from
:
number_ranges.yaml
# Refer to the definition in number_ranges.yaml of the current directory
.
-
field
:
field_use_ranges
# Other definition file can be referred, in which more than one ranges are defined.
from
:
custom.number.v1.yaml
# Refer to the ranges in data/custom/number/v1.yaml
.
use
:
medium
# use medium range.
postfix
:
"
\t
"
...
...
res/
cn
/messages.json
→
res/
zh
/messages.json
浏览文件 @
f365cbb5
文件已移动
res/
cn
/sample.yaml
→
res/
zh
/sample.yaml
浏览文件 @
f365cbb5
...
...
@@ -92,11 +92,11 @@ fields:
postfix
:
"
\t
"
-
field
:
field_use_another_file
# 可以引用其他的定义文件。
config
:
number
_field.yaml
# 引用当前目录下面的number_field
.yaml文件里面的定义。
config
:
number
.yaml
# 引用当前目录下面的number
.yaml文件里面的定义。
postfix
:
"
\t
"
-
field
:
field_use_ranges
_file
# 引用其他
的定义文件,该文件定义了多个range,他们共享了一些field层面的属性。
from
:
number_ranges.yaml
# 引用当前目录下面的number_field.yaml文件里面的
定义。
-
field
:
field_use_ranges
# 引用內置
的定义文件,该文件定义了多个range,他们共享了一些field层面的属性。
from
:
custom.number.v1.yaml
# 引用data/custom/number/v1.yaml文件里面的ranges
定义。
use
:
medium
# 使用该文件中定义的medium分组。
postfix
:
"
\t
"
...
...
res/
cn
/usage.txt
→
res/
zh
/usage.txt
浏览文件 @
f365cbb5
文件已移动
src/gen/res.go
浏览文件 @
f365cbb5
...
...
@@ -71,9 +71,13 @@ func getResProp(from string) (string, string) { // from resource
resPath
:=
resFile
if
!
filepath
.
IsAbs
(
resPath
)
{
resPath
=
vari
.
ExeDir
+
constant
.
ResDir
+
resFile
// used res should be in data folder
if
!
fileUtils
.
FileExist
(
resPath
)
{
resPath
=
""
resPath
=
vari
.
ConfigDir
+
resFile
if
!
fileUtils
.
FileExist
(
resPath
)
{
// res in the same folder with passed config file
resPath
=
vari
.
ExeDir
+
constant
.
ResDir
+
resFile
if
!
fileUtils
.
FileExist
(
resPath
)
{
// res in res file
resPath
=
""
}
}
}
else
{
if
!
fileUtils
.
FileExist
(
resPath
)
{
...
...
src/utils/const/const.go
浏览文件 @
f365cbb5
...
...
@@ -15,8 +15,8 @@ var (
LanguageEN
=
"en"
LanguageZH
=
"zh"
EnRes
=
fmt
.
Sprintf
(
"res%s
messages_en.json"
,
string
(
os
.
PathSeparator
))
ZhRes
=
fmt
.
Sprintf
(
"res%s
messages_zh.json"
,
string
(
os
.
PathSeparator
))
EnRes
=
fmt
.
Sprintf
(
"res%s
en%smessages.json"
,
string
(
os
.
PathSeparator
)
,
string
(
os
.
PathSeparator
))
ZhRes
=
fmt
.
Sprintf
(
"res%s
zh%smessages.json"
,
string
(
os
.
PathSeparator
)
,
string
(
os
.
PathSeparator
))
LogDir
=
fmt
.
Sprintf
(
"log%s"
,
string
(
os
.
PathSeparator
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录