Extract all of the parameters from the tokens.

        :param tokens: The tokens to extract the parameters from
        :type tokens: list

        :rtype: dict
16557
def _parameters(cls, tokens):
        
        arguments = []
        options = []

        for token in tokens:
            if not token.startswith("--"):
                arguments.append(cls._parse_argument(token))
            else:
                options.append(cls._parse_option(token))

        return {"arguments": arguments, "options": options}
118350
def fetch(index, tokens):
    
    if len(tokens) == 0:
        return set()
    return set.intersection(*[set(index.get(token, [])) for token in tokens])
1175960
def _subtoken_to_tokens(self, subtokens):
        
        concatenated = "".join(subtokens)
        split = concatenated.split("_")
        return [_unescape_token(t + "_") for t in split if t]
107563
def tokens(self):
        
        if self._tokens is None:
            self._tokens = TokenList(self._version, account_sid=self._solution['sid'], )
        return self._tokens
1361733
def unpack(self, token, **kwargs):
        
        if isinstance(token, str):
            try:
                token = token.encode("utf-8")
            except UnicodeDecodeError:
                pass

        part = split_token(token)
        self.b64part = part
        self.part = [b64d(p) for p in part]
        self.headers = json.loads(as_unicode(self.part[0]))
        for key,val in kwargs.items():
            if not val and key in self.headers:
                continue

            try:
                _ok = self.verify_header(key,val)
            except KeyError:
                raise
            else:
                if not _ok:
                    raise HeaderError(
                        'Expected "{}" to be "{}", was "{}"'.format(
                            key, val, self.headers[key]))

        return self
366837
def detect_spans(self, tokens):
        
        candidates = self._get_candidates(tokens)
        results = self._filter_candidates(tokens, candidates)
        return results
606871
def call(self, tokens, *args, **kwargs):
        
        tokens.append([evaluate, [args, kwargs], {}])
        return tokens
1364673
def parse_tokens(self, tokens):
        
        if len(tokens) == 1:
            return list(), tokens, {"kubectl": self.ast.help}
        else:
            tokens.reverse()
        parsed, unparsed, suggestions = self.treewalk(self.ast, parsed=list(), unparsed=tokens)
        if not suggestions and unparsed:
            # TODO: @vogxn: This is hack until we include expected value types for each option and argument.
            # Whenver we recieve no suggestions but are left with unparsed tokens we pop the value and walk the
            # tree again without values
            logger.debug("unparsed tokens remain, possible value encountered")
            unparsed.pop()
            parsed.reverse()
            unparsed.extend(parsed)
            logger.debug("resuming treewalk with tokens: %s", unparsed)
            return self.treewalk(self.ast, parsed=list(), unparsed=unparsed)
        else:
            return parsed, unparsed, suggestions
319795
def parse(tokens):
    ''''''
    args = []
    kwargs = {}
    last = None
    for token in tokens:
        if token.startswith('--'):
            # If this is a keyword flag, but we've already got one that we've
            # parsed, then we're going to interpret it as a bool
            if last:
                kwargs[last] = True
            # See if it is the --foo=5 style
            last, _, value = token.strip('-').partition('=')
            if value:
                kwargs[last] = value
                last = None
        elif last != None:
            kwargs[last] = token
            last = None
        else:
            args.append(token)

    # If there's a dangling last, set that bool
    if last:
        kwargs[last] = True

    return args, kwargs
226594
def _headers(self, **kwargs):
        
        headers = BASE_HEADERS.copy()
        if self._token:
            headers['X-Plex-Token'] = self._token
        headers.update(kwargs)
        return headers
625952
def _escaped_token_to_subtoken_ids(self, escaped_token):
    
    return [
        self._subtoken_string_to_id[subtoken]
        for subtoken in self._escaped_token_to_subtoken_strings(escaped_token)
    ]
955470
def expr(self, token_stream, token):
        
        lval = self.keyword(token_stream, token, {})
        token = next(token_stream)
        if token[0] == 'OR':
            op = or_
            token = next(token_stream)
        elif token[0] == 'TEXT' or token[0] == 'COLOR':
            op = lambda l, r: list(flatten([l, r]))
        elif token[0] == 'SEPARATOR':
            op = lambda l, r: list(flatten([l, r]))
            token = next(token_stream)
        else:
            return [lval]
        rval = self.expr(token_stream, token)
        return op(lval, rval)
1233623
def _parse_vars(self, tokens):
        
        key_values = {}
        for token in tokens:
            if token.startswith('#'):
                # End parsing if we encounter a comment, which lasts
                # until the end of the line.
                break
            else:
                k, v = token.split('=', 1)
                key = k.strip()
                key_values[key] = v.strip()
        return key_values
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
579169
def get_tokens(tokens):
    
    tokens = tokens[1:-1]
    ret = []
    start = 0
    stack = 0
    for i in range(len(tokens)):
        if tokens[i] == '(':
            if stack == 0:
                start = i
            stack += 1
        elif tokens[i] == ')':
            stack -= 1
            if stack < 0:
                raise Exception('Bracket mismatch: ' + str(tokens))
            if stack == 0:
                ret.append(get_tokens(tokens[start:i + 1]))
        else:
            if stack == 0:
                ret.append(tokens[i])
    if stack != 0:
        raise Exception('Bracket mismatch: ' + str(tokens))
    return ret
248384
def get_tokens(self, filters={}):
        
        uri = 'tokens'

        if filters:
            filters = {'filters': json.dumps(filters)}
            uri += "?%s" % urllib.urlencode(filters, True)

        resp, body = self.get(uri)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)
489006
def ids2strids(ids: Iterable[int]) -> str:
    
    return C.TOKEN_SEPARATOR.join(map(str, ids))