def __init__(cls, clsname, bases, clsdict): # @UnusedVariable @NoSelf ContractsMeta.__init__(cls, clsname, bases, clsdict) if not 'cmd' in clsdict: # print('skpping %r' % cls) return # print('Automatically registering %s>%s' % (cls, clsname)) if clsname in ['SubCmd']: return cmds = QuickMultiCmdApp.subs[appcls] cmds.append(cls)
def __init__(cls, clsname, bases, clsdict): # @UnusedVariable @NoSelf ContractsMeta.__init__(cls, clsname, bases, clsdict) # Do not do this for the superclasses if clsname in ['Generator', 'Block']: return setattr(cls, 'defined_in', cls.__module__) setattr(cls, 'config', BlockMeta.tmp_config) setattr(cls, 'output', BlockMeta.tmp_output) setattr(cls, 'input', BlockMeta.tmp_input) BlockMeta.tmp_config = [] BlockMeta.tmp_output = [] BlockMeta.tmp_input = [] has_variable_input = [x for x in BlockMeta.tmp_input if x.type == VARIABLE] has_variable_output = [x for x in BlockMeta.tmp_output if x.type == VARIABLE] if has_variable_output and not has_variable_input: raise ModelWriterError('Cannot have variable output without ' 'variable input.') if len(BlockMeta.aliases) > 1: raise ModelWriterError("We don't support multiple aliases yet. " "Tried to set %r." % BlockMeta.aliases) if BlockMeta.aliases: name = BlockMeta.aliases[0] else: name = cls.__name__ from .registrar import default_library default_library.register(name, cls) BlockMeta.aliases = []
def __call__(cls, *args, **kwargs): instance = ContractsMeta.__call__(cls, *args, **kwargs) instance._check_common_attributes() return instance