def task_and_state(task, state): """Combines a task objects string representation with a state to create a uniquely identifying task+state name.""" task_name = "" if isinstance(task, types.FunctionType): # If its a function look for the attributes that should have been # set using the task() decorator provided in the decorators file. If # those have not been set, then we should at least have enough basic # information (not a version) to form a useful task name. if hasattr(task, 'name'): task_name = str(task.name) else: name_pieces = [ a for a in utils.get_many_attr(task, '__module__', '__name__') if a is not None ] task_name = utils.join(name_pieces, ".") task_version = getattr(task, '__version__', None) if isinstance(task_version, (list, tuple)): task_version = utils.join(task_version, with_what=".") if task_version is not None: task_name += "==%s" % (task_version) else: task_name = str(task) return "%s;%s" % (task_name, state)
def task_and_state(task, state): """Combines a task objects string representation with a state to create a uniquely identifying task+state name.""" task_name = "" if isinstance(task, types.FunctionType): # If its a function look for the attributes that should have been # set using the task() decorator provided in the decorators file. If # those have not been set, then we should at least have enough basic # information (not a version) to form a useful task name. if hasattr(task, 'name'): task_name = str(task.name) else: name_pieces = [a for a in utils.get_many_attr(task, '__module__', '__name__') if a is not None] task_name = utils.join(name_pieces, ".") task_version = getattr(task, '__version__', None) if isinstance(task_version, (list, tuple)): task_version = utils.join(task_version, with_what=".") if task_version is not None: task_name += "==%s" % (task_version) else: task_name = str(task) return "%s;%s" % (task_name, state)
def __str__(self): return "%s==%s" % (self.name, utils.join(self.version, with_what="."))