コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
    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 = []
コード例 #4
0
ファイル: block_meta.py プロジェクト: pombredanne/procgraph
    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 = []
コード例 #5
0
ファイル: interface2.py プロジェクト: avcopan/pypractice
 def __call__(cls, *args, **kwargs):
     instance = ContractsMeta.__call__(cls, *args, **kwargs)
     instance._check_common_attributes()
     return instance