-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdCFG.dsc
More file actions
203 lines (192 loc) · 9.11 KB
/
dCFG.dsc
File metadata and controls
203 lines (192 loc) · 9.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# ---------------------------------------------------------------------------- #
# |
# |
# C o n f i g F i l e G e n e r a t o r |
# |
# A system for extracting default config files for your scripts |
# |
# |
# Author: |Anthony| |
# Version: 2.0 |
# dScript Version: 1.1.7-b5132-DEV |
# |
# ---------------------------------------------------------------------------- #
# |
# |
# ABOUT: |
# |
# It extracts default config files from your script. It is entirely |
# useless now since Denizen has the builtin copykey argument for the |
# yaml command. |
# |
# This is a re-write of an old script of mine that was then very |
# useful to me, but no longer necessary. This was just an exercise for |
# me to get back into Denizen scripting. |
# |
# Included is an example usage scenario presented in the form of a |
# comparative stress test against the builtin copykey arg. |
# |
#______________________________________________________________________________#
# #
#==============================================================================#
# #
#------------------------------------------------------------------------------#
#..............................................................................#
# #
dCFG_Main:
type: task
# definitions: readID|writeID|readPath|writePath
debug: false
script:
- choose <script[<[1]>].data_key[<[3]>].type||element>:
- case map:
- yaml set <[4]>:<map[]> id:<[2]>
- foreach <script[<[1]>].list_keys[<[3]>]>:
- run instantly <script[dCFG_Main]> def:<[1]>|<[2]>|<[3]>.<[value]>|<[4]>.<[value]>
- case list:
- yaml set <[4]>:|: id:<[2]>
- foreach <script[<[1]>].data_key[<[3]>].unescaped>:
- yaml set <[4]>:->:<[value].unescaped> id:<[2]>
- case element:
- yaml set <[4]>:<script[<[1]>].data_key[<[3]>].unescaped> id:<[2]>
#______________________________________________________________________________#
# |
#==============================================================================#
# #
# E X A M P L E U S A G E #
# #
#------------------------------------------------------------------------------#
#..............................................................................#
#______________________________________________________________________________#
# #
dCFG_Example_dCFG:
# >ex run <script[dCFG_Example_dCFG]>
# [12:39:57] [Server thread/INFO]: Executing Denizen script command...
# [12:39:57] [Server thread/INFO]: Starting InstantQueue 'EXCOMMAND_OhioNebraskaCircular'...
# [12:39:57] [Server thread/INFO]: +- Queue 'EXCOMMAND_OhioNebraskaCircular' Executing: (line 1) RUN <script[dCFG_Example_dCFG]> ---------+
# [12:39:57] [Server thread/INFO]: Filled tag <script[dCFG_Example_dCFG]> with 's@dcfg_example_dcfg (TASK)'.
# [12:39:57] [Server thread/INFO]: +> Executing 'RUN': script='s@dcfg_example_dcfg (TASK)'
# [12:39:58] [Server thread/INFO]: Completing queue 'EXCOMMAND_OhioNebraskaCircular' in 580ms.
type: task
debug: false
script:
- define readID dCFG_Test_Config
- define writeID CFG_Test_Config_Output
- define readPath <element[]>
- define writePath <element[]>
- define savePath dCFG/config_b.yml
- if <yaml.list.contains[<[writeID]>]>:
- yaml unload id:<[writeID]>
- if <server.has_file[<[savePath]>]>:
- yaml load:<[savePath]> id:<[writeID]>
- else:
- yaml create id:<[writeID]>
- repeat 1000:
- foreach <script[<[readID]>].list_keys[<[readPath]>].exclude[type]>:
- run instantly <script[dCFG_Main]> def:<[readID]||>|<[writeID]||>|<[value]>|<[value]>
- yaml savefile:<[savePath]> id:<[writeID]>
- yaml unload id:<[writeID]>
dCFG_Example_copykey:
# >ex run <script[dCFG_Example_copykey]>
# [12:41:05] [Server thread/INFO]: Executing Denizen script command...
# [12:41:05] [Server thread/INFO]: Starting InstantQueue 'EXCOMMAND_MxRvNewfoundland'...
# [12:41:05] [Server thread/INFO]: +- Queue 'EXCOMMAND_MxRvNewfoundland' Executing: (line 1) RUN <script[dCFG_Example_copykey]> ---------+
# [12:41:05] [Server thread/INFO]: Filled tag <script[dCFG_Example_copykey]> with 's@dcfg_example_copykey (TASK)'.
# [12:41:05] [Server thread/INFO]: +> Executing 'RUN': script='s@dcfg_example_copykey (TASK)'
# [12:41:05] [Server thread/INFO]: Completing queue 'EXCOMMAND_MxRvNewfoundland' in 22ms.
type: task
debug: false
script:
- define readID dCFG_Test_Config
- define writeID CFG_Test_Config_Output
- define readPath <element[]>
- define writePath <element[]>
- define savePath dCFG/config_a.yml
- if <yaml.list.contains[<[writeID]>]>:
- yaml unload id:<[writeID]>
- if <server.has_file[<[savePath]>]>:
- yaml load:<[savePath]> id:<[writeID]>
- else:
- yaml create id:<[writeID]>
- yaml load:<script[dCFG_Main].relative_filename> id:<[readID]>
- repeat 1000:
- foreach <yaml[<[readID]>].list_keys[dCFG_Test_Config].exclude[type]>:
- yaml copykey:dCFG_Test_Config.<[value]> <[value]> to_id:<[writeID]> id:<[readID]>
- yaml unload id:<[readID]>
- yaml savefile:<[savePath]> id:<[writeID]>
- yaml unload id:<[writeID]>
#______________________________________________________________________________#
# #
#==============================================================================#
#______________________________________________________________________________#
# #
# Example Config Script Container #
# #
#------------------------------------------------------------------------------#
#..............................................................................#
#______________________________________________________________________________#
# #
dCFG_Test_Config:
type: data
# ------ Single Value file container ------ #
singleValues:
keyA: 1
keyB: 0.1
keyC: -1
keyD: NaN
keyE: This is a StRiNg!
# ------ Single Lists file container ------ #
singleLists:
listA:
- 1
- 0.1
- -1
- NaN
- This is a StRiNg!
listB:
- 2
- 0.2
- -2
- nAn
- This is a sTrInG!
# ------ Recursive Lists file container ------ #
recursiveLists:
list1:
list1A:
list1A1:
key1A1A: 1
list1A1A:
- 1
- 2
list1A2:
list1A2A:
key1A2A1: 1
list1A2A1:
- 1
- 2
list1B:
- 1
- 2
list2:
list2A:
key2A1: 1
list2A1:
- 1
- 2
list2B:
key2B1: 1
list2B1:
- 1
- 2
list2C:
key2C1: 1
list2C1:
- 1
- 2
list3:
emptyKey: {}
emptyList: []
emptyValue: ''
#______________________________________________________________________________#
# #
#==============================================================================#