# -*- coding: utf-8 -*-
#------------------------------------------------------------------------------
# file: $Id$
# auth: Philip J Grabner <grabner@cadit.com>
# date: 2015/12/01
# copy: (C) Copyright 2015-EOT Cadit Inc., All Rights Reserved.
#------------------------------------------------------------------------------

import logging
import re
import json
import types
import inspect
import copy

import yaml
import six
from aadict import aadict
import asset
import pyramid.httpexceptions
import morph

from .scope import Scope
from .i18n import _
from . import util

#------------------------------------------------------------------------------

log = logging.getLogger(__name__)

# TODO: here, ``scalar`` really means ``primitive``... replace.
# todo: should `union` really exist?... it was only implemented for
#       "symmetry"...
#       ==> perhapse the "union" name is also a bit misleading???
#           in XMLSchema, "xsd:union" means the same as "one-of" here... ugh.

#------------------------------------------------------------------------------
class _aadict(aadict):
  def __setattr__(self, key, value):
    if value is None:
      return self.__delattr__(key)
    return super(_aadict, self).__setattr__(key, value)
  def __eq__(self, target): return self.__cmp__(target) == 0
  def __ne__(self, target): return self.__cmp__(target) != 0
  def __lt__(self, target): return self.__cmp__(target) < 0
  def __le__(self, target): return self.__cmp__(target) <= 0
  def __gt__(self, target): return self.__cmp__(target) > 0
  def __ge__(self, target): return self.__cmp__(target) >= 0

#------------------------------------------------------------------------------
class Type(_aadict):