# Path: schema_salad/exceptions.py
# class SchemaException(SchemaSaladException):
#     """Indicates error with the provided schema definition."""
# 
# Path: schema_salad/utils.py
# def add_dictlist(di, key, val):  # type: (Dict[Any, Any], Any, Any) -> None
# def aslist(thing):  # type: (Any) -> MutableSequence[Any]
# def flatten(thing, ltypes=(list, tuple)):
# def onWindows():
# def convert_to_dict(j4):  # type: (Any) -> Any
# def json_dump(
#     obj,  # type: Any
#     fp,  # type: IO[str]
#     **kwargs  # type: Any
# ):  # type: (...) -> None
# def json_dumps(
#     obj,  # type: Any
#     **kwargs  # type: Any
# ):  # type: (...) -> str
# def stdout() -> BufferedWriter:
#     def construct_yaml_timestamp(self: Any, node: Any, values: Any = None) -> Any:
# def yaml_no_ts() -> YAML:
# class _RoundTripNoTimeStampConstructor(RoundTripConstructor):


import logging
import unicodedata
import rdflib
import rdflib.namespace
from typing import (
    Any,
    Dict,
    Iterable,
    List,
    MutableMapping,
    MutableSequence,
    Optional,
    Tuple,
    Union,
    cast,
)
from urllib.parse import urldefrag, urlsplit
from rdflib import Graph, URIRef
from rdflib.namespace import RDF, RDFS
from ruamel.yaml.comments import CommentedMap, CommentedSeq
from .exceptions import SchemaException
from .utils import ContextType, aslist, json_dumps
def process_type(
    t: MutableMapping[str, Any],
    g: Graph,
    context: ContextType,
    defaultBase: str,
    namespaces: Dict[str, rdflib.namespace.Namespace],
    defaultPrefix: str,
) -> None:
    if t["type"] not in ("record", "enum"):
        return

    if "name" in t:
        recordname = t["name"]

        _logger.debug("Processing %s %s\n", t.get("type"), t)

        classnode = URIRef(recordname)
        g.add((classnode, RDF.type, RDFS.Class))

        split = urlsplit(recordname)
        predicate = recordname
        if t.get("inVocab", True):
            if split.scheme:
                (ns, ln) = rdflib.namespace.split_uri(str(recordname))
                predicate = recordname
                recordname = ln
            else:
                predicate = f"{defaultPrefix}:{recordname}"

        if context.get(recordname, predicate) != predicate:

# Path: schema_salad/exceptions.py
# class SchemaException(SchemaSaladException):
#     """Indicates error with the provided schema definition."""
# 
# Path: schema_salad/utils.py
# def add_dictlist(di, key, val):  # type: (Dict[Any, Any], Any, Any) -> None
# def aslist(thing):  # type: (Any) -> MutableSequence[Any]
# def flatten(thing, ltypes=(list, tuple)):
# def onWindows():
# def convert_to_dict(j4):  # type: (Any) -> Any
# def json_dump(
#     obj,  # type: Any
#     fp,  # type: IO[str]
#     **kwargs  # type: Any
# ):  # type: (...) -> None
# def json_dumps(
#     obj,  # type: Any
#     **kwargs  # type: Any
# ):  # type: (...) -> str
# def stdout() -> BufferedWriter:
#     def construct_yaml_timestamp(self: Any, node: Any, values: Any = None) -> Any:
# def yaml_no_ts() -> YAML:
# class _RoundTripNoTimeStampConstructor(RoundTripConstructor):


# Path: schema_salad/jsonld_context.py
import logging
import unicodedata
import rdflib
import rdflib.namespace
from typing import (
    Any,
    Dict,
    Iterable,
    List,
    MutableMapping,
    MutableSequence,
    Optional,
    Tuple,
    Union,
    cast,
)
from urllib.parse import urldefrag, urlsplit
from rdflib import Graph, URIRef
from rdflib.namespace import RDF, RDFS
from ruamel.yaml.comments import CommentedMap, CommentedSeq
from .exceptions import SchemaException
from .utils import ContextType, aslist, json_dumps

def process_type(
    t: MutableMapping[str, Any],
    g: Graph,
    context: ContextType,
    defaultBase: str,
    namespaces: Dict[str, rdflib.namespace.Namespace],
    defaultPrefix: str,
) -> None:
    if t["type"] not in ("record", "enum"):
        return

    if "name" in t:
        recordname = t["name"]

        _logger.debug("Processing %s %s\n", t.get("type"), t)

        classnode = URIRef(recordname)
        g.add((classnode, RDF.type, RDFS.Class))

        split = urlsplit(recordname)
        predicate = recordname
        if t.get("inVocab", True):
            if split.scheme:
                (ns, ln) = rdflib.namespace.split_uri(str(recordname))
                predicate = recordname
                recordname = ln
            else:
                predicate = f"{defaultPrefix}:{recordname}"

        if context.get(recordname, predicate) != predicate:

            raise SchemaException(