anoy 0.3.0__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {anoy-0.3.0.dist-info → anoy-0.3.2.dist-info}/METADATA +1 -1
- anoy-0.3.2.dist-info/RECORD +10 -0
- cli.py +1 -1
- modules/dictTraversal.py +327 -167
- anoy-0.3.0.dist-info/RECORD +0 -10
- {anoy-0.3.0.dist-info → anoy-0.3.2.dist-info}/WHEEL +0 -0
- {anoy-0.3.0.dist-info → anoy-0.3.2.dist-info}/entry_points.txt +0 -0
- {anoy-0.3.0.dist-info → anoy-0.3.2.dist-info}/licenses/LICENSE.txt +0 -0
- {anoy-0.3.0.dist-info → anoy-0.3.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
cli.py,sha256=-gCbboBrSGor9uOvwySsFSswkxw1iSVKm5oM1GMhtLY,912
|
|
2
|
+
anoy-0.3.2.dist-info/licenses/LICENSE.txt,sha256=nsHvySI1U7YZgAX4K3rJsWli_GfXy2syPI-MtGPwjlo,1062
|
|
3
|
+
modules/__init__.py,sha256=WSvUse7H-6ConliG5plmNLGHjeHWXqHR9t901plrWM0,133
|
|
4
|
+
modules/dictTraversal.py,sha256=KVWbjZr0tHt5htOsYEka9zZq2WBowrxsW0jQxMwUegw,32442
|
|
5
|
+
modules/errors.py,sha256=P9KwBhPdPGdujCMA00Ep37RvPLwGYsNip4RidT7oMdg,2091
|
|
6
|
+
anoy-0.3.2.dist-info/METADATA,sha256=xUD8KQozCr8wUgMos5akGBELHAWOAe6gJBFgB6Ka4hs,3873
|
|
7
|
+
anoy-0.3.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
8
|
+
anoy-0.3.2.dist-info/entry_points.txt,sha256=_lpL6R97giGseZcV0r5QwdX4zRwoZLzRHUxyBZl_iYI,34
|
|
9
|
+
anoy-0.3.2.dist-info/top_level.txt,sha256=jfF8JYDvxB66wJSH2sWhdDiR0GGzxt5x-1k2vxwZKqA,12
|
|
10
|
+
anoy-0.3.2.dist-info/RECORD,,
|
cli.py
CHANGED
modules/dictTraversal.py
CHANGED
|
@@ -64,195 +64,128 @@ class DictTraversal():
|
|
|
64
64
|
@Summ: 型確認して、余計なものを取り除いたconfigDict。
|
|
65
65
|
@Type: dict
|
|
66
66
|
"""
|
|
67
|
-
|
|
67
|
+
validConfigDict={} # 整形されたconfigDict
|
|
68
68
|
for annoKey in configDict.keys():
|
|
69
|
-
|
|
69
|
+
validAnnoValue={} #annotation value.
|
|
70
70
|
if(annoKey[0]!="@"):
|
|
71
71
|
raise ConfigYamlError([annoKey],"Annotaion key should start with `@`.")
|
|
72
72
|
valueDict=configDict[annoKey]
|
|
73
73
|
if(type(valueDict)!=dict):
|
|
74
74
|
raise ConfigYamlError([annoKey])
|
|
75
75
|
for key,value in valueDict.items():
|
|
76
|
+
if(type(key)!=str):
|
|
77
|
+
raise ConfigYamlError([annoKey,key], "Invalid value as !Parent.")
|
|
76
78
|
if(key[0]=="@"):
|
|
77
79
|
continue
|
|
78
80
|
elif(key=="!Parent"):
|
|
79
|
-
validConfParent=self.checkParent(annoKey,value)
|
|
80
|
-
|
|
81
|
+
validConfParent=self.checkParent([annoKey,"!Parent"],value)
|
|
82
|
+
validAnnoValue["!Parent"]=validConfParent
|
|
81
83
|
elif(key=="!Child"):
|
|
82
|
-
validConfChild=self.
|
|
83
|
-
|
|
84
|
+
validConfChild=self.checkDataType([annoKey,"!Child"],value)
|
|
85
|
+
validAnnoValue["!Child"]=validConfChild
|
|
84
86
|
else:
|
|
85
|
-
raise ConfigYamlError([annoKey], "
|
|
87
|
+
raise ConfigYamlError([annoKey,key], "Invalid value as !Parent.")
|
|
86
88
|
# isVisit keyの追加。
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return
|
|
89
|
+
validAnnoValue["isVisit"]=False
|
|
90
|
+
validConfigDict[annoKey]=validAnnoValue
|
|
91
|
+
return validConfigDict
|
|
90
92
|
|
|
91
93
|
@classmethod
|
|
92
|
-
def checkParent(cls,
|
|
94
|
+
def checkParent(cls,confPath,value):
|
|
93
95
|
"""
|
|
94
96
|
@Summ: `!Parent`に対応する値を型確認する関数。
|
|
95
97
|
|
|
96
98
|
@Args:
|
|
97
|
-
|
|
98
|
-
@Summ:
|
|
99
|
-
@Type:
|
|
100
|
-
|
|
101
|
-
@Summ: `!Parent
|
|
99
|
+
confPath:
|
|
100
|
+
@Summ: config yaml上の位置。
|
|
101
|
+
@Type: List
|
|
102
|
+
value:
|
|
103
|
+
@Summ: `!Parent`に対応する値。
|
|
102
104
|
@Type: Any
|
|
103
105
|
@Returns:
|
|
104
106
|
@Summ: `!Parent`のvalueとして有効な値。
|
|
105
107
|
@Type: List
|
|
106
108
|
"""
|
|
107
|
-
if(type(
|
|
108
|
-
raise ConfigYamlError(
|
|
109
|
-
for item in
|
|
109
|
+
if(type(value)!=list):
|
|
110
|
+
raise ConfigYamlError(confPath)
|
|
111
|
+
for item in value:
|
|
110
112
|
if(item is None):
|
|
111
113
|
continue
|
|
112
114
|
if(item[0]!="@"):
|
|
113
|
-
raise ConfigYamlError(
|
|
114
|
-
return
|
|
115
|
+
raise ConfigYamlError(confPath)
|
|
116
|
+
return value.copy()
|
|
115
117
|
|
|
116
118
|
@classmethod
|
|
117
|
-
def
|
|
119
|
+
def checkDataType(cls,confPath,value):
|
|
118
120
|
"""
|
|
119
|
-
@Summ:
|
|
121
|
+
@Summ: data型構文を確認する関数。
|
|
122
|
+
|
|
123
|
+
@Desc: `!Child`だけでなく、data型の入れ子が発生する際にも呼び出される。
|
|
120
124
|
|
|
121
125
|
@Args:
|
|
122
|
-
|
|
123
|
-
@Summ:
|
|
124
|
-
@Type:
|
|
125
|
-
|
|
126
|
-
@Summ:
|
|
126
|
+
confPath:
|
|
127
|
+
@Summ: config yaml上の位置。
|
|
128
|
+
@Type: List
|
|
129
|
+
value:
|
|
130
|
+
@Summ: data型構文。
|
|
127
131
|
@Type: Any
|
|
128
132
|
@Returns:
|
|
129
133
|
@Summ: `!Child`のvalueとして有効な値。
|
|
130
134
|
@Type: Dict
|
|
131
135
|
"""
|
|
132
|
-
if(type(
|
|
133
|
-
match
|
|
136
|
+
if(type(value)==str):
|
|
137
|
+
match value:
|
|
134
138
|
case "!Str":
|
|
135
|
-
|
|
139
|
+
newConfPath=confPath+["!Str"]
|
|
140
|
+
validType=cls.checkConfStr(newConfPath,None)
|
|
136
141
|
case "!Bool":
|
|
137
|
-
|
|
142
|
+
validType={"!Bool":{}}
|
|
138
143
|
case "!Int":
|
|
139
|
-
|
|
144
|
+
newConfPath=confPath+["!Int"]
|
|
145
|
+
validType=cls.checkConfInt(newConfPath,None)
|
|
140
146
|
case "!Float":
|
|
141
|
-
|
|
147
|
+
newConfPath=confPath+["!Float"]
|
|
148
|
+
validType=cls.checkConfFloat(newConfPath,None)
|
|
142
149
|
case "!List":
|
|
143
|
-
|
|
150
|
+
newConfPath=confPath+["!List"]
|
|
151
|
+
validType=cls.checkConfList(newConfPath,None)
|
|
144
152
|
case "!FreeMap":
|
|
145
|
-
|
|
153
|
+
validType={"!FreeMap":{}}
|
|
146
154
|
case "!AnnoMap":
|
|
147
|
-
|
|
155
|
+
newConfPath=confPath+["!AnnoMap"]
|
|
156
|
+
validType=cls.checkConfAnnoMap(newConfPath,None)
|
|
148
157
|
case _:
|
|
149
|
-
raise ConfigYamlError(
|
|
150
|
-
elif(type(
|
|
151
|
-
confChildKey=list(
|
|
158
|
+
raise ConfigYamlError(confPath,"Invalid data type.")
|
|
159
|
+
elif(type(value)==dict):
|
|
160
|
+
confChildKey=list(value.keys())
|
|
152
161
|
if(len(confChildKey)!=1):
|
|
153
|
-
raise ConfigYamlError(
|
|
162
|
+
raise ConfigYamlError(confPath,"Invalid data type.")
|
|
154
163
|
typeStr=confChildKey[0]
|
|
155
|
-
typeOption=
|
|
164
|
+
typeOption=value[typeStr]
|
|
156
165
|
match typeStr:
|
|
157
166
|
case "!Str":
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
strLength=None
|
|
161
|
-
strMin=None
|
|
162
|
-
strMax=None
|
|
163
|
-
for strKey,strVal in typeOption.items():
|
|
164
|
-
match strKey:
|
|
165
|
-
case "length":
|
|
166
|
-
if(strMin is None and strMax is None):
|
|
167
|
-
strLength=strVal
|
|
168
|
-
else:
|
|
169
|
-
raise ConfigYamlError([annoKey,"!Child","!Str","length"])
|
|
170
|
-
case "min":
|
|
171
|
-
if(strLength is None):
|
|
172
|
-
strMin=strVal
|
|
173
|
-
else:
|
|
174
|
-
raise ConfigYamlError([annoKey,"!Child","!Str","min"])
|
|
175
|
-
case "max":
|
|
176
|
-
if(strLength is None):
|
|
177
|
-
strMax=strVal
|
|
178
|
-
else:
|
|
179
|
-
raise ConfigYamlError([annoKey,"!Child","!Str","max"])
|
|
180
|
-
case _:
|
|
181
|
-
raise ConfigYamlError([annoKey,"!Child","!Str"])
|
|
182
|
-
return {"!Str":{"length":strLength,"min":strMin,"max":strMax}}
|
|
167
|
+
newConfPath=confPath+["!Str"]
|
|
168
|
+
validType=cls.checkConfStr(newConfPath,typeOption)
|
|
183
169
|
case "!Int":
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
intMin=None
|
|
187
|
-
intMax=None
|
|
188
|
-
for intKey,intVal in typeOption.items():
|
|
189
|
-
match intKey:
|
|
190
|
-
case "min":
|
|
191
|
-
intMin=intVal
|
|
192
|
-
case "max":
|
|
193
|
-
intMax=intVal
|
|
194
|
-
case _:
|
|
195
|
-
raise ConfigYamlError([annoKey,"!Child","!Int"])
|
|
196
|
-
return {"!Int":{"min":intMin,"max":intMax}}
|
|
170
|
+
newConfPath=confPath+["!Int"]
|
|
171
|
+
validType=cls.checkConfInt(newConfPath,typeOption)
|
|
197
172
|
case "!Float":
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
floatMin=None
|
|
201
|
-
floatMax=None
|
|
202
|
-
for floatKey,floatVal in typeOption.items():
|
|
203
|
-
match floatKey:
|
|
204
|
-
case "min":
|
|
205
|
-
if(type(floatVal)!=int and type(floatVal)!=float):
|
|
206
|
-
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
207
|
-
floatMin=floatVal
|
|
208
|
-
case "max":
|
|
209
|
-
if(type(floatVal)!=int and type(floatVal)!=float):
|
|
210
|
-
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
211
|
-
floatMax=floatVal
|
|
212
|
-
case _:
|
|
213
|
-
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
214
|
-
return {"!Float":{"min":floatMin,"max":floatMax}}
|
|
173
|
+
newConfPath=confPath+["!Float"]
|
|
174
|
+
validType=cls.checkConfFloat(newConfPath,typeOption)
|
|
215
175
|
case "!Enum":
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
enumOption=[]
|
|
219
|
-
for item in typeOption:
|
|
220
|
-
if(type(item)==list):
|
|
221
|
-
raise ConfigYamlError([annoKey,"!Child","!Enum",item])
|
|
222
|
-
elif(type(item)==dict):
|
|
223
|
-
keyList=list(item.keys())
|
|
224
|
-
if(len(keyList)!=1):
|
|
225
|
-
raise ConfigYamlError([annoKey,"!Child","!Enum",item])
|
|
226
|
-
enumOption.append(keyList[0])
|
|
227
|
-
else:
|
|
228
|
-
enumOption.append(item)
|
|
229
|
-
return {"!Enum":enumOption}
|
|
176
|
+
newConfPath=confPath+["!Enum"]
|
|
177
|
+
validType=cls.checkConfEnum(newConfPath,typeOption)
|
|
230
178
|
case "!List":
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
listType=None
|
|
234
|
-
listLength=None
|
|
235
|
-
for listKey,listVal in typeOption.items():
|
|
236
|
-
match listKey:
|
|
237
|
-
case "type":
|
|
238
|
-
listType=listVal
|
|
239
|
-
case "length":
|
|
240
|
-
listLength=listVal
|
|
241
|
-
case _:
|
|
242
|
-
raise ConfigYamlError([annoKey,"!Child","!List",listKey])
|
|
243
|
-
return {"!List":{"type":listType,"length":listLength}}
|
|
179
|
+
newConfPath=confPath+["!List"]
|
|
180
|
+
validType=cls.checkConfList(newConfPath,typeOption)
|
|
244
181
|
case "!AnnoMap":
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
for i in range(len(typeOption)):
|
|
248
|
-
item=typeOption[i]
|
|
249
|
-
if(item[0]!="@"):
|
|
250
|
-
raise ConfigYamlError([annoKey,"!Child","!AnnoMap",item])
|
|
251
|
-
return {"!AnnoMap":typeOption}
|
|
182
|
+
newConfPath=confPath+["!AnnoMap"]
|
|
183
|
+
validType=cls.checkConfAnnoMap(newConfPath,typeOption)
|
|
252
184
|
case _:
|
|
253
|
-
raise ConfigYamlError(
|
|
185
|
+
raise ConfigYamlError(confPath, "Invalid data type.")
|
|
254
186
|
else:
|
|
255
|
-
raise ConfigYamlError(
|
|
187
|
+
raise ConfigYamlError(confPath, "Invalid data type.")
|
|
188
|
+
return validType
|
|
256
189
|
|
|
257
190
|
|
|
258
191
|
def dirDFS(self,anoyPath:Path):
|
|
@@ -355,18 +288,24 @@ class DictTraversal():
|
|
|
355
288
|
self._pathQueue.append(newPath)
|
|
356
289
|
elif(type(childValue)==dict):
|
|
357
290
|
# !Child=nullであってもfree keyとannotation keyの混合は許さない。
|
|
291
|
+
# keyがstr型でない時は!FreeMapとして扱う。
|
|
358
292
|
isAnnoMap=None
|
|
359
293
|
for key,value in childValue.items():
|
|
360
|
-
if(
|
|
361
|
-
if(
|
|
362
|
-
isAnnoMap=True
|
|
363
|
-
else:
|
|
294
|
+
if(type(key)!=str):
|
|
295
|
+
if(isAnnoMap is None):
|
|
364
296
|
isAnnoMap=False
|
|
365
|
-
|
|
366
|
-
if(isAnnoMap==True and key[0]!="@"):
|
|
297
|
+
elif(isAnnoMap==True):
|
|
367
298
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!AnnoMap")
|
|
368
|
-
|
|
299
|
+
elif(key[0]=="@"):
|
|
300
|
+
if(isAnnoMap is None):
|
|
301
|
+
isAnnoMap=True
|
|
302
|
+
elif(isAnnoMap==False):
|
|
369
303
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!FreeMap")
|
|
304
|
+
else:
|
|
305
|
+
if(isAnnoMap is None):
|
|
306
|
+
isAnnoMap=False
|
|
307
|
+
elif(isAnnoMap==True):
|
|
308
|
+
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!AnnoMap")
|
|
370
309
|
newPath=self._anoyPath+[key]
|
|
371
310
|
self._visitQueue.append((key,value))
|
|
372
311
|
self._pathQueue.append(newPath)
|
|
@@ -375,27 +314,74 @@ class DictTraversal():
|
|
|
375
314
|
typeOption=confChild[typeStr]
|
|
376
315
|
match typeStr:
|
|
377
316
|
case "!Str":
|
|
378
|
-
self.
|
|
317
|
+
self.checkAnoyStr(childValue,**typeOption)
|
|
379
318
|
case "!Bool":
|
|
380
|
-
self.
|
|
319
|
+
self.checkAnoyBool(childValue)
|
|
381
320
|
case "!Int":
|
|
382
|
-
self.
|
|
321
|
+
self.checkAnoyInt(childValue,**typeOption)
|
|
383
322
|
case "!Float":
|
|
384
|
-
self.
|
|
323
|
+
self.checkAnoyFloat(childValue,**typeOption)
|
|
385
324
|
case "!FreeMap":
|
|
386
|
-
self.
|
|
325
|
+
self.checkAnoyFreeMap(childValue)
|
|
387
326
|
case "!AnnoMap":
|
|
388
|
-
self.
|
|
327
|
+
self.checkAnoyAnnoMap(parentKey,childValue,typeOption)
|
|
389
328
|
case "!List":
|
|
390
|
-
self.
|
|
329
|
+
self.checkAnoyList(parentKey,childValue,elementType=typeOption["type"],length=typeOption["length"])
|
|
391
330
|
case "!Enum":
|
|
392
|
-
self.
|
|
331
|
+
self.checkAnoyEnum(childValue,typeOption)
|
|
393
332
|
case _:
|
|
394
333
|
raise ConfigYamlError([parentKey,"!Child"])
|
|
395
334
|
|
|
396
|
-
|
|
335
|
+
@classmethod
|
|
336
|
+
def checkConfStr(cls,confPath,typeOption):
|
|
337
|
+
"""
|
|
338
|
+
@Summ: config yaml上で!Str型のtype optionを確認する関数。
|
|
339
|
+
|
|
340
|
+
@Args:
|
|
341
|
+
confPath:
|
|
342
|
+
@Summ: config yaml上の位置。
|
|
343
|
+
@Type: List
|
|
344
|
+
typeOption:
|
|
345
|
+
@Summ: !Strに対応するtype option。
|
|
346
|
+
@Desc: Noneの時はstring_formatとして処理する。
|
|
347
|
+
@Type: Dict
|
|
348
|
+
@Returns:
|
|
349
|
+
@Summ: 有効なtype option。
|
|
350
|
+
@Type: Dict
|
|
351
|
+
"""
|
|
352
|
+
lenMin=None
|
|
353
|
+
lenMax=None
|
|
354
|
+
if(typeOption is None):
|
|
355
|
+
pass
|
|
356
|
+
elif(type(typeOption)!=dict):
|
|
357
|
+
raise ConfigYamlError(confPath)
|
|
358
|
+
else:
|
|
359
|
+
for key,value in typeOption.items():
|
|
360
|
+
newConfPath=confPath+[key]
|
|
361
|
+
match key:
|
|
362
|
+
case "min":
|
|
363
|
+
lenMin=value
|
|
364
|
+
if(type(value)==int):
|
|
365
|
+
if(lenMax is not None):
|
|
366
|
+
if(lenMax<value):
|
|
367
|
+
raise ConfigYamlError(newConfPath)
|
|
368
|
+
else:
|
|
369
|
+
raise ConfigYamlError(newConfPath)
|
|
370
|
+
case "max":
|
|
371
|
+
lenMax=value
|
|
372
|
+
if(type(value)==int):
|
|
373
|
+
if(lenMax is not None):
|
|
374
|
+
if(value<lenMin):
|
|
375
|
+
raise ConfigYamlError(newConfPath)
|
|
376
|
+
else:
|
|
377
|
+
raise ConfigYamlError(newConfPath)
|
|
378
|
+
case _:
|
|
379
|
+
raise ConfigYamlError(newConfPath)
|
|
380
|
+
return {"!Str":{"min":lenMin,"max":lenMax}}
|
|
381
|
+
|
|
382
|
+
def checkAnoyStr(self,anoyValue,length=None,min=None,max=None):
|
|
397
383
|
"""
|
|
398
|
-
@Summ:
|
|
384
|
+
@Summ: ANOY上で!Str型を型確認する関数。
|
|
399
385
|
|
|
400
386
|
@Desc:
|
|
401
387
|
- <length>と<min>、<length>と<max>の両立は不可能であるが、この関数ではその確認を行わない。
|
|
@@ -435,9 +421,9 @@ class DictTraversal():
|
|
|
435
421
|
else:
|
|
436
422
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Str")
|
|
437
423
|
|
|
438
|
-
def
|
|
424
|
+
def checkAnoyBool(self,anoyValue):
|
|
439
425
|
"""
|
|
440
|
-
@Summ:
|
|
426
|
+
@Summ: ANOY上で!Bool型を型確認する関数。
|
|
441
427
|
|
|
442
428
|
@Args:
|
|
443
429
|
anoyValue:
|
|
@@ -446,9 +432,43 @@ class DictTraversal():
|
|
|
446
432
|
if(type(anoyValue)!=bool):
|
|
447
433
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Bool")
|
|
448
434
|
|
|
449
|
-
|
|
435
|
+
@classmethod
|
|
436
|
+
def checkConfInt(cls,annoKey,typeOption):
|
|
450
437
|
"""
|
|
451
|
-
@Summ:
|
|
438
|
+
@Summ: config yaml上で!Int型のtype optionを確認する関数。
|
|
439
|
+
|
|
440
|
+
@Args:
|
|
441
|
+
annoKey:
|
|
442
|
+
@Summ: `!Child!Str`を格納するannotation key。
|
|
443
|
+
@Type: Str
|
|
444
|
+
typeOption:
|
|
445
|
+
@Summ: !Intに対応するtype option。
|
|
446
|
+
@Desc: Noneの時はstring_formatとして処理する。
|
|
447
|
+
@Type: Dict
|
|
448
|
+
@Returns:
|
|
449
|
+
@Summ: 有効なtype option。
|
|
450
|
+
@Type: Dict
|
|
451
|
+
"""
|
|
452
|
+
intMin=None
|
|
453
|
+
intMax=None
|
|
454
|
+
if(typeOption is None):
|
|
455
|
+
pass
|
|
456
|
+
elif(type(typeOption)!=dict):
|
|
457
|
+
raise ConfigYamlError([annoKey,"!Child","!Str"], "Required `!Map` type.")
|
|
458
|
+
else:
|
|
459
|
+
for intKey,intVal in typeOption.items():
|
|
460
|
+
match intKey:
|
|
461
|
+
case "min":
|
|
462
|
+
intMin=intVal
|
|
463
|
+
case "max":
|
|
464
|
+
intMax=intVal
|
|
465
|
+
case _:
|
|
466
|
+
raise ConfigYamlError([annoKey,"!Child","!Int"])
|
|
467
|
+
return {"!Int":{"min":intMin,"max":intMax}}
|
|
468
|
+
|
|
469
|
+
def checkAnoyInt(self,anoyValue,min=None,max=None):
|
|
470
|
+
"""
|
|
471
|
+
@Summ: ANOY上で!Int型を型確認する関数。
|
|
452
472
|
|
|
453
473
|
@Args:
|
|
454
474
|
anoyValue:
|
|
@@ -469,9 +489,47 @@ class DictTraversal():
|
|
|
469
489
|
else:
|
|
470
490
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Int")
|
|
471
491
|
|
|
472
|
-
|
|
492
|
+
@classmethod
|
|
493
|
+
def checkConfFloat(cls,annoKey,typeOption):
|
|
473
494
|
"""
|
|
474
|
-
@Summ:
|
|
495
|
+
@Summ: config yaml上で!Float型のtype optionを確認する関数。
|
|
496
|
+
|
|
497
|
+
@Args:
|
|
498
|
+
annoKey:
|
|
499
|
+
@Summ: `!Child!Float`を格納するannotation key。
|
|
500
|
+
@Type: Str
|
|
501
|
+
typeOption:
|
|
502
|
+
@Summ: !Floatに対応するtype option。
|
|
503
|
+
@Desc: Noneの時はstring_formatとして処理する。
|
|
504
|
+
@Type: Dict
|
|
505
|
+
@Returns:
|
|
506
|
+
@Summ: 有効なtype option。
|
|
507
|
+
@Type: Dict
|
|
508
|
+
"""
|
|
509
|
+
floatMin=None
|
|
510
|
+
floatMax=None
|
|
511
|
+
if(typeOption is None):
|
|
512
|
+
pass
|
|
513
|
+
elif(type(typeOption)!=dict):
|
|
514
|
+
raise ConfigYamlError([annoKey,"!Child","!Float"], "Required `!Map` type.")
|
|
515
|
+
else:
|
|
516
|
+
for floatKey,floatVal in typeOption.items():
|
|
517
|
+
match floatKey:
|
|
518
|
+
case "min":
|
|
519
|
+
if(type(floatVal)!=int and type(floatVal)!=float):
|
|
520
|
+
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
521
|
+
floatMin=floatVal
|
|
522
|
+
case "max":
|
|
523
|
+
if(type(floatVal)!=int and type(floatVal)!=float):
|
|
524
|
+
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
525
|
+
floatMax=floatVal
|
|
526
|
+
case _:
|
|
527
|
+
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
528
|
+
return {"!Float":{"min":floatMin,"max":floatMax}}
|
|
529
|
+
|
|
530
|
+
def checkAnoyFloat(self,anoyValue,min=None,max=None):
|
|
531
|
+
"""
|
|
532
|
+
@Summ: ANOY上で!Float型を型確認する関数。
|
|
475
533
|
|
|
476
534
|
@Args:
|
|
477
535
|
anoyValue:
|
|
@@ -498,9 +556,9 @@ class DictTraversal():
|
|
|
498
556
|
else:
|
|
499
557
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Float")
|
|
500
558
|
|
|
501
|
-
def
|
|
559
|
+
def checkAnoyFreeMap(self,anoyValue):
|
|
502
560
|
"""
|
|
503
|
-
@Summ:
|
|
561
|
+
@Summ: ANOY上で!FreeMap型を型確認する関数。
|
|
504
562
|
|
|
505
563
|
@Args:
|
|
506
564
|
anoyValue:
|
|
@@ -511,14 +569,43 @@ class DictTraversal():
|
|
|
511
569
|
newPath=self._anoyPath+[key]
|
|
512
570
|
self._visitQueue.append((key,value))
|
|
513
571
|
self._pathQueue.append(newPath)
|
|
514
|
-
if(key
|
|
515
|
-
|
|
572
|
+
if(type(key)==str):
|
|
573
|
+
if(key[0]=="@"):
|
|
574
|
+
raise AnnotationTypeError(self._curAnoy,newPath,"!FreeMap")
|
|
516
575
|
else:
|
|
517
576
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!FreeMap")
|
|
518
577
|
|
|
519
|
-
|
|
578
|
+
@classmethod
|
|
579
|
+
def checkConfAnnoMap(cls,annoKey,typeOption):
|
|
520
580
|
"""
|
|
521
|
-
@Summ:
|
|
581
|
+
@Summ: config yaml上で!AnnoMap型のtype optionを確認する関数。
|
|
582
|
+
|
|
583
|
+
@Args:
|
|
584
|
+
annoKey:
|
|
585
|
+
@Summ: `!Child!AnnoMap`を格納するannotation key。
|
|
586
|
+
@Type: Str
|
|
587
|
+
typeOption:
|
|
588
|
+
@Summ: !AnnoMapに対応するtype option。
|
|
589
|
+
@Desc: Noneの時はstring_formatとして処理する。
|
|
590
|
+
@Type: List
|
|
591
|
+
@Returns:
|
|
592
|
+
@Summ: 有効なtype option。
|
|
593
|
+
@Type: Dict
|
|
594
|
+
"""
|
|
595
|
+
if(typeOption is None):
|
|
596
|
+
typeOption=[]
|
|
597
|
+
elif(type(typeOption)!=list):
|
|
598
|
+
raise ConfigYamlError([annoKey,"!Child","!AnnoMap"])
|
|
599
|
+
else:
|
|
600
|
+
for i in range(len(typeOption)):
|
|
601
|
+
item=typeOption[i]
|
|
602
|
+
if(item[0]!="@"):
|
|
603
|
+
raise ConfigYamlError([annoKey,"!Child","!AnnoMap",item])
|
|
604
|
+
return {"!AnnoMap":typeOption}
|
|
605
|
+
|
|
606
|
+
def checkAnoyAnnoMap(self,parentKey,anoyValue,annoKeyList:list=[]):
|
|
607
|
+
"""
|
|
608
|
+
@Summ: ANOY上で!FreeMap型を型確認する関数。
|
|
522
609
|
|
|
523
610
|
@Desc:
|
|
524
611
|
- <annoKeyList>は最低限必要なannotation keyのlistが入る。
|
|
@@ -557,9 +644,50 @@ class DictTraversal():
|
|
|
557
644
|
else:
|
|
558
645
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!AnnoMap")
|
|
559
646
|
|
|
560
|
-
|
|
647
|
+
@classmethod
|
|
648
|
+
def checkConfList(cls,annoKey,typeOption):
|
|
561
649
|
"""
|
|
562
|
-
@Summ:
|
|
650
|
+
@Summ: config yaml上で!List型のtype optionを確認する関数。
|
|
651
|
+
|
|
652
|
+
@Args:
|
|
653
|
+
annoKey:
|
|
654
|
+
@Summ: `!Child!List`を格納するannotation key。
|
|
655
|
+
@Type: Str
|
|
656
|
+
typeOption:
|
|
657
|
+
@Summ: !Listに対応するtype option。
|
|
658
|
+
@Desc: Noneの時はstring_formatとして処理する。
|
|
659
|
+
@Type: Dict
|
|
660
|
+
@Returns:
|
|
661
|
+
@Summ: 有効なtype option。
|
|
662
|
+
@Type: Dict
|
|
663
|
+
"""
|
|
664
|
+
listType=None
|
|
665
|
+
listLength=None
|
|
666
|
+
if(typeOption is None):
|
|
667
|
+
pass
|
|
668
|
+
elif(type(typeOption)!=dict):
|
|
669
|
+
raise ConfigYamlError([annoKey,"!Child","!List"])
|
|
670
|
+
else:
|
|
671
|
+
for listKey,listVal in typeOption.items():
|
|
672
|
+
match listKey:
|
|
673
|
+
case "type":
|
|
674
|
+
listType=listVal
|
|
675
|
+
case "length":
|
|
676
|
+
if(listVal is None):
|
|
677
|
+
continue
|
|
678
|
+
elif(type(listVal)!=int):
|
|
679
|
+
raise ConfigYamlError([annoKey,"!Child","!List",listKey])
|
|
680
|
+
elif(listVal<=0):
|
|
681
|
+
raise ConfigYamlError([annoKey,"!Child","!List",listKey])
|
|
682
|
+
listLength=listVal
|
|
683
|
+
case _:
|
|
684
|
+
raise ConfigYamlError([annoKey,"!Child","!List",listKey])
|
|
685
|
+
return {"!List":{"type":listType,"length":listLength}}
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
def checkAnoyList(self,parentKey,anoyValue,elementType:str=None,length:int=None):
|
|
689
|
+
"""
|
|
690
|
+
@Summ: ANOY上で!List型を型確認する関数。
|
|
563
691
|
|
|
564
692
|
@Desc:
|
|
565
693
|
- <typeOption>は最低限必要なannotation keyのlistが入る。
|
|
@@ -608,10 +736,42 @@ class DictTraversal():
|
|
|
608
736
|
self._pathQueue.append(newPath)
|
|
609
737
|
else:
|
|
610
738
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!List")
|
|
611
|
-
|
|
612
|
-
|
|
739
|
+
|
|
740
|
+
@classmethod
|
|
741
|
+
def checkConfEnum(cls,annoKey,typeOption):
|
|
742
|
+
"""
|
|
743
|
+
@Summ: config yaml上で!Enum型のtype optionを確認する関数。
|
|
744
|
+
|
|
745
|
+
@Args:
|
|
746
|
+
annoKey:
|
|
747
|
+
@Summ: `!Child!Enum`を格納するannotation key。
|
|
748
|
+
@Type: Str
|
|
749
|
+
typeOption:
|
|
750
|
+
@Summ: !Enumに対応するtype option。
|
|
751
|
+
@Type: List
|
|
752
|
+
@Returns:
|
|
753
|
+
@Summ: 有効なtype option。
|
|
754
|
+
@Type: Dict
|
|
755
|
+
"""
|
|
756
|
+
enumOption=[]
|
|
757
|
+
if(type(typeOption)!=list):
|
|
758
|
+
raise ConfigYamlError([annoKey,"!Child","!Enum"])
|
|
759
|
+
else:
|
|
760
|
+
for item in typeOption:
|
|
761
|
+
if(type(item)==list):
|
|
762
|
+
raise ConfigYamlError([annoKey,"!Child","!Enum",item])
|
|
763
|
+
elif(type(item)==dict):
|
|
764
|
+
keyList=list(item.keys())
|
|
765
|
+
if(len(keyList)!=1):
|
|
766
|
+
raise ConfigYamlError([annoKey,"!Child","!Enum",item])
|
|
767
|
+
enumOption.append(keyList[0])
|
|
768
|
+
else:
|
|
769
|
+
enumOption.append(item)
|
|
770
|
+
return {"!Enum":enumOption}
|
|
771
|
+
|
|
772
|
+
def checkAnoyEnum(self,anoyValue,optionList:list):
|
|
613
773
|
"""
|
|
614
|
-
@Summ:
|
|
774
|
+
@Summ: ANOY上で!Enum型を型確認する関数。
|
|
615
775
|
|
|
616
776
|
@Desc:
|
|
617
777
|
- 他の言語のUnion型の役割も兼ねている。
|
anoy-0.3.0.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
cli.py,sha256=7_Lb8t4A3aGUnVXCkQJIKknz8L4zYo3Oy-1BsKxWi1w,912
|
|
2
|
-
anoy-0.3.0.dist-info/licenses/LICENSE.txt,sha256=nsHvySI1U7YZgAX4K3rJsWli_GfXy2syPI-MtGPwjlo,1062
|
|
3
|
-
modules/__init__.py,sha256=WSvUse7H-6ConliG5plmNLGHjeHWXqHR9t901plrWM0,133
|
|
4
|
-
modules/dictTraversal.py,sha256=6195pQMghpjbLNzdDNit3_FBYQ4dPykhRwRTmf8Vv5c,27455
|
|
5
|
-
modules/errors.py,sha256=P9KwBhPdPGdujCMA00Ep37RvPLwGYsNip4RidT7oMdg,2091
|
|
6
|
-
anoy-0.3.0.dist-info/METADATA,sha256=YZyydL2kbJcoHrppESmwaTtKKJkB4LhI56qbxfwCIdg,3873
|
|
7
|
-
anoy-0.3.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
8
|
-
anoy-0.3.0.dist-info/entry_points.txt,sha256=_lpL6R97giGseZcV0r5QwdX4zRwoZLzRHUxyBZl_iYI,34
|
|
9
|
-
anoy-0.3.0.dist-info/top_level.txt,sha256=jfF8JYDvxB66wJSH2sWhdDiR0GGzxt5x-1k2vxwZKqA,12
|
|
10
|
-
anoy-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|