import importlib.util
import os
import sys

from .base_mob import BaseMob

pydantic = None
name = 'pydantic'
if name in sys.modules:
    pydantic = sys.modules[name]
elif (spec := importlib.util.find_spec(name)) is not None:
    pydantic = importlib.util.module_from_spec(spec)
    sys.modules[name] = pydantic
    spec.loader.exec_module(pydantic)

if pydantic and os.environ.get('ELIRON_BUILDER') == 'pydantic':
    from .pydantic_builder import load_character, save_character
else:
    from .default_builder import load_character, save_character
