22 lines
621 B
Python
22 lines
621 B
Python
#!/usr/bin/env python3
|
|
|
|
from Utils.Patterns import RE
|
|
from typing import Any, Optional, Self
|
|
|
|
class Check:
|
|
|
|
@staticmethod
|
|
def is_string(item:Optional[Any]) -> bool:
|
|
return isinstance(item, str) and not isinstance(item, bytes)
|
|
|
|
@classmethod
|
|
def is_key(cls:type[Self], item:Optional[Any]) -> bool:
|
|
return cls.is_string(item) and RE.KEY.match(item) is not None
|
|
|
|
@staticmethod
|
|
def is_dictionary(item:Optional[Any]) -> bool:
|
|
return isinstance(item, dict)
|
|
|
|
@staticmethod
|
|
def is_array(item:Optional[Any]) -> bool:
|
|
return isinstance(item, (list, tuple)) |