simple function to generate the text of the task list so that it can be used in various places
335138
function generateTaskList (user) {
		
		var text = '';
		
		for (var t = 0; t < user.tasks.length; t++) {
			text = text + '> `' + (t + 1) + '`) ' + user.tasks[t] + '\n';
		}
		
		return text;
		
	}
259049
def taskinfo(self):
        

        task_input = {'taskName': 'QueryTask',
                      'inputParameters': {"Task_Name": self._name}}

        info = taskengine.execute(task_input, self._engine, cwd=self._cwd)

        task_def = info['outputParameters']['DEFINITION']

        task_def['name'] = str(task_def.pop('NAME'))
        task_def['description'] = str(task_def.pop('DESCRIPTION'))
        task_def['displayName'] = str(task_def.pop('DISPLAY_NAME'))

        if 'COMMUTE_ON_SUBSET' in task_def:
            task_def['commute_on_subset'] = task_def.pop('COMMUTE_ON_SUBSET')
        if 'COMMUTE_ON_DOWNSAMPLE' in task_def:
            task_def['commute_on_downsample'] = task_def.pop('COMMUTE_ON_DOWNSAMPLE')

        # Convert PARAMETERS into a list instead of a dictionary
        # which matches the gsf side things
        task_def['parameters'] = \
            [v for v in task_def['PARAMETERS'].values()]
        task_def.pop('PARAMETERS')

        parameters = task_def['parameters']
        for parameter in parameters:
            parameter['name'] = str(parameter.pop('NAME'))
            parameter['description'] = str(parameter.pop('DESCRIPTION'))
            parameter['display_name'] = str(parameter.pop('DISPLAY_NAME'))
            parameter['required'] = bool(parameter.pop('REQUIRED'))

            if 'MIN' in parameter:
                parameter['min'] = parameter.pop('MIN')

            if 'MAX' in parameter:
                parameter['max'] = parameter.pop('MAX')

            if parameter['TYPE'].count('['):
                parameter['type'], parameter['dimensions'] = parameter.pop('TYPE').split('[')
                parameter['dimensions'] = '[' + parameter['dimensions']
                parameter['type'] = str(parameter['type'])
            else:
                parameter['type'] = str(parameter.pop('TYPE').split('ARRAY')[0])

            if 'DIMENSIONS' in parameter:
                parameter['dimensions'] = parameter.pop('DIMENSIONS')

            if 'DIRECTION' in parameter:
                parameter['direction'] = parameter.pop('DIRECTION').lower()

            if 'DEFAULT' in parameter:
                if parameter['DEFAULT'] is not None:
                    parameter['default_value'] = parameter.pop('DEFAULT')
                else:
                    parameter.pop('DEFAULT')

            if 'CHOICE_LIST' in parameter:
                if parameter['CHOICE_LIST'] is not None:
                    parameter['choice_list'] = parameter.pop('CHOICE_LIST')
                else:
                    parameter.pop('CHOICE_LIST')

            if 'FOLD_CASE' in parameter:
                parameter['fold_case'] = parameter.pop('FOLD_CASE')

            if 'AUTO_EXTENSION' in parameter:
                parameter['auto_extension'] = parameter.pop('AUTO_EXTENSION')

            if 'IS_TEMPORARY' in parameter:
                parameter['is_temporary'] = parameter.pop('IS_TEMPORARY')

            if 'IS_DIRECTORY' in parameter:
                parameter['is_directory'] = parameter.pop('IS_DIRECTORY')

        return task_def
1305373
function walkGlobal (taskName) {
  // Skip dot operator and tasks that start with a dot.
  if (taskName.indexOf('.') === 0) return

  // Skip stuff that may include dots:
  // * comments
  // * strings
  // * numbers
  // * references
  if (regexComment.test(taskName)) return
  if (parseFloat(taskName)) return
  if (regexQuoted.test(taskName)) return
  if (regexReference.test(taskName)) return

  function toNextProp (next, prop) {
    return next[prop]
  }

  return taskName.split('.')
    .reduce(toNextProp, globalContext)
}
534325
function createNewTask(task) {
        console.log("Creating task...");

        //set up the new list item
        const listItem = document.createElement("li");
        const checkBox = document.createElement("input");
        const label = document.createElement("label");


        //pull the inputed text into label
        label.innerText = task;

        //add properties
        checkBox.type = "checkbox";

        //add items to the li
        listItem.appendChild(checkBox);
        listItem.appendChild(label);
        //everything put together
        return listItem;
    }
1327275
function(data, taskList) {
		var tasks = {};

		for (var key in taskList) {
			var module = taskList[key].split('.');
			if (!procsObj[module[0]]) return {
				'err': true,
				'tasks': module
			};
			var procsInst = new procsObj[module[0]](request, response, data);
			if (!procsInst[module[1]]) return {
				'err': true,
				'tasks': module
			};
			tasks[module[0] + '_' + module[1]] = procsInst[module[1]];
		}
		return {
			'err': false,
			'tasks': tasks
		};
	}
1183051
def _non_idempotent_tasks(self, output):
        
        # Remove blank lines to make regex matches easier.
        output = re.sub(r'\n\s*\n*', '\n', output)

        # Remove ansi escape sequences.
        output = util.strip_ansi_escape(output)

        # Split the output into a list and go through it.
        output_lines = output.split('\n')
        res = []
        task_line = ''
        for _, line in enumerate(output_lines):
            if line.startswith('TASK'):
                task_line = line
            elif line.startswith('changed'):
                host_name = re.search(r'\[(.*)\]', line).groups()[0]
                task_name = re.search(r'\[(.*)\]', task_line).groups()[0]
                res.append(u'* [{}] => {}'.format(host_name, task_name))

        return res
430447
private static function createTaskWithCrontabLine($task_class, $matches, $comment)
    {
        $task = $task_class::createNew();
        $task->setTime(trim($matches[2]));
        $arguments = str_replace(' ', ',', trim($matches[5]));
        $command = ucfirst($matches[3]) . '::' . $matches[4] . '(' . $arguments . ')';
        $task->setCommand($command);
        if (!empty($comment)) {
            $task->setComment($comment);
        }
        //$output = $matches[7];
        $status = empty($matches[1]) ? TaskInterface::TASK_STATUS_ACTIVE : TaskInterface::TASK_STATUS_INACTIVE;
        $task->setStatus($status);
        $task->setTs(date('Y-m-d H:i:s'));
        $task->taskSave();
        return $task;
    }
1262209
def print_task_help(self, task, name):
        
        TerminalColor.set('GREEN')
        print(get_signature(name, task))

        # TODO: print the location does not work properly and sometimes returns None
        # print('    => defined in: {}'.format(inspect.getsourcefile(task)))
        help_msg = inspect.getdoc(task) or ''
        TerminalColor.reset()
        print('   ' + help_msg.replace('\n', '\n   '))
        TerminalColor.reset()
        print()
693464
public static String taskListToString(List<RebalanceTaskInfo> infos) {
        StringBuffer sb = new StringBuffer();
        for (RebalanceTaskInfo info : infos) {
            sb.append("\t").append(info.getDonorId()).append(" -> ").append(info.getStealerId()).append(" : [");
            for (String storeName : info.getPartitionStores()) {
                sb.append("{").append(storeName).append(" : ").append(info.getPartitionIds(storeName)).append("}");
            }
            sb.append("]").append(Utils.NEWLINE);
        }
        return sb.toString();
    }
972369
def list_tasks(collector, tasks, **kwargs):
    """"""
    print("Available tasks to choose from are:")
    print("Use the --task option to choose one")
    print("")
    keygetter = lambda item: item[1].label
    tasks = sorted(tasks.items(), key=keygetter)
    for label, items in itertools.groupby(tasks, keygetter):
        print("--- {0}".format(label))
        print("----{0}".format("-" * len(label)))
        sorted_tasks = sorted(list(items), key=lambda item: len(item[0]))
        max_length = max(len(name) for name, _ in sorted_tasks)
        for key, task in sorted_tasks:
            desc = dedent(task.description or "").strip().split('\n')[0]
            print("\t{0}{1} :-: {2}".format(" " * (max_length-len(key)), key, desc))
        print("")
620110
def load_tasks(self, cmd, params, args):
        """"""
        return generate_tasks('taskname that shows up in log', self._gen_tasks()), self.DOIT_CONFIG
1072808
def encode_task(task):
    
    # First, clean the task:
    task = task.copy()
    if 'tags' in task:
        task['tags'] = ','.join(task['tags'])
    for k in task:
        for unsafe, safe in six.iteritems(encode_replacements):
            if isinstance(task[k], six.string_types):
                task[k] = task[k].replace(unsafe, safe)

        if isinstance(task[k], datetime.datetime):
            task[k] = task[k].strftime("%Y%m%dT%M%H%SZ")

    # Then, format it as a string
    return "[%s]\n" % " ".join([
        "%s:\"%s\"" % (k, v)
        for k, v in sorted(task.items(), key=itemgetter(0))
    ])
541373
def doc_task(task_name, task_config, project_config=None, org_config=None):
    
    from cumulusci.core.utils import import_class

    doc = []
    doc.append("{}\n==========================================\n".format(task_name))
    doc.append("**Description:** {}\n".format(task_config.description))
    doc.append("**Class::** {}\n".format(task_config.class_path))

    task_class = import_class(task_config.class_path)
    task_docs = textwrap.dedent(task_class.task_docs.strip("\n"))
    if task_docs:
        doc.append(task_docs + "\n")
    if task_class.task_options:
        doc.append("Options:\n------------------------------------------\n")
        defaults = task_config.options or {}
        for name, option in list(task_class.task_options.items()):
            default = defaults.get(name)
            if default:
                default = " **Default: {}**".format(default)
            else:
                default = ""
            if option.get("required"):
                doc.append(
                    "* **{}** *(required)*: {}{}".format(
                        name, option.get("description"), default
                    )
                )
            else:
                doc.append(
                    "* **{}**: {}{}".format(name, option.get("description"), default)
                )

    return "\n".join(doc)
318882
def _help():
	''''''
	for task in sorted(TASKS, key=lambda x: (x.ns or '000') + x.name):
		tags = ''
		if task is DEFAULT:
			tags += '*'
		if task is SETUP:
			tags += '+'
		if task is TEARDOWN:
			tags += '-'

		print LOCALE['help_command'].format(task, tags, task.help)

		if task.aliases:
			print LOCALE['help_aliases'].format(task.aliasstr())
		if task.reqs:
			print LOCALE['help_reqs'].format(task.reqstr())
		if task.gens:
			print LOCALE['help_gens'].format(task.gens)
		if task.args or task.defaults:
			print LOCALE['help_args'].format(task.ns + task.name, task.kwargstr(), task.argstr())
655128
def text(self):
        
        out = []
        out.extend(x.text for x in self.types.values())
        out.extend(x.text for x in self.enums.values())
        out.extend('extern {0};'.format(x.text)
                   for x in self.commands.values())
        return '\n'.join(out)
823238
def _get_task(name):
	''''''
	matches = [x for x in TASKS if x.match(name)]
	if matches:
		return matches[0]
902064
def help(self, context):
        
        context.info('%s\n%s [global options] [task] [task options]...\n' % (self.name, sys.argv[0]))

        def print_parameter(prn, p):
            if p.description:
                suffix = '    - {0.description}'.format(p)
            else:
                suffix = ''
            if p.constraint is bool:
                prn('    {0.arg_name}'.format(p) + suffix)
            else:
                prn('    {0.arg_name} [{0.value}]'.format(p) + suffix)

        context.info('Global options:')
        for parameter in self.context_parameters.values():
            print_parameter(context.info, parameter)
        context.info()

        context.info('Commands:')
        name_template = '  {0.name:<%d}' % min(max(map(len, self.available_tasks)), 20)
        for task in self.available_tasks.values():
            printer = context.debug if task.hidden else context.info
            if task.description:
                printer((name_template + ' - {0.description}').format(task))
            else:
                printer(name_template.format(task))
            for parameter in task.parameters.values():
                print_parameter(printer, parameter)