예제 #1
0
 def load_base(cls, base_name, all_bases, all_mixins):
     previous_bases = []
     base = {}
     while base_name is not None:
         if base_name in previous_bases:
             raise ValueError("Cyclic bases detected: %s -> %s" % (' -> '.join(previous_bases), base_name))
         previous_bases.append(base_name)
         base.pop('base', None)
         this_base = all_bases[base_name]
         if 'mixins' in this_base:
             mixins = cls.load_mixins(this_base['mixins'], all_mixins)
             mixins.pop('base', None)
             this_base = dict_merge(this_base, mixins)
         base = dict_merge(this_base, base)
         base_name = base.get('base')
     return base
예제 #2
0
 def load_mixins(cls, mixin_list, all_mixins):
     if isinstance(mixin_list, str):
         ## Single mixin can just be a string. Convert to single item list.
         mixin_list = [mixin_list]
     mixin = {}
     for mixin_name in mixin_list:
         mixin = dict_merge(mixin, all_mixins[mixin_name])
     return mixin
예제 #3
0
 def parse_comic(cls, info, all_bases, all_mixins):
     base = {}
     mixin = {}
     if 'base' in info:
         base = cls.load_base(info['base'], all_bases, all_mixins)
     if 'mixins' in info:
         mixin = cls.load_mixins(info['mixins'], all_mixins)
     return dict_merge(base, mixin, info)