Given a list of tokens, return a tuple of the command
        and the args as a string.
172580
def _command_and_args(tokens: List[str]) -> Tuple[str, str]:
        
        command = ''
        args = ''

        if tokens:
            command = tokens[0]

        if len(tokens) > 1:
            args = ' '.join(tokens[1:])

        return command, args
1173429
private static List<String> fixArguments(List<String> command) {
    if (!IS_OS_WINDOWS) {
      return command;
    }
    List<String> result = new ArrayList<String>(command);
    for (ListIterator it = result.listIterator(); it.hasNext(); ) {
      if ("".equals(it.next())) {
        it.set("\"\"");
      }
    }
    return result;
  }
715002
def iter_token_lines(tokenlist):
    
    line = []
    for token, c in explode_tokens(tokenlist):
        line.append((token, c))

        if c == '\n':
            yield line
            line = []

    yield line
1170907
def format_help(self, tokens: List[str]) -> str:
        """"""
        for idx, token in enumerate(tokens):
            if idx >= self._token_start_index:
                if self._positional_completers:
                    # For now argparse only allows 1 sub-command group per level
                    # so this will only loop once.
                    for completers in self._positional_completers.values():
                        if token in completers:
                            return completers[token].format_help(tokens)
        return self._parser.format_help()
1182010
def get_command_templates(command_tokens, file_tokens=[], path_tokens=[],
    job_options=[]):
    
    files = get_files(file_tokens)
    paths = get_paths(path_tokens)
    job_options = get_options(job_options)

    templates = _get_command_templates(command_tokens, files, paths,
        job_options)

    for command_template in templates:
        command_template._dependencies = _get_prelim_dependencies(
            command_template, templates)
    return templates
976934
def extract_args(self, data):
        
        args = []
        data = data.strip(' ')
        if ':' in data:
            lhs, rhs = data.split(':', 1)
            if lhs: args.extend(lhs.rstrip(' ').split(' '))
            args.append(rhs)
        else:
           args.extend(data.split(' '))
        return tuple(args)
1205305
def split_token_in_parts(token):
    
    result = []
    current = []
    for part in token + (':', ):
        if part == ':':
            if current:
                result.append(tuple(current))
                current = []
        else:
            current.append(part)

    return result
1332761
def tuple_to_string(prog_tuple):
    """"""
    (roman, acc, suff) = prog_tuple
    if acc > 6:
        acc = 0 - acc % 6
    elif acc < -6:
        acc = acc % 6
    while acc < 0:
        roman = 'b' + roman
        acc += 1
    while acc > 0:
        roman = '#' + roman
        acc -= 1
    return roman + suff
305735
def tokenize(s):
    
    return [m.group(m.lastindex) for m in _tdl_re.finditer(s)]
512722
def ptokens(cmd, text)
      Enumerator.new do |yielder|
        pos = 0
        tokens(cmd, text).each do |token|
          ne_text = token['form'].dup

          ne_regexp = build_regexp(ne_text)
          token_pos = text.index(ne_regexp, pos)

          if token_pos && token_pos < (pos + 5)
            token.pos = token_pos
            yielder << token

            pos = token_pos + ne_text.length
          else
            pos = pos + ne_text.length
          end
        end
      end
    end
46847
def _get_command_templates(command_tokens, files=[], paths=[], job_options=[],
    count=1):
    
    if not command_tokens:
        return []

    comment_tokens, command_token = command_tokens.pop()
    parts = []

    parts += job_options + _get_comments(comment_tokens)
    for part in command_token[0]:
        # Check for file
        try:
            parts.append(_get_file_by_alias(part, files))
            continue
        except (AttributeError, ValueError):
            pass

        # Check for path/string
        for cut in part.split():
            try:
                parts.append(_get_path_by_name(cut, paths))
                continue
            except ValueError:
                pass

            parts.append(cut)

    command_template = CommandTemplate(alias=str(count), parts=parts)
    [setattr(p, 'alias', command_template.alias)
        for p in command_template.output_parts]
    return [command_template] + _get_command_templates(command_tokens,
        files, paths, job_options, count+1)
63279
def args_as_tuple(self):
        
        value = self.arguments["header-names"]
        if isinstance(value, list):
            value = "[{}]".format(
                ",".join('"{}"'.format(item) for item in value))
        if not value.startswith("["):
            return ('exists', value.strip('"'))
        return ("exists", ) + tuple(tools.to_list(value))
229769
def parse_from_args(self, l):
        """"""
        if self.multiple:
            return [self.parse_from_arg(arg) for arg in l]
        return self.parse_from_arg(l[0])
444686
def get_tokens(line: str) -> Iterator[str]:
    
    for token in line.rstrip().split():
        if len(token) > 0:
            yield token
355436
def parse_args(self, ctx, args):
        """"""
        if args and args[0] in self.commands:
            args.insert(0, '')
        super(OptionalGroup, self).parse_args(ctx, args)
242351
def args_as_tuple(self):
        """"""
        result = ("currentdate", )
        result += (
            ":zone",
            self.extra_arguments["zone"].strip('"'),
            self.arguments["match-type"],
        )
        if self.arguments["match-type"] in [":count", ":value"]:
            result += (self.extra_arguments["match-type"].strip('"'), )
        result += (self.arguments["date-part"].strip('"'), )
        value = self.arguments["key-list"]
        if isinstance(value, list):
            # FIXME
            value = "[{}]".format(
                ",".join('"{}"'.format(item) for item in value))
        if value.startswith("["):
            result = result + tuple(tools.to_list(value))
        else:
            result = result + (value.strip('"'),)
        return result
1372970
def cmd2list(cmd):
   ''' 
   '''
   p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
   stdout, stderr = p.communicate()
   if p.returncode != 0 and stderr != '':
      return "ERROR: %s\n"%(stderr)
   else:
      return stdout.split('\n')