anoy 0.3.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anoy
3
- Version: 0.3.2
3
+ Version: 0.3.3
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=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
@@ -5,7 +5,7 @@ import yaml
5
5
 
6
6
  from modules import DictTraversal
7
7
 
8
- VERSION="v0.3.2"
8
+ VERSION="v0.3.3"
9
9
 
10
10
  def main():
11
11
  """
modules/dictTraversal.py CHANGED
@@ -134,57 +134,48 @@ class DictTraversal():
134
134
  @Type: Dict
135
135
  """
136
136
  if(type(value)==str):
137
+ newConfPath=confPath+[value]
137
138
  match value:
138
139
  case "!Str":
139
- newConfPath=confPath+["!Str"]
140
140
  validType=cls.checkConfStr(newConfPath,None)
141
141
  case "!Bool":
142
142
  validType={"!Bool":{}}
143
143
  case "!Int":
144
- newConfPath=confPath+["!Int"]
145
144
  validType=cls.checkConfInt(newConfPath,None)
146
145
  case "!Float":
147
- newConfPath=confPath+["!Float"]
148
146
  validType=cls.checkConfFloat(newConfPath,None)
149
147
  case "!List":
150
- newConfPath=confPath+["!List"]
151
148
  validType=cls.checkConfList(newConfPath,None)
152
149
  case "!FreeMap":
153
150
  validType={"!FreeMap":{}}
154
151
  case "!AnnoMap":
155
- newConfPath=confPath+["!AnnoMap"]
156
152
  validType=cls.checkConfAnnoMap(newConfPath,None)
157
153
  case _:
158
- raise ConfigYamlError(confPath,"Invalid data type.")
154
+ raise ConfigYamlError(newConfPath,"Invalid data type.")
159
155
  elif(type(value)==dict):
160
156
  confChildKey=list(value.keys())
161
157
  if(len(confChildKey)!=1):
162
158
  raise ConfigYamlError(confPath,"Invalid data type.")
163
159
  typeStr=confChildKey[0]
160
+ newConfPath=confPath+[typeStr]
164
161
  typeOption=value[typeStr]
165
162
  match typeStr:
166
163
  case "!Str":
167
- newConfPath=confPath+["!Str"]
168
164
  validType=cls.checkConfStr(newConfPath,typeOption)
169
165
  case "!Int":
170
- newConfPath=confPath+["!Int"]
171
166
  validType=cls.checkConfInt(newConfPath,typeOption)
172
167
  case "!Float":
173
- newConfPath=confPath+["!Float"]
174
168
  validType=cls.checkConfFloat(newConfPath,typeOption)
175
169
  case "!Enum":
176
- newConfPath=confPath+["!Enum"]
177
170
  validType=cls.checkConfEnum(newConfPath,typeOption)
178
171
  case "!List":
179
- newConfPath=confPath+["!List"]
180
172
  validType=cls.checkConfList(newConfPath,typeOption)
181
173
  case "!AnnoMap":
182
- newConfPath=confPath+["!AnnoMap"]
183
174
  validType=cls.checkConfAnnoMap(newConfPath,typeOption)
184
175
  case _:
185
- raise ConfigYamlError(confPath, "Invalid data type.")
176
+ raise ConfigYamlError(newConfPath,"Invalid data type.")
186
177
  else:
187
- raise ConfigYamlError(confPath, "Invalid data type.")
178
+ raise ConfigYamlError(confPath,"Invalid data type.")
188
179
  return validType
189
180
 
190
181
 
@@ -379,7 +370,7 @@ class DictTraversal():
379
370
  raise ConfigYamlError(newConfPath)
380
371
  return {"!Str":{"min":lenMin,"max":lenMax}}
381
372
 
382
- def checkAnoyStr(self,anoyValue,length=None,min=None,max=None):
373
+ def checkAnoyStr(self,anoyValue,min=None,max=None):
383
374
  """
384
375
  @Summ: ANOY上で!Str型を型確認する関数。
385
376
 
@@ -390,9 +381,6 @@ class DictTraversal():
390
381
  @Args:
391
382
  anoyValue:
392
383
  @Summ: 型確認する値。
393
- length:
394
- @Summ: 文字列の長さ。
395
- @Desc: min,maxとの両立は不可能。
396
384
  min:
397
385
  @Summ: 文字列の長さの最小値。
398
386
  @Desc:
@@ -405,19 +393,12 @@ class DictTraversal():
405
393
  - max+1からerror.
406
394
  """
407
395
  if(type(anoyValue)==str):
408
- if(length is not None):
409
- if(len(anoyValue)==length):
410
- return
411
- else:
412
- raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Str",)
413
- else:
414
- if(min is not None):
415
- if(len(anoyValue)<min):
416
- raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Str")
417
- if(max is not None):
418
- if(max<len(anoyValue)):
419
- raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Str")
420
- 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")
421
402
  else:
422
403
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Str")
423
404
 
@@ -433,14 +414,14 @@ class DictTraversal():
433
414
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!Bool")
434
415
 
435
416
  @classmethod
436
- def checkConfInt(cls,annoKey,typeOption):
417
+ def checkConfInt(cls,confPath,typeOption):
437
418
  """
438
419
  @Summ: config yaml上で!Int型のtype optionを確認する関数。
439
420
 
440
421
  @Args:
441
- annoKey:
442
- @Summ: `!Child!Str`を格納するannotation key。
443
- @Type: Str
422
+ confPath:
423
+ @Summ: config yaml上の位置。
424
+ @Type: List
444
425
  typeOption:
445
426
  @Summ: !Intに対応するtype option。
446
427
  @Desc: Noneの時はstring_formatとして処理する。
@@ -454,16 +435,29 @@ class DictTraversal():
454
435
  if(typeOption is None):
455
436
  pass
456
437
  elif(type(typeOption)!=dict):
457
- raise ConfigYamlError([annoKey,"!Child","!Str"], "Required `!Map` type.")
438
+ raise ConfigYamlError(configPath, "Required `!Map` type.")
458
439
  else:
459
- for intKey,intVal in typeOption.items():
460
- match intKey:
440
+ for key,value in typeOption.items():
441
+ newConfPath=confPath+[key]
442
+ match key:
461
443
  case "min":
462
- intMin=intVal
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)
463
451
  case "max":
464
- intMax=intVal
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)
465
459
  case _:
466
- raise ConfigYamlError([annoKey,"!Child","!Int"])
460
+ raise ConfigYamlError(newConfPath)
467
461
  return {"!Int":{"min":intMin,"max":intMax}}
468
462
 
469
463
  def checkAnoyInt(self,anoyValue,min=None,max=None):
@@ -1,10 +0,0 @@
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,,
File without changes