##
# Copyright (c) 2008-2010, 2012, 2013 Sprymix Inc.
# All rights reserved.
#
# See LICENSE for details.
##


import importlib
import sys
import yaml

from importkit import meta, context as lang_context, loader as lang_loader
from importkit.import_ import utils as import_utils
from importkit.yaml import loader, dumper, representer
from importkit.yaml import schema as yaml_schema
from importkit.utils.adapter import Adapter
from importkit.utils.ordered import OrderedSet

from . import types


class YAMLModuleCacheMetaInfo(lang_loader.LangModuleCacheMetaInfo):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.lazy_dependencies = []
        self.schemas = []

    def update_from_code(self, code):
        super().update_from_code(code)
        self.lazy_dependencies = code.lazy_imports
        self.schemas = ['{}.{}'.format(s.__module__, s.__name__) for s in code.schemas]
        self.schemas.sort()

    def get_extras(self):
        result = super().get_extras()