anoy 0.3.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anoy
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: This is a library that provides simple type checking for YAML.
5
5
  Author-email: masaniki <masaniki.software@gmail.com>
6
6
  License-Expression: MIT
@@ -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
@@ -5,7 +5,7 @@ import yaml
5
5
 
6
6
  from modules import DictTraversal
7
7
 
8
- VERSION="v0.3.1"
8
+ VERSION="v0.3.2"
9
9
 
10
10
  def main():
11
11
  """
modules/dictTraversal.py CHANGED
@@ -64,12 +64,10 @@ class DictTraversal():
64
64
  @Summ: 型確認して、余計なものを取り除いたconfigDict。
65
65
  @Type: dict
66
66
  """
67
- newConfigDict={} # 整形されたconfigDict
67
+ validConfigDict={} # 整形されたconfigDict
68
68
  for annoKey in configDict.keys():
69
- newAnnoValue={} #annotation keyに対応する値。
70
- if(type(annoKey)!=str):
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,114 @@ class DictTraversal():
80
78
  if(key[0]=="@"):
81
79
  continue
82
80
  elif(key=="!Parent"):
83
- validConfParent=self.checkParent(annoKey,value)
84
- newAnnoValue["!Parent"]=validConfParent
81
+ validConfParent=self.checkParent([annoKey,"!Parent"],value)
82
+ validAnnoValue["!Parent"]=validConfParent
85
83
  elif(key=="!Child"):
86
- validConfChild=self.checkChild(annoKey,value)
87
- newAnnoValue["!Child"]=validConfChild
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
- newAnnoValue["isVisit"]=False
92
- newConfigDict[annoKey]=newAnnoValue
93
- return newConfigDict
89
+ validAnnoValue["isVisit"]=False
90
+ validConfigDict[annoKey]=validAnnoValue
91
+ return validConfigDict
94
92
 
95
93
  @classmethod
96
- def checkParent(cls,annoKey,confParent):
94
+ def checkParent(cls,confPath,value):
97
95
  """
98
96
  @Summ: `!Parent`に対応する値を型確認する関数。
99
97
 
100
98
  @Args:
101
- annoKey:
102
- @Summ: `!Parent`の親となるannotation key.
103
- @Type: Str
104
- confParent:
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(confParent)!=list):
112
- raise ConfigYamlError([annoKey,"!Parent"])
113
- for item in confParent:
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([annoKey,"!Parent"])
118
- return confParent.copy()
115
+ raise ConfigYamlError(confPath)
116
+ return value.copy()
119
117
 
120
118
  @classmethod
121
- def checkChild(cls,annoKey,confChild):
119
+ def checkDataType(cls,confPath,value):
122
120
  """
123
- @Summ: `!Child`に対応する値を型確認する関数。
121
+ @Summ: data型構文を確認する関数。
122
+
123
+ @Desc: `!Child`だけでなく、data型の入れ子が発生する際にも呼び出される。
124
124
 
125
125
  @Args:
126
- annoKey:
127
- @Summ: `!Child`の親となるannotation key.
128
- @Type: Str
129
- confChild:
130
- @Summ: `!Child`の子。
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(confChild)==str):
137
- match confChild:
136
+ if(type(value)==str):
137
+ match value:
138
138
  case "!Str":
139
- return {"!Str":{"length":None,"min":None,"max":None}}
139
+ newConfPath=confPath+["!Str"]
140
+ validType=cls.checkConfStr(newConfPath,None)
140
141
  case "!Bool":
141
- return {"!Bool":{}}
142
+ validType={"!Bool":{}}
142
143
  case "!Int":
143
- return {"!Int":{"min":None,"max":None}}
144
+ newConfPath=confPath+["!Int"]
145
+ validType=cls.checkConfInt(newConfPath,None)
144
146
  case "!Float":
145
- return {"!Float":{"min":None,"max":None}}
147
+ newConfPath=confPath+["!Float"]
148
+ validType=cls.checkConfFloat(newConfPath,None)
146
149
  case "!List":
147
- return {"!List":{"type":None,"length":None}}
150
+ newConfPath=confPath+["!List"]
151
+ validType=cls.checkConfList(newConfPath,None)
148
152
  case "!FreeMap":
149
- return {"!FreeMap":{}}
153
+ validType={"!FreeMap":{}}
150
154
  case "!AnnoMap":
151
- return {"!AnnoMap":[]}
155
+ newConfPath=confPath+["!AnnoMap"]
156
+ validType=cls.checkConfAnnoMap(newConfPath,None)
152
157
  case _:
153
- raise ConfigYamlError([annoKey,"!Child"])
154
- elif(type(confChild)==dict):
155
- confChildKey=list(confChild.keys())
158
+ raise ConfigYamlError(confPath,"Invalid data type.")
159
+ elif(type(value)==dict):
160
+ confChildKey=list(value.keys())
156
161
  if(len(confChildKey)!=1):
157
- raise ConfigYamlError([annoKey,"!Child"])
162
+ raise ConfigYamlError(confPath,"Invalid data type.")
158
163
  typeStr=confChildKey[0]
159
- typeOption=confChild[typeStr]
164
+ typeOption=value[typeStr]
160
165
  match typeStr:
161
166
  case "!Str":
162
- if(type(typeOption)!=dict):
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}}
167
+ newConfPath=confPath+["!Str"]
168
+ validType=cls.checkConfStr(newConfPath,typeOption)
187
169
  case "!Int":
188
- if(type(typeOption)!=dict):
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}}
170
+ newConfPath=confPath+["!Int"]
171
+ validType=cls.checkConfInt(newConfPath,typeOption)
201
172
  case "!Float":
202
- if(type(typeOption)!=dict):
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}}
173
+ newConfPath=confPath+["!Float"]
174
+ validType=cls.checkConfFloat(newConfPath,typeOption)
219
175
  case "!Enum":
220
- if(type(typeOption)!=list):
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}
176
+ newConfPath=confPath+["!Enum"]
177
+ validType=cls.checkConfEnum(newConfPath,typeOption)
234
178
  case "!List":
235
- if(type(typeOption)!=dict):
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}}
179
+ newConfPath=confPath+["!List"]
180
+ validType=cls.checkConfList(newConfPath,typeOption)
248
181
  case "!AnnoMap":
249
- if(type(typeOption)!=list):
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}
182
+ newConfPath=confPath+["!AnnoMap"]
183
+ validType=cls.checkConfAnnoMap(newConfPath,typeOption)
258
184
  case _:
259
- raise ConfigYamlError([annoKey,"!Child","!AnnoMap",item], "Unknown data type string.")
185
+ raise ConfigYamlError(confPath, "Invalid data type.")
260
186
  else:
261
- raise ConfigYamlError([annoKey,"!Child"])
187
+ raise ConfigYamlError(confPath, "Invalid data type.")
188
+ return validType
262
189
 
263
190
 
264
191
  def dirDFS(self,anoyPath:Path):
@@ -387,27 +314,74 @@ class DictTraversal():
387
314
  typeOption=confChild[typeStr]
388
315
  match typeStr:
389
316
  case "!Str":
390
- self.checkStr(childValue,**typeOption)
317
+ self.checkAnoyStr(childValue,**typeOption)
391
318
  case "!Bool":
392
- self.checkBool(childValue)
319
+ self.checkAnoyBool(childValue)
393
320
  case "!Int":
394
- self.checkInt(childValue,**typeOption)
321
+ self.checkAnoyInt(childValue,**typeOption)
395
322
  case "!Float":
396
- self.checkFloat(childValue,**typeOption)
323
+ self.checkAnoyFloat(childValue,**typeOption)
397
324
  case "!FreeMap":
398
- self.checkFreeMap(childValue)
325
+ self.checkAnoyFreeMap(childValue)
399
326
  case "!AnnoMap":
400
- self.checkAnnoMap(parentKey,childValue,typeOption)
327
+ self.checkAnoyAnnoMap(parentKey,childValue,typeOption)
401
328
  case "!List":
402
- self.checkList(parentKey,childValue,elementType=typeOption["type"],length=typeOption["length"])
329
+ self.checkAnoyList(parentKey,childValue,elementType=typeOption["type"],length=typeOption["length"])
403
330
  case "!Enum":
404
- self.checkEnum(childValue,typeOption)
331
+ self.checkAnoyEnum(childValue,typeOption)
405
332
  case _:
406
333
  raise ConfigYamlError([parentKey,"!Child"])
407
334
 
408
- def checkStr(self,anoyValue,length=None,min=None,max=None):
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):
409
383
  """
410
- @Summ: !Str型を型確認する関数。
384
+ @Summ: ANOY上で!Str型を型確認する関数。
411
385
 
412
386
  @Desc:
413
387
  - <length>と<min>、<length>と<max>の両立は不可能であるが、この関数ではその確認を行わない。
@@ -447,9 +421,9 @@ class DictTraversal():
447
421
  else:
448
422
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Str")
449
423
 
450
- def checkBool(self,anoyValue):
424
+ def checkAnoyBool(self,anoyValue):
451
425
  """
452
- @Summ: !Bool型を型確認する関数。
426
+ @Summ: ANOY上で!Bool型を型確認する関数。
453
427
 
454
428
  @Args:
455
429
  anoyValue:
@@ -458,9 +432,43 @@ class DictTraversal():
458
432
  if(type(anoyValue)!=bool):
459
433
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Bool")
460
434
 
461
- def checkInt(self,anoyValue,min=None,max=None):
435
+ @classmethod
436
+ def checkConfInt(cls,annoKey,typeOption):
437
+ """
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
462
451
  """
463
- @Summ: !Int型を型確認する関数。
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型を型確認する関数。
464
472
 
465
473
  @Args:
466
474
  anoyValue:
@@ -481,9 +489,47 @@ class DictTraversal():
481
489
  else:
482
490
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Int")
483
491
 
484
- def checkFloat(self,anoyValue,min=None,max=None):
492
+ @classmethod
493
+ def checkConfFloat(cls,annoKey,typeOption):
494
+ """
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):
485
531
  """
486
- @Summ: !Float型を型確認する関数。
532
+ @Summ: ANOY上で!Float型を型確認する関数。
487
533
 
488
534
  @Args:
489
535
  anoyValue:
@@ -510,9 +556,9 @@ class DictTraversal():
510
556
  else:
511
557
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Float")
512
558
 
513
- def checkFreeMap(self,anoyValue):
559
+ def checkAnoyFreeMap(self,anoyValue):
514
560
  """
515
- @Summ: !FreeMap型を型確認する関数。
561
+ @Summ: ANOY上で!FreeMap型を型確認する関数。
516
562
 
517
563
  @Args:
518
564
  anoyValue:
@@ -529,9 +575,37 @@ class DictTraversal():
529
575
  else:
530
576
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!FreeMap")
531
577
 
532
- def checkAnnoMap(self,parentKey,anoyValue,annoKeyList:list=[]):
578
+ @classmethod
579
+ def checkConfAnnoMap(cls,annoKey,typeOption):
533
580
  """
534
- @Summ: !FreeMap型を型確認する関数。
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型を型確認する関数。
535
609
 
536
610
  @Desc:
537
611
  - <annoKeyList>は最低限必要なannotation keyのlistが入る。
@@ -570,9 +644,50 @@ class DictTraversal():
570
644
  else:
571
645
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!AnnoMap")
572
646
 
573
- def checkList(self,parentKey,anoyValue,elementType:str=None,length:int=None):
647
+ @classmethod
648
+ def checkConfList(cls,annoKey,typeOption):
649
+ """
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):
574
689
  """
575
- @Summ: !List型を型確認する関数。
690
+ @Summ: ANOY上で!List型を型確認する関数。
576
691
 
577
692
  @Desc:
578
693
  - <typeOption>は最低限必要なannotation keyのlistが入る。
@@ -621,10 +736,42 @@ class DictTraversal():
621
736
  self._pathQueue.append(newPath)
622
737
  else:
623
738
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!List")
624
-
625
- def checkEnum(self,anoyValue,optionList:list):
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):
626
773
  """
627
- @Summ: !Enum型を型確認する関数。
774
+ @Summ: ANOY上で!Enum型を型確認する関数。
628
775
 
629
776
  @Desc:
630
777
  - 他の言語のUnion型の役割も兼ねている。
@@ -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