anoy 0.3.1__py3-none-any.whl → 0.3.3__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.1.dist-info → anoy-0.3.3.dist-info}/METADATA +1 -1
- anoy-0.3.3.dist-info/RECORD +10 -0
- cli.py +1 -1
- modules/dictTraversal.py +319 -178
- anoy-0.3.1.dist-info/RECORD +0 -10
- {anoy-0.3.1.dist-info → anoy-0.3.3.dist-info}/WHEEL +0 -0
- {anoy-0.3.1.dist-info → anoy-0.3.3.dist-info}/entry_points.txt +0 -0
- {anoy-0.3.1.dist-info → anoy-0.3.3.dist-info}/licenses/LICENSE.txt +0 -0
- {anoy-0.3.1.dist-info → anoy-0.3.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
cli.py,sha256=7nBKcOYABjhlAoKfQyoqUyQ8ALJKyrJJhqWC950Ks2g,912
|
|
2
|
+
anoy-0.3.3.dist-info/licenses/LICENSE.txt,sha256=nsHvySI1U7YZgAX4K3rJsWli_GfXy2syPI-MtGPwjlo,1062
|
|
3
|
+
modules/__init__.py,sha256=WSvUse7H-6ConliG5plmNLGHjeHWXqHR9t901plrWM0,133
|
|
4
|
+
modules/dictTraversal.py,sha256=1O74wxiuCEd7J_PZXXC7T0AyspmRwXoAE1ioddd6AjA,32170
|
|
5
|
+
modules/errors.py,sha256=P9KwBhPdPGdujCMA00Ep37RvPLwGYsNip4RidT7oMdg,2091
|
|
6
|
+
anoy-0.3.3.dist-info/METADATA,sha256=bSXScAcxgWKiW6KG9PcaiIcsixLqZa4GhY-fs8GJPPs,3873
|
|
7
|
+
anoy-0.3.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
8
|
+
anoy-0.3.3.dist-info/entry_points.txt,sha256=_lpL6R97giGseZcV0r5QwdX4zRwoZLzRHUxyBZl_iYI,34
|
|
9
|
+
anoy-0.3.3.dist-info/top_level.txt,sha256=jfF8JYDvxB66wJSH2sWhdDiR0GGzxt5x-1k2vxwZKqA,12
|
|
10
|
+
anoy-0.3.3.dist-info/RECORD,,
|
cli.py
CHANGED
modules/dictTraversal.py
CHANGED
|
@@ -64,12 +64,10 @@ class DictTraversal():
|
|
|
64
64
|
@Summ: 型確認して、余計なものを取り除いたconfigDict。
|
|
65
65
|
@Type: dict
|
|
66
66
|
"""
|
|
67
|
-
|
|
67
|
+
validConfigDict={} # 整形されたconfigDict
|
|
68
68
|
for annoKey in configDict.keys():
|
|
69
|
-
|
|
70
|
-
if(
|
|
71
|
-
raise ConfigYamlError([annoKey],"Annotaion key should start with `@`.")
|
|
72
|
-
elif(annoKey[0]!="@"):
|
|
69
|
+
validAnnoValue={} #annotation value.
|
|
70
|
+
if(annoKey[0]!="@"):
|
|
73
71
|
raise ConfigYamlError([annoKey],"Annotaion key should start with `@`.")
|
|
74
72
|
valueDict=configDict[annoKey]
|
|
75
73
|
if(type(valueDict)!=dict):
|
|
@@ -80,185 +78,105 @@ class DictTraversal():
|
|
|
80
78
|
if(key[0]=="@"):
|
|
81
79
|
continue
|
|
82
80
|
elif(key=="!Parent"):
|
|
83
|
-
validConfParent=self.checkParent(annoKey,value)
|
|
84
|
-
|
|
81
|
+
validConfParent=self.checkParent([annoKey,"!Parent"],value)
|
|
82
|
+
validAnnoValue["!Parent"]=validConfParent
|
|
85
83
|
elif(key=="!Child"):
|
|
86
|
-
validConfChild=self.
|
|
87
|
-
|
|
84
|
+
validConfChild=self.checkDataType([annoKey,"!Child"],value)
|
|
85
|
+
validAnnoValue["!Child"]=validConfChild
|
|
88
86
|
else:
|
|
89
87
|
raise ConfigYamlError([annoKey,key], "Invalid value as !Parent.")
|
|
90
88
|
# isVisit keyの追加。
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return
|
|
89
|
+
validAnnoValue["isVisit"]=False
|
|
90
|
+
validConfigDict[annoKey]=validAnnoValue
|
|
91
|
+
return validConfigDict
|
|
94
92
|
|
|
95
93
|
@classmethod
|
|
96
|
-
def checkParent(cls,
|
|
94
|
+
def checkParent(cls,confPath,value):
|
|
97
95
|
"""
|
|
98
96
|
@Summ: `!Parent`に対応する値を型確認する関数。
|
|
99
97
|
|
|
100
98
|
@Args:
|
|
101
|
-
|
|
102
|
-
@Summ:
|
|
103
|
-
@Type:
|
|
104
|
-
|
|
105
|
-
@Summ: `!Parent
|
|
99
|
+
confPath:
|
|
100
|
+
@Summ: config yaml上の位置。
|
|
101
|
+
@Type: List
|
|
102
|
+
value:
|
|
103
|
+
@Summ: `!Parent`に対応する値。
|
|
106
104
|
@Type: Any
|
|
107
105
|
@Returns:
|
|
108
106
|
@Summ: `!Parent`のvalueとして有効な値。
|
|
109
107
|
@Type: List
|
|
110
108
|
"""
|
|
111
|
-
if(type(
|
|
112
|
-
raise ConfigYamlError(
|
|
113
|
-
for item in
|
|
109
|
+
if(type(value)!=list):
|
|
110
|
+
raise ConfigYamlError(confPath)
|
|
111
|
+
for item in value:
|
|
114
112
|
if(item is None):
|
|
115
113
|
continue
|
|
116
114
|
if(item[0]!="@"):
|
|
117
|
-
raise ConfigYamlError(
|
|
118
|
-
return
|
|
115
|
+
raise ConfigYamlError(confPath)
|
|
116
|
+
return value.copy()
|
|
119
117
|
|
|
120
118
|
@classmethod
|
|
121
|
-
def
|
|
119
|
+
def checkDataType(cls,confPath,value):
|
|
122
120
|
"""
|
|
123
|
-
@Summ:
|
|
121
|
+
@Summ: data型構文を確認する関数。
|
|
122
|
+
|
|
123
|
+
@Desc: `!Child`だけでなく、data型の入れ子が発生する際にも呼び出される。
|
|
124
124
|
|
|
125
125
|
@Args:
|
|
126
|
-
|
|
127
|
-
@Summ:
|
|
128
|
-
@Type:
|
|
129
|
-
|
|
130
|
-
@Summ:
|
|
126
|
+
confPath:
|
|
127
|
+
@Summ: config yaml上の位置。
|
|
128
|
+
@Type: List
|
|
129
|
+
value:
|
|
130
|
+
@Summ: data型構文。
|
|
131
131
|
@Type: Any
|
|
132
132
|
@Returns:
|
|
133
133
|
@Summ: `!Child`のvalueとして有効な値。
|
|
134
134
|
@Type: Dict
|
|
135
135
|
"""
|
|
136
|
-
if(type(
|
|
137
|
-
|
|
136
|
+
if(type(value)==str):
|
|
137
|
+
newConfPath=confPath+[value]
|
|
138
|
+
match value:
|
|
138
139
|
case "!Str":
|
|
139
|
-
|
|
140
|
+
validType=cls.checkConfStr(newConfPath,None)
|
|
140
141
|
case "!Bool":
|
|
141
|
-
|
|
142
|
+
validType={"!Bool":{}}
|
|
142
143
|
case "!Int":
|
|
143
|
-
|
|
144
|
+
validType=cls.checkConfInt(newConfPath,None)
|
|
144
145
|
case "!Float":
|
|
145
|
-
|
|
146
|
+
validType=cls.checkConfFloat(newConfPath,None)
|
|
146
147
|
case "!List":
|
|
147
|
-
|
|
148
|
+
validType=cls.checkConfList(newConfPath,None)
|
|
148
149
|
case "!FreeMap":
|
|
149
|
-
|
|
150
|
+
validType={"!FreeMap":{}}
|
|
150
151
|
case "!AnnoMap":
|
|
151
|
-
|
|
152
|
+
validType=cls.checkConfAnnoMap(newConfPath,None)
|
|
152
153
|
case _:
|
|
153
|
-
raise ConfigYamlError(
|
|
154
|
-
elif(type(
|
|
155
|
-
confChildKey=list(
|
|
154
|
+
raise ConfigYamlError(newConfPath,"Invalid data type.")
|
|
155
|
+
elif(type(value)==dict):
|
|
156
|
+
confChildKey=list(value.keys())
|
|
156
157
|
if(len(confChildKey)!=1):
|
|
157
|
-
raise ConfigYamlError(
|
|
158
|
+
raise ConfigYamlError(confPath,"Invalid data type.")
|
|
158
159
|
typeStr=confChildKey[0]
|
|
159
|
-
|
|
160
|
+
newConfPath=confPath+[typeStr]
|
|
161
|
+
typeOption=value[typeStr]
|
|
160
162
|
match typeStr:
|
|
161
163
|
case "!Str":
|
|
162
|
-
|
|
163
|
-
raise ConfigYamlError([annoKey,"!Child","!Str"])
|
|
164
|
-
strLength=None
|
|
165
|
-
strMin=None
|
|
166
|
-
strMax=None
|
|
167
|
-
for strKey,strVal in typeOption.items():
|
|
168
|
-
match strKey:
|
|
169
|
-
case "length":
|
|
170
|
-
if(strMin is None and strMax is None):
|
|
171
|
-
strLength=strVal
|
|
172
|
-
else:
|
|
173
|
-
raise ConfigYamlError([annoKey,"!Child","!Str","length"])
|
|
174
|
-
case "min":
|
|
175
|
-
if(strLength is None):
|
|
176
|
-
strMin=strVal
|
|
177
|
-
else:
|
|
178
|
-
raise ConfigYamlError([annoKey,"!Child","!Str","min"])
|
|
179
|
-
case "max":
|
|
180
|
-
if(strLength is None):
|
|
181
|
-
strMax=strVal
|
|
182
|
-
else:
|
|
183
|
-
raise ConfigYamlError([annoKey,"!Child","!Str","max"])
|
|
184
|
-
case _:
|
|
185
|
-
raise ConfigYamlError([annoKey,"!Child","!Str"])
|
|
186
|
-
return {"!Str":{"length":strLength,"min":strMin,"max":strMax}}
|
|
164
|
+
validType=cls.checkConfStr(newConfPath,typeOption)
|
|
187
165
|
case "!Int":
|
|
188
|
-
|
|
189
|
-
raise ConfigYamlError([annoKey,"!Child","!Str"], "Required `!Map` type.")
|
|
190
|
-
intMin=None
|
|
191
|
-
intMax=None
|
|
192
|
-
for intKey,intVal in typeOption.items():
|
|
193
|
-
match intKey:
|
|
194
|
-
case "min":
|
|
195
|
-
intMin=intVal
|
|
196
|
-
case "max":
|
|
197
|
-
intMax=intVal
|
|
198
|
-
case _:
|
|
199
|
-
raise ConfigYamlError([annoKey,"!Child","!Int"])
|
|
200
|
-
return {"!Int":{"min":intMin,"max":intMax}}
|
|
166
|
+
validType=cls.checkConfInt(newConfPath,typeOption)
|
|
201
167
|
case "!Float":
|
|
202
|
-
|
|
203
|
-
raise ConfigYamlError([annoKey,"!Child","!Float"], "Required `!Map` type.")
|
|
204
|
-
floatMin=None
|
|
205
|
-
floatMax=None
|
|
206
|
-
for floatKey,floatVal in typeOption.items():
|
|
207
|
-
match floatKey:
|
|
208
|
-
case "min":
|
|
209
|
-
if(type(floatVal)!=int and type(floatVal)!=float):
|
|
210
|
-
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
211
|
-
floatMin=floatVal
|
|
212
|
-
case "max":
|
|
213
|
-
if(type(floatVal)!=int and type(floatVal)!=float):
|
|
214
|
-
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
215
|
-
floatMax=floatVal
|
|
216
|
-
case _:
|
|
217
|
-
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
218
|
-
return {"!Float":{"min":floatMin,"max":floatMax}}
|
|
168
|
+
validType=cls.checkConfFloat(newConfPath,typeOption)
|
|
219
169
|
case "!Enum":
|
|
220
|
-
|
|
221
|
-
raise ConfigYamlError([annoKey,"!Child","!Enum"])
|
|
222
|
-
enumOption=[]
|
|
223
|
-
for item in typeOption:
|
|
224
|
-
if(type(item)==list):
|
|
225
|
-
raise ConfigYamlError([annoKey,"!Child","!Enum",item])
|
|
226
|
-
elif(type(item)==dict):
|
|
227
|
-
keyList=list(item.keys())
|
|
228
|
-
if(len(keyList)!=1):
|
|
229
|
-
raise ConfigYamlError([annoKey,"!Child","!Enum",item])
|
|
230
|
-
enumOption.append(keyList[0])
|
|
231
|
-
else:
|
|
232
|
-
enumOption.append(item)
|
|
233
|
-
return {"!Enum":enumOption}
|
|
170
|
+
validType=cls.checkConfEnum(newConfPath,typeOption)
|
|
234
171
|
case "!List":
|
|
235
|
-
|
|
236
|
-
raise ConfigYamlError([annoKey,"!Child","!List"])
|
|
237
|
-
listType=None
|
|
238
|
-
listLength=None
|
|
239
|
-
for listKey,listVal in typeOption.items():
|
|
240
|
-
match listKey:
|
|
241
|
-
case "type":
|
|
242
|
-
listType=listVal
|
|
243
|
-
case "length":
|
|
244
|
-
listLength=listVal
|
|
245
|
-
case _:
|
|
246
|
-
raise ConfigYamlError([annoKey,"!Child","!List",listKey])
|
|
247
|
-
return {"!List":{"type":listType,"length":listLength}}
|
|
172
|
+
validType=cls.checkConfList(newConfPath,typeOption)
|
|
248
173
|
case "!AnnoMap":
|
|
249
|
-
|
|
250
|
-
raise ConfigYamlError([annoKey,"!Child","!AnnoMap"])
|
|
251
|
-
for i in range(len(typeOption)):
|
|
252
|
-
item=typeOption[i]
|
|
253
|
-
if(type(item)!=str):
|
|
254
|
-
raise ConfigYamlError([annoKey,"!Child","!AnnoMap",item])
|
|
255
|
-
elif(item[0]!="@"):
|
|
256
|
-
raise ConfigYamlError([annoKey,"!Child","!AnnoMap",item])
|
|
257
|
-
return {"!AnnoMap":typeOption}
|
|
174
|
+
validType=cls.checkConfAnnoMap(newConfPath,typeOption)
|
|
258
175
|
case _:
|
|
259
|
-
raise ConfigYamlError(
|
|
176
|
+
raise ConfigYamlError(newConfPath,"Invalid data type.")
|
|
260
177
|
else:
|
|
261
|
-
raise ConfigYamlError(
|
|
178
|
+
raise ConfigYamlError(confPath,"Invalid data type.")
|
|
179
|
+
return validType
|
|
262
180
|
|
|
263
181
|
|
|
264
182
|
def dirDFS(self,anoyPath:Path):
|
|
@@ -387,27 +305,74 @@ class DictTraversal():
|
|
|
387
305
|
typeOption=confChild[typeStr]
|
|
388
306
|
match typeStr:
|
|
389
307
|
case "!Str":
|
|
390
|
-
self.
|
|
308
|
+
self.checkAnoyStr(childValue,**typeOption)
|
|
391
309
|
case "!Bool":
|
|
392
|
-
self.
|
|
310
|
+
self.checkAnoyBool(childValue)
|
|
393
311
|
case "!Int":
|
|
394
|
-
self.
|
|
312
|
+
self.checkAnoyInt(childValue,**typeOption)
|
|
395
313
|
case "!Float":
|
|
396
|
-
self.
|
|
314
|
+
self.checkAnoyFloat(childValue,**typeOption)
|
|
397
315
|
case "!FreeMap":
|
|
398
|
-
self.
|
|
316
|
+
self.checkAnoyFreeMap(childValue)
|
|
399
317
|
case "!AnnoMap":
|
|
400
|
-
self.
|
|
318
|
+
self.checkAnoyAnnoMap(parentKey,childValue,typeOption)
|
|
401
319
|
case "!List":
|
|
402
|
-
self.
|
|
320
|
+
self.checkAnoyList(parentKey,childValue,elementType=typeOption["type"],length=typeOption["length"])
|
|
403
321
|
case "!Enum":
|
|
404
|
-
self.
|
|
322
|
+
self.checkAnoyEnum(childValue,typeOption)
|
|
405
323
|
case _:
|
|
406
324
|
raise ConfigYamlError([parentKey,"!Child"])
|
|
407
325
|
|
|
408
|
-
|
|
326
|
+
@classmethod
|
|
327
|
+
def checkConfStr(cls,confPath,typeOption):
|
|
328
|
+
"""
|
|
329
|
+
@Summ: config yaml上で!Str型のtype optionを確認する関数。
|
|
330
|
+
|
|
331
|
+
@Args:
|
|
332
|
+
confPath:
|
|
333
|
+
@Summ: config yaml上の位置。
|
|
334
|
+
@Type: List
|
|
335
|
+
typeOption:
|
|
336
|
+
@Summ: !Strに対応するtype option。
|
|
337
|
+
@Desc: Noneの時はstring_formatとして処理する。
|
|
338
|
+
@Type: Dict
|
|
339
|
+
@Returns:
|
|
340
|
+
@Summ: 有効なtype option。
|
|
341
|
+
@Type: Dict
|
|
342
|
+
"""
|
|
343
|
+
lenMin=None
|
|
344
|
+
lenMax=None
|
|
345
|
+
if(typeOption is None):
|
|
346
|
+
pass
|
|
347
|
+
elif(type(typeOption)!=dict):
|
|
348
|
+
raise ConfigYamlError(confPath)
|
|
349
|
+
else:
|
|
350
|
+
for key,value in typeOption.items():
|
|
351
|
+
newConfPath=confPath+[key]
|
|
352
|
+
match key:
|
|
353
|
+
case "min":
|
|
354
|
+
lenMin=value
|
|
355
|
+
if(type(value)==int):
|
|
356
|
+
if(lenMax is not None):
|
|
357
|
+
if(lenMax<value):
|
|
358
|
+
raise ConfigYamlError(newConfPath)
|
|
359
|
+
else:
|
|
360
|
+
raise ConfigYamlError(newConfPath)
|
|
361
|
+
case "max":
|
|
362
|
+
lenMax=value
|
|
363
|
+
if(type(value)==int):
|
|
364
|
+
if(lenMax is not None):
|
|
365
|
+
if(value<lenMin):
|
|
366
|
+
raise ConfigYamlError(newConfPath)
|
|
367
|
+
else:
|
|
368
|
+
raise ConfigYamlError(newConfPath)
|
|
369
|
+
case _:
|
|
370
|
+
raise ConfigYamlError(newConfPath)
|
|
371
|
+
return {"!Str":{"min":lenMin,"max":lenMax}}
|
|
372
|
+
|
|
373
|
+
def checkAnoyStr(self,anoyValue,min=None,max=None):
|
|
409
374
|
"""
|
|
410
|
-
@Summ:
|
|
375
|
+
@Summ: ANOY上で!Str型を型確認する関数。
|
|
411
376
|
|
|
412
377
|
@Desc:
|
|
413
378
|
- <length>と<min>、<length>と<max>の両立は不可能であるが、この関数ではその確認を行わない。
|
|
@@ -416,9 +381,6 @@ class DictTraversal():
|
|
|
416
381
|
@Args:
|
|
417
382
|
anoyValue:
|
|
418
383
|
@Summ: 型確認する値。
|
|
419
|
-
length:
|
|
420
|
-
@Summ: 文字列の長さ。
|
|
421
|
-
@Desc: min,maxとの両立は不可能。
|
|
422
384
|
min:
|
|
423
385
|
@Summ: 文字列の長さの最小値。
|
|
424
386
|
@Desc:
|
|
@@ -431,25 +393,18 @@ class DictTraversal():
|
|
|
431
393
|
- max+1からerror.
|
|
432
394
|
"""
|
|
433
395
|
if(type(anoyValue)==str):
|
|
434
|
-
if(
|
|
435
|
-
if(len(anoyValue)
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
if(min is not None):
|
|
441
|
-
if(len(anoyValue)<min):
|
|
442
|
-
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Str")
|
|
443
|
-
if(max is not None):
|
|
444
|
-
if(max<len(anoyValue)):
|
|
445
|
-
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Str")
|
|
446
|
-
return
|
|
396
|
+
if(min is not None):
|
|
397
|
+
if(len(anoyValue)<min):
|
|
398
|
+
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Str")
|
|
399
|
+
if(max is not None):
|
|
400
|
+
if(max<len(anoyValue)):
|
|
401
|
+
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Str")
|
|
447
402
|
else:
|
|
448
403
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Str")
|
|
449
404
|
|
|
450
|
-
def
|
|
405
|
+
def checkAnoyBool(self,anoyValue):
|
|
451
406
|
"""
|
|
452
|
-
@Summ:
|
|
407
|
+
@Summ: ANOY上で!Bool型を型確認する関数。
|
|
453
408
|
|
|
454
409
|
@Args:
|
|
455
410
|
anoyValue:
|
|
@@ -458,9 +413,56 @@ class DictTraversal():
|
|
|
458
413
|
if(type(anoyValue)!=bool):
|
|
459
414
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Bool")
|
|
460
415
|
|
|
461
|
-
|
|
416
|
+
@classmethod
|
|
417
|
+
def checkConfInt(cls,confPath,typeOption):
|
|
462
418
|
"""
|
|
463
|
-
@Summ:
|
|
419
|
+
@Summ: config yaml上で!Int型のtype optionを確認する関数。
|
|
420
|
+
|
|
421
|
+
@Args:
|
|
422
|
+
confPath:
|
|
423
|
+
@Summ: config yaml上の位置。
|
|
424
|
+
@Type: List
|
|
425
|
+
typeOption:
|
|
426
|
+
@Summ: !Intに対応するtype option。
|
|
427
|
+
@Desc: Noneの時はstring_formatとして処理する。
|
|
428
|
+
@Type: Dict
|
|
429
|
+
@Returns:
|
|
430
|
+
@Summ: 有効なtype option。
|
|
431
|
+
@Type: Dict
|
|
432
|
+
"""
|
|
433
|
+
intMin=None
|
|
434
|
+
intMax=None
|
|
435
|
+
if(typeOption is None):
|
|
436
|
+
pass
|
|
437
|
+
elif(type(typeOption)!=dict):
|
|
438
|
+
raise ConfigYamlError(configPath, "Required `!Map` type.")
|
|
439
|
+
else:
|
|
440
|
+
for key,value in typeOption.items():
|
|
441
|
+
newConfPath=confPath+[key]
|
|
442
|
+
match key:
|
|
443
|
+
case "min":
|
|
444
|
+
intMin=value
|
|
445
|
+
if(type(value)==int):
|
|
446
|
+
if(intMax is not None):
|
|
447
|
+
if(intMax<value):
|
|
448
|
+
raise ConfigYamlError(newConfPath)
|
|
449
|
+
else:
|
|
450
|
+
raise ConfigYamlError(newConfPath)
|
|
451
|
+
case "max":
|
|
452
|
+
intMax=value
|
|
453
|
+
if(type(value)==int):
|
|
454
|
+
if(intMax is not None):
|
|
455
|
+
if(value<intMin):
|
|
456
|
+
raise ConfigYamlError(newConfPath)
|
|
457
|
+
else:
|
|
458
|
+
raise ConfigYamlError(newConfPath)
|
|
459
|
+
case _:
|
|
460
|
+
raise ConfigYamlError(newConfPath)
|
|
461
|
+
return {"!Int":{"min":intMin,"max":intMax}}
|
|
462
|
+
|
|
463
|
+
def checkAnoyInt(self,anoyValue,min=None,max=None):
|
|
464
|
+
"""
|
|
465
|
+
@Summ: ANOY上で!Int型を型確認する関数。
|
|
464
466
|
|
|
465
467
|
@Args:
|
|
466
468
|
anoyValue:
|
|
@@ -481,9 +483,47 @@ class DictTraversal():
|
|
|
481
483
|
else:
|
|
482
484
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Int")
|
|
483
485
|
|
|
484
|
-
|
|
486
|
+
@classmethod
|
|
487
|
+
def checkConfFloat(cls,annoKey,typeOption):
|
|
488
|
+
"""
|
|
489
|
+
@Summ: config yaml上で!Float型のtype optionを確認する関数。
|
|
490
|
+
|
|
491
|
+
@Args:
|
|
492
|
+
annoKey:
|
|
493
|
+
@Summ: `!Child!Float`を格納するannotation key。
|
|
494
|
+
@Type: Str
|
|
495
|
+
typeOption:
|
|
496
|
+
@Summ: !Floatに対応するtype option。
|
|
497
|
+
@Desc: Noneの時はstring_formatとして処理する。
|
|
498
|
+
@Type: Dict
|
|
499
|
+
@Returns:
|
|
500
|
+
@Summ: 有効なtype option。
|
|
501
|
+
@Type: Dict
|
|
485
502
|
"""
|
|
486
|
-
|
|
503
|
+
floatMin=None
|
|
504
|
+
floatMax=None
|
|
505
|
+
if(typeOption is None):
|
|
506
|
+
pass
|
|
507
|
+
elif(type(typeOption)!=dict):
|
|
508
|
+
raise ConfigYamlError([annoKey,"!Child","!Float"], "Required `!Map` type.")
|
|
509
|
+
else:
|
|
510
|
+
for floatKey,floatVal in typeOption.items():
|
|
511
|
+
match floatKey:
|
|
512
|
+
case "min":
|
|
513
|
+
if(type(floatVal)!=int and type(floatVal)!=float):
|
|
514
|
+
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
515
|
+
floatMin=floatVal
|
|
516
|
+
case "max":
|
|
517
|
+
if(type(floatVal)!=int and type(floatVal)!=float):
|
|
518
|
+
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
519
|
+
floatMax=floatVal
|
|
520
|
+
case _:
|
|
521
|
+
raise ConfigYamlError([annoKey,"!Child","!Float"])
|
|
522
|
+
return {"!Float":{"min":floatMin,"max":floatMax}}
|
|
523
|
+
|
|
524
|
+
def checkAnoyFloat(self,anoyValue,min=None,max=None):
|
|
525
|
+
"""
|
|
526
|
+
@Summ: ANOY上で!Float型を型確認する関数。
|
|
487
527
|
|
|
488
528
|
@Args:
|
|
489
529
|
anoyValue:
|
|
@@ -510,9 +550,9 @@ class DictTraversal():
|
|
|
510
550
|
else:
|
|
511
551
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Float")
|
|
512
552
|
|
|
513
|
-
def
|
|
553
|
+
def checkAnoyFreeMap(self,anoyValue):
|
|
514
554
|
"""
|
|
515
|
-
@Summ:
|
|
555
|
+
@Summ: ANOY上で!FreeMap型を型確認する関数。
|
|
516
556
|
|
|
517
557
|
@Args:
|
|
518
558
|
anoyValue:
|
|
@@ -529,9 +569,37 @@ class DictTraversal():
|
|
|
529
569
|
else:
|
|
530
570
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!FreeMap")
|
|
531
571
|
|
|
532
|
-
|
|
572
|
+
@classmethod
|
|
573
|
+
def checkConfAnnoMap(cls,annoKey,typeOption):
|
|
533
574
|
"""
|
|
534
|
-
@Summ:
|
|
575
|
+
@Summ: config yaml上で!AnnoMap型のtype optionを確認する関数。
|
|
576
|
+
|
|
577
|
+
@Args:
|
|
578
|
+
annoKey:
|
|
579
|
+
@Summ: `!Child!AnnoMap`を格納するannotation key。
|
|
580
|
+
@Type: Str
|
|
581
|
+
typeOption:
|
|
582
|
+
@Summ: !AnnoMapに対応するtype option。
|
|
583
|
+
@Desc: Noneの時はstring_formatとして処理する。
|
|
584
|
+
@Type: List
|
|
585
|
+
@Returns:
|
|
586
|
+
@Summ: 有効なtype option。
|
|
587
|
+
@Type: Dict
|
|
588
|
+
"""
|
|
589
|
+
if(typeOption is None):
|
|
590
|
+
typeOption=[]
|
|
591
|
+
elif(type(typeOption)!=list):
|
|
592
|
+
raise ConfigYamlError([annoKey,"!Child","!AnnoMap"])
|
|
593
|
+
else:
|
|
594
|
+
for i in range(len(typeOption)):
|
|
595
|
+
item=typeOption[i]
|
|
596
|
+
if(item[0]!="@"):
|
|
597
|
+
raise ConfigYamlError([annoKey,"!Child","!AnnoMap",item])
|
|
598
|
+
return {"!AnnoMap":typeOption}
|
|
599
|
+
|
|
600
|
+
def checkAnoyAnnoMap(self,parentKey,anoyValue,annoKeyList:list=[]):
|
|
601
|
+
"""
|
|
602
|
+
@Summ: ANOY上で!FreeMap型を型確認する関数。
|
|
535
603
|
|
|
536
604
|
@Desc:
|
|
537
605
|
- <annoKeyList>は最低限必要なannotation keyのlistが入る。
|
|
@@ -570,9 +638,50 @@ class DictTraversal():
|
|
|
570
638
|
else:
|
|
571
639
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!AnnoMap")
|
|
572
640
|
|
|
573
|
-
|
|
641
|
+
@classmethod
|
|
642
|
+
def checkConfList(cls,annoKey,typeOption):
|
|
643
|
+
"""
|
|
644
|
+
@Summ: config yaml上で!List型のtype optionを確認する関数。
|
|
645
|
+
|
|
646
|
+
@Args:
|
|
647
|
+
annoKey:
|
|
648
|
+
@Summ: `!Child!List`を格納するannotation key。
|
|
649
|
+
@Type: Str
|
|
650
|
+
typeOption:
|
|
651
|
+
@Summ: !Listに対応するtype option。
|
|
652
|
+
@Desc: Noneの時はstring_formatとして処理する。
|
|
653
|
+
@Type: Dict
|
|
654
|
+
@Returns:
|
|
655
|
+
@Summ: 有効なtype option。
|
|
656
|
+
@Type: Dict
|
|
574
657
|
"""
|
|
575
|
-
|
|
658
|
+
listType=None
|
|
659
|
+
listLength=None
|
|
660
|
+
if(typeOption is None):
|
|
661
|
+
pass
|
|
662
|
+
elif(type(typeOption)!=dict):
|
|
663
|
+
raise ConfigYamlError([annoKey,"!Child","!List"])
|
|
664
|
+
else:
|
|
665
|
+
for listKey,listVal in typeOption.items():
|
|
666
|
+
match listKey:
|
|
667
|
+
case "type":
|
|
668
|
+
listType=listVal
|
|
669
|
+
case "length":
|
|
670
|
+
if(listVal is None):
|
|
671
|
+
continue
|
|
672
|
+
elif(type(listVal)!=int):
|
|
673
|
+
raise ConfigYamlError([annoKey,"!Child","!List",listKey])
|
|
674
|
+
elif(listVal<=0):
|
|
675
|
+
raise ConfigYamlError([annoKey,"!Child","!List",listKey])
|
|
676
|
+
listLength=listVal
|
|
677
|
+
case _:
|
|
678
|
+
raise ConfigYamlError([annoKey,"!Child","!List",listKey])
|
|
679
|
+
return {"!List":{"type":listType,"length":listLength}}
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
def checkAnoyList(self,parentKey,anoyValue,elementType:str=None,length:int=None):
|
|
683
|
+
"""
|
|
684
|
+
@Summ: ANOY上で!List型を型確認する関数。
|
|
576
685
|
|
|
577
686
|
@Desc:
|
|
578
687
|
- <typeOption>は最低限必要なannotation keyのlistが入る。
|
|
@@ -621,10 +730,42 @@ class DictTraversal():
|
|
|
621
730
|
self._pathQueue.append(newPath)
|
|
622
731
|
else:
|
|
623
732
|
raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!List")
|
|
624
|
-
|
|
625
|
-
|
|
733
|
+
|
|
734
|
+
@classmethod
|
|
735
|
+
def checkConfEnum(cls,annoKey,typeOption):
|
|
736
|
+
"""
|
|
737
|
+
@Summ: config yaml上で!Enum型のtype optionを確認する関数。
|
|
738
|
+
|
|
739
|
+
@Args:
|
|
740
|
+
annoKey:
|
|
741
|
+
@Summ: `!Child!Enum`を格納するannotation key。
|
|
742
|
+
@Type: Str
|
|
743
|
+
typeOption:
|
|
744
|
+
@Summ: !Enumに対応するtype option。
|
|
745
|
+
@Type: List
|
|
746
|
+
@Returns:
|
|
747
|
+
@Summ: 有効なtype option。
|
|
748
|
+
@Type: Dict
|
|
749
|
+
"""
|
|
750
|
+
enumOption=[]
|
|
751
|
+
if(type(typeOption)!=list):
|
|
752
|
+
raise ConfigYamlError([annoKey,"!Child","!Enum"])
|
|
753
|
+
else:
|
|
754
|
+
for item in typeOption:
|
|
755
|
+
if(type(item)==list):
|
|
756
|
+
raise ConfigYamlError([annoKey,"!Child","!Enum",item])
|
|
757
|
+
elif(type(item)==dict):
|
|
758
|
+
keyList=list(item.keys())
|
|
759
|
+
if(len(keyList)!=1):
|
|
760
|
+
raise ConfigYamlError([annoKey,"!Child","!Enum",item])
|
|
761
|
+
enumOption.append(keyList[0])
|
|
762
|
+
else:
|
|
763
|
+
enumOption.append(item)
|
|
764
|
+
return {"!Enum":enumOption}
|
|
765
|
+
|
|
766
|
+
def checkAnoyEnum(self,anoyValue,optionList:list):
|
|
626
767
|
"""
|
|
627
|
-
@Summ:
|
|
768
|
+
@Summ: ANOY上で!Enum型を型確認する関数。
|
|
628
769
|
|
|
629
770
|
@Desc:
|
|
630
771
|
- 他の言語のUnion型の役割も兼ねている。
|
anoy-0.3.1.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
cli.py,sha256=C1fgYhoZ1vvcBgfsZF1CCtcJSNlT4YVS_qZZ5QVkdc0,912
|
|
2
|
-
anoy-0.3.1.dist-info/licenses/LICENSE.txt,sha256=nsHvySI1U7YZgAX4K3rJsWli_GfXy2syPI-MtGPwjlo,1062
|
|
3
|
-
modules/__init__.py,sha256=WSvUse7H-6ConliG5plmNLGHjeHWXqHR9t901plrWM0,133
|
|
4
|
-
modules/dictTraversal.py,sha256=5xMEe1jfhA4ZnjABfUPkWk2u3OuW3Toaq50Tsed4m74,28228
|
|
5
|
-
modules/errors.py,sha256=P9KwBhPdPGdujCMA00Ep37RvPLwGYsNip4RidT7oMdg,2091
|
|
6
|
-
anoy-0.3.1.dist-info/METADATA,sha256=hliKmzPvY0WX86yif_GGF3nrkCA1lVY7sxA1jaWbwzs,3873
|
|
7
|
-
anoy-0.3.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
8
|
-
anoy-0.3.1.dist-info/entry_points.txt,sha256=_lpL6R97giGseZcV0r5QwdX4zRwoZLzRHUxyBZl_iYI,34
|
|
9
|
-
anoy-0.3.1.dist-info/top_level.txt,sha256=jfF8JYDvxB66wJSH2sWhdDiR0GGzxt5x-1k2vxwZKqA,12
|
|
10
|
-
anoy-0.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|