# Path: spanner_orm/error.py
# class SpannerError(Exception):
# class ValidationError(Exception):


from typing import Any, Dict, List, Type, Union
from spanner_orm import error
import dataclasses

  def add(self, reference: Type[Any]) -> None:
    self.references.append(reference)


class Registry(object):

  def __init__(self):
    self._registered = {}  # type: Dict[str, RegistryComponent]

  def _name_from_class(self, klass: Type[Any]) -> str:
    return '{}.{}'.format(klass.__module__, klass.__name__)

  def register(self, to_register: Type[Any]) -> None:
    name_components = reversed(self._name_from_class(to_register).split('.'))
    name = None
    for component in name_components:
      name = name = '{}.{}'.format(component, name) if name else component
      if name not in self._registered:
        self._registered[name] = RegistryComponent()
      self._registered[name].add(to_register)

  def get(self, name: Union[Type[Any], str]) -> Type[Any]:
    if isinstance(name, type):
      name = self._name_from_class(name)

    if name not in self._registered:
      raise error.SpannerError(
          '{} was not found, verify it has been imported'.format(name))
    if len(self._registered[name].references) > 1:

# Path: spanner_orm/error.py
# class SpannerError(Exception):
# class ValidationError(Exception):


# Path: spanner_orm/registry.py
from typing import Any, Dict, List, Type, Union
from spanner_orm import error
import dataclasses


  def add(self, reference: Type[Any]) -> None:
    self.references.append(reference)


class Registry(object):

  def __init__(self):
    self._registered = {}  # type: Dict[str, RegistryComponent]

  def _name_from_class(self, klass: Type[Any]) -> str:
    return '{}.{}'.format(klass.__module__, klass.__name__)

  def register(self, to_register: Type[Any]) -> None:
    name_components = reversed(self._name_from_class(to_register).split('.'))
    name = None
    for component in name_components:
      name = name = '{}.{}'.format(component, name) if name else component
      if name not in self._registered:
        self._registered[name] = RegistryComponent()
      self._registered[name].add(to_register)

  def get(self, name: Union[Type[Any], str]) -> Type[Any]:
    if isinstance(name, type):
      name = self._name_from_class(name)

    if name not in self._registered:
      raise error.SpannerError(
          '{} was not found, verify it has been imported'.format(name))
    if len(self._registered[name].references) > 1:

      raise error.SpannerError(