anoy 0.3.0__tar.gz → 0.3.1__tar.gz

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.0
3
+ Version: 0.3.1
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
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "anoy"
8
- version = "0.3.0"
8
+ version = "0.3.1"
9
9
  authors = [
10
10
  { name="masaniki", email="masaniki.software@gmail.com" }
11
11
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anoy
3
- Version: 0.3.0
3
+ Version: 0.3.1
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
@@ -5,7 +5,7 @@ import yaml
5
5
 
6
6
  from modules import DictTraversal
7
7
 
8
- VERSION="v0.3.0"
8
+ VERSION="v0.3.1"
9
9
 
10
10
  def main():
11
11
  """
@@ -67,12 +67,16 @@ class DictTraversal():
67
67
  newConfigDict={} # 整形されたconfigDict
68
68
  for annoKey in configDict.keys():
69
69
  newAnnoValue={} #annotation keyに対応する値。
70
- if(annoKey[0]!="@"):
70
+ if(type(annoKey)!=str):
71
+ raise ConfigYamlError([annoKey],"Annotaion key should start with `@`.")
72
+ elif(annoKey[0]!="@"):
71
73
  raise ConfigYamlError([annoKey],"Annotaion key should start with `@`.")
72
74
  valueDict=configDict[annoKey]
73
75
  if(type(valueDict)!=dict):
74
76
  raise ConfigYamlError([annoKey])
75
77
  for key,value in valueDict.items():
78
+ if(type(key)!=str):
79
+ raise ConfigYamlError([annoKey,key], "Invalid value as !Parent.")
76
80
  if(key[0]=="@"):
77
81
  continue
78
82
  elif(key=="!Parent"):
@@ -82,7 +86,7 @@ class DictTraversal():
82
86
  validConfChild=self.checkChild(annoKey,value)
83
87
  newAnnoValue["!Child"]=validConfChild
84
88
  else:
85
- raise ConfigYamlError([annoKey], "Unknown config key is found.")
89
+ raise ConfigYamlError([annoKey,key], "Invalid value as !Parent.")
86
90
  # isVisit keyの追加。
87
91
  newAnnoValue["isVisit"]=False
88
92
  newConfigDict[annoKey]=newAnnoValue
@@ -246,7 +250,9 @@ class DictTraversal():
246
250
  raise ConfigYamlError([annoKey,"!Child","!AnnoMap"])
247
251
  for i in range(len(typeOption)):
248
252
  item=typeOption[i]
249
- if(item[0]!="@"):
253
+ if(type(item)!=str):
254
+ raise ConfigYamlError([annoKey,"!Child","!AnnoMap",item])
255
+ elif(item[0]!="@"):
250
256
  raise ConfigYamlError([annoKey,"!Child","!AnnoMap",item])
251
257
  return {"!AnnoMap":typeOption}
252
258
  case _:
@@ -355,18 +361,24 @@ class DictTraversal():
355
361
  self._pathQueue.append(newPath)
356
362
  elif(type(childValue)==dict):
357
363
  # !Child=nullであってもfree keyとannotation keyの混合は許さない。
364
+ # keyがstr型でない時は!FreeMapとして扱う。
358
365
  isAnnoMap=None
359
366
  for key,value in childValue.items():
360
- if(isAnnoMap is None):
361
- if(key[0]=="@"):
362
- isAnnoMap=True
363
- else:
367
+ if(type(key)!=str):
368
+ if(isAnnoMap is None):
364
369
  isAnnoMap=False
365
- else:
366
- if(isAnnoMap==True and key[0]!="@"):
370
+ elif(isAnnoMap==True):
367
371
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!AnnoMap")
368
- elif(isAnnoMap==False and key[0]=="@"):
372
+ elif(key[0]=="@"):
373
+ if(isAnnoMap is None):
374
+ isAnnoMap=True
375
+ elif(isAnnoMap==False):
369
376
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!FreeMap")
377
+ else:
378
+ if(isAnnoMap is None):
379
+ isAnnoMap=False
380
+ elif(isAnnoMap==True):
381
+ raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!AnnoMap")
370
382
  newPath=self._anoyPath+[key]
371
383
  self._visitQueue.append((key,value))
372
384
  self._pathQueue.append(newPath)
@@ -511,8 +523,9 @@ class DictTraversal():
511
523
  newPath=self._anoyPath+[key]
512
524
  self._visitQueue.append((key,value))
513
525
  self._pathQueue.append(newPath)
514
- if(key[0]=="@"):
515
- raise AnnotationTypeError(self._curAnoy,newPath,"!FreeMap")
526
+ if(type(key)==str):
527
+ if(key[0]=="@"):
528
+ raise AnnotationTypeError(self._curAnoy,newPath,"!FreeMap")
516
529
  else:
517
530
  raise AnnotationTypeError(self._curAnoy,self._anoyPath,"!FreeMap")
518
531
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes