Beispiel #1
0
    def __init__(cls, name, bases, dict):
        super(store_task_type, cls).__init__(name, bases, dict)
        name = cls.__name__

        if name != 'evil' and name != 'Task':
            if getattr(cls, 'run_str', None):
                # if a string is provided, convert it to a method
                (f, dvars) = compile_fun(cls.run_str, cls.shell)
                cls.hcode = Utils.h_cmd(cls.run_str)
                cls.orig_run_str = cls.run_str
                # change the name of run_str or it is impossible to subclass with a function
                cls.run_str = None
                cls.run = f
                # process variables
                cls.vars = list(set(cls.vars + dvars))
                cls.vars.sort()
                if cls.vars:
                    fun = compile_sig_vars(cls.vars)
                    if fun:
                        cls.sig_vars = fun
            elif getattr(cls, 'run', None) and not 'hcode' in cls.__dict__:
                # getattr(cls, 'hcode') would look in the upper classes
                cls.hcode = Utils.h_cmd(cls.run)

            # be creative
            getattr(cls, 'register', classes)[name] = cls
Beispiel #2
0
	def __init__(cls, name, bases, dict):
		super(store_task_type, cls).__init__(name, bases, dict)
		name = cls.__name__

		if name != 'evil' and name != 'Task':
			if getattr(cls, 'run_str', None):
				# if a string is provided, convert it to a method
				(f, dvars) = compile_fun(cls.run_str, cls.shell)
				cls.hcode = Utils.h_cmd(cls.run_str)
				cls.orig_run_str = cls.run_str
				# change the name of run_str or it is impossible to subclass with a function
				cls.run_str = None
				cls.run = f
				# process variables
				cls.vars = list(set(cls.vars + dvars))
				cls.vars.sort()
				if cls.vars:
					fun = compile_sig_vars(cls.vars)
					if fun:
						cls.sig_vars = fun
			elif getattr(cls, 'run', None) and not 'hcode' in cls.__dict__:
				# getattr(cls, 'hcode') would look in the upper classes
				cls.hcode = Utils.h_cmd(cls.run)

			# be creative
			getattr(cls, 'register', classes)[name] = cls
Beispiel #3
0
	def __init__(cls,name,bases,dict):
		super(store_task_type,cls).__init__(name,bases,dict)
		name=cls.__name__
		if name!='evil'and name!='Task':
			if getattr(cls,'run_str',None):
				(f,dvars)=compile_fun(cls.run_str,cls.shell)
				cls.hcode=Utils.h_cmd(cls.run_str)
				cls.orig_run_str=cls.run_str
				cls.run_str=None
				cls.run=f
				cls.vars=list(set(cls.vars+dvars))
				cls.vars.sort()
			elif getattr(cls,'run',None)and not'hcode'in cls.__dict__:
				cls.hcode=Utils.h_cmd(cls.run)
			getattr(cls,'register',classes)[name]=cls
Beispiel #4
0
	def __init__(cls,name,bases,dict):
		super(store_task_type,cls).__init__(name,bases,dict)
		name=cls.__name__
		if name!='evil'and name!='TaskBase':
			global classes
			if getattr(cls,'run_str',None):
				(f,dvars)=compile_fun(cls.run_str,cls.shell)
				cls.hcode=Utils.h_cmd(cls.run_str)
				cls.orig_run_str=cls.run_str
				cls.run_str=None
				cls.run=f
				cls.vars=list(set(cls.vars+dvars))
				cls.vars.sort()
			elif getattr(cls,'run',None)and not'hcode'in cls.__dict__:
				cls.hcode=Utils.h_cmd(cls.run)
			getattr(cls,'register',classes)[name]=cls
    def __init__(cls, name, bases, dict):
        super().__init__(name, bases, dict)
        name = cls.__name__

        if name != "evil" and name != "Task":
            if getattr(cls, "run_str", None):
                # if a string is provided, convert it to a method
                (f, dvars) = compile_fun(cls.run_str, cls.shell)
                cls.hcode = Utils.h_cmd(cls.run_str)
                cls.orig_run_str = cls.run_str
                # change the name of run_str or it is impossible to subclass with a function
                cls.run_str = None
                cls.run = f
                cls.vars = list(set(cls.vars + dvars))
                cls.vars.sort()
            elif getattr(cls, "run", None) and not "hcode" in cls.__dict__:
                # getattr(cls, 'hcode') would look in the upper classes
                cls.hcode = Utils.h_cmd(cls.run)

            # be creative
            getattr(cls, "register", classes)[name] = cls