# Path: graphscale/check.py
# def isinst(obj: Any, ttype: Type, _msg: str=None) -> None:
# def invariant(condition: Any, msg: str) -> None:
# def failed(msg: str) -> NoReturn:
# 
# Path: graphscale/utils.py
# def is_camel_case(string: str) -> bool:
#     """Is the string potentially camel case? Only checks for capital letters currently"""
#     return bool(re.search('[A-Z]', string))
# 
# def to_snake_case(camel_case: str) -> str:
#     """Convert a camel case string to snake case. e.g. fooBar ==> foo_bar"""
#     with_underscores = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', camel_case)
#     return re.sub('([a-z0-9])([A-Z])', r'\1_\2', with_underscores).lower()


from datetime import datetime
from enum import Enum, auto
from typing import NamedTuple, List, Any, Union
from uuid import UUID
from graphql.language.ast import (
    EnumTypeDefinition, InputObjectTypeDefinition, ListType, NamedType, NonNullType,
    ObjectTypeDefinition, IntValue, StringValue, BooleanValue, Node, TypeDefinition, Value,
    InputValueDefinition, Directive, FieldDefinition, Type
)
from graphql.language.parser import parse
from graphql.language.source import Source
from graphscale import check
from graphscale.utils import is_camel_case, to_snake_case

    def enum_types(self) -> List[GrappleTypeDef]:
        return [t for t in self._types if t.type_varietal == TypeVarietal.ENUM]

    def is_enum(self, name: str) -> bool:
        ttype = self.type_named(name)
        return ttype and ttype.type_varietal == TypeVarietal.ENUM

    def type_named(self, name: str) -> GrappleTypeDef:
        for ttype in self._types:
            if ttype.name == name:
                return ttype
        return None


def parse_grapple(grapple_string: str) -> GrappleDocument:
    ast = parse(Source(grapple_string))
    grapple_types = []
    for type_node in ast.definitions:
        grapple_types.append(create_grapple_type_definition(type_node))
    return GrappleDocument(types=grapple_types)


def has_directive(ast: Node, name: str) -> bool:
    return name in [dir_node.name.value for dir_node in ast.directives]


def get_directive(ast: Node, name: str) -> Directive:
    for dir_node in ast.directives:
        if dir_node.name.value == name:

# Path: graphscale/check.py
# def isinst(obj: Any, ttype: Type, _msg: str=None) -> None:
# def invariant(condition: Any, msg: str) -> None:
# def failed(msg: str) -> NoReturn:
# 
# Path: graphscale/utils.py
# def is_camel_case(string: str) -> bool:
#     """Is the string potentially camel case? Only checks for capital letters currently"""
#     return bool(re.search('[A-Z]', string))
# 
# def to_snake_case(camel_case: str) -> str:
#     """Convert a camel case string to snake case. e.g. fooBar ==> foo_bar"""
#     with_underscores = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', camel_case)
#     return re.sub('([a-z0-9])([A-Z])', r'\1_\2', with_underscores).lower()


# Path: graphscale/grapple/parser.py
from datetime import datetime
from enum import Enum, auto
from typing import NamedTuple, List, Any, Union
from uuid import UUID
from graphql.language.ast import (
    EnumTypeDefinition, InputObjectTypeDefinition, ListType, NamedType, NonNullType,
    ObjectTypeDefinition, IntValue, StringValue, BooleanValue, Node, TypeDefinition, Value,
    InputValueDefinition, Directive, FieldDefinition, Type
)
from graphql.language.parser import parse
from graphql.language.source import Source
from graphscale import check
from graphscale.utils import is_camel_case, to_snake_case


    def enum_types(self) -> List[GrappleTypeDef]:
        return [t for t in self._types if t.type_varietal == TypeVarietal.ENUM]

    def is_enum(self, name: str) -> bool:
        ttype = self.type_named(name)
        return ttype and ttype.type_varietal == TypeVarietal.ENUM

    def type_named(self, name: str) -> GrappleTypeDef:
        for ttype in self._types:
            if ttype.name == name:
                return ttype
        return None


def parse_grapple(grapple_string: str) -> GrappleDocument:
    ast = parse(Source(grapple_string))
    grapple_types = []
    for type_node in ast.definitions:
        grapple_types.append(create_grapple_type_definition(type_node))
    return GrappleDocument(types=grapple_types)


def has_directive(ast: Node, name: str) -> bool:
    return name in [dir_node.name.value for dir_node in ast.directives]


def get_directive(ast: Node, name: str) -> Directive:
    for dir_node in ast.directives:
        if dir_node.name.value == name:

            check.isinst(dir_node, Directive)