Reverse conversion for parse_qsl
325025
def unparse_qsl(qsl, sort=False, reverse=False):
    """"""
    result = []
    items = qsl
    if sort:
        items = sorted(items, key=lambda x: x[0], reverse=reverse)
    for keys, values in items:
        query_name = quote(keys)
        result.append(query_name + "=" + quote(values))
    return "&".join(result)
1286783
def parse_backend(backend):
    """"""
    r = urlparse.urlsplit(backend)
    scheme, host = r.scheme, r.netloc
    path, query = r.path, r.query
    if path and not query:
        query, path = path, ''
        if query:
            if query.find('?'):
                path = query
            else:
                query = query[1:]
    if query:
        params = dict(urlparse.parse_qsl(query))
    else:
        params = {}

    return scheme, host, params
585941
def convert(aRawParse)
      result = case configuration.parse_repr
                 when :parse_tree
                   to_ptree(aRawParse)
                 when :parse_forest
                   to_pforest(aRawParse)
               end

      return result
    end
174984
def _parse_template(tmpl_str):
    '''
    
    '''
    tmpl_str = tmpl_str.strip()
    if tmpl_str.startswith('{'):
        tpl = salt.utils.json.loads(tmpl_str)
    else:
        try:
            tpl = salt.utils.yaml.safe_load(tmpl_str)
        except salt.utils.yaml.YAMLError as exc:
            raise ValueError(six.text_type(exc))
        else:
            if tpl is None:
                tpl = {}
    if not ('HeatTemplateFormatVersion' in tpl
            or 'heat_template_version' in tpl
            or 'AWSTemplateFormatVersion' in tpl):
        raise ValueError(('Template format version not found.'))
    return tpl
1362984
def convert_from(self, base):
        """"""
        if self.identifier == 'bmp':
            return base
        elif self.identifier == 'man':
            result = []
            prefix = 'BOOST_METAPARSE_STRING("'
            while True:
                bmp_at = base.find(prefix)
                if bmp_at == -1:
                    return ''.join(result) + base
                else:
                    result.append(
                        base[0:bmp_at] + '::boost::metaparse::string<'
                    )
                    new_base = ''
                    was_backslash = False
                    comma = ''
                    for i in xrange(bmp_at + len(prefix), len(base)):
                        if was_backslash:
                            result.append(
                                '{0}\'\\{1}\''.format(comma, base[i])
                            )
                            was_backslash = False
                            comma = ','
                        elif base[i] == '"':
                            new_base = base[i+2:]
                            break
                        elif base[i] == '\\':
                            was_backslash = True
                        else:
                            result.append('{0}\'{1}\''.format(comma, base[i]))
                            comma = ','
                    base = new_base
                    result.append('>')
392224
def reverse(self):
        
        name = self.schema.get('rdfReverse')
        if name is not None:
            return name
        if self.parent is not None and self.parent.is_array:
            return self.parent.reverse
1292531
def parse_ctcp(query):
    
    query = query.strip(CTCP_DELIMITER)
    query = query.replace(CTCP_ESCAPE_CHAR + '0', '\0')
    query = query.replace(CTCP_ESCAPE_CHAR + 'n', '\n')
    query = query.replace(CTCP_ESCAPE_CHAR + 'r', '\r')
    query = query.replace(CTCP_ESCAPE_CHAR + CTCP_ESCAPE_CHAR, CTCP_ESCAPE_CHAR)
    if ' ' in query:
        return query.split(' ', 1)
    return query, None
484407
def convert_none(key, val, attr_type, attr={}, cdata=False):
    """"""
    LOG.info('Inside convert_none(): key="%s"' % (unicode_me(key)))

    key, attr = make_valid_xml_name(key, attr)

    if attr_type:
        attr['type'] = get_xml_type(val)
    attrstring = make_attrstring(attr)
    return '<%s%s></%s>' % (key, attrstring, key)
244180
def _parse_tol(rtol,atol):
    """"""
    #Process atol and rtol
    if rtol is None:
        rtol= -12.*nu.log(10.)
    else: #pragma: no cover
        rtol= nu.log(rtol)
    if atol is None:
        atol= -12.*nu.log(10.)
    else: #pragma: no cover
        atol= nu.log(atol)
    return (rtol,atol)
766523
def _parseXpathScope(self):
        
        rd = self.refsDecl
        matches = REFSDECL_SPLITTER.findall(rd)
        return REFSDECL_REPLACER.sub("?", "".join(matches[0:-1])), REFSDECL_REPLACER.sub("?", matches[-1])
1338010
def getquerylist(self, sep='&', encoding='utf-8', errors='strict'):
        
        if not self.query:
            return []
        elif isinstance(sep, type(self.query)):
            qsl = self.query.split(sep)
        elif isinstance(sep, bytes):
            qsl = self.query.split(sep.decode('ascii'))
        else:
            qsl = self.query.split(sep.encode('ascii'))
        items = []
        for parts in [qs.partition(self.EQ) for qs in qsl if qs]:
            name = uridecode(parts[0], encoding, errors)
            if parts[1]:
                value = uridecode(parts[2], encoding, errors)
            else:
                value = None
            items.append((name, value))
        return items
285191
def parse(self):
        """"""
        token_type = self.current_token.type.lower()
        handler = getattr(self, f'parse_{token_type}', None)
        if handler is None:
            raise self.error(f'Invalid literal {self.current_token.value!r}')
        return handler()
470358
def render(data, saltenv='base', sls='', argline='', **kwargs):  # pylint: disable=unused-argument
    '''
    
    '''
    translate_newlines = kwargs.get('translate_newlines', False)
    return _decrypt_object(data, translate_newlines=translate_newlines)
450707
function parseCFFIndex(reader, offset, conversionFn) {
            if (offset) {
                reader.seek(offset);
            }
            var start = reader.offset;
            var offsets = [];
            var objects = [];
            var count = reader.readUint16();
            var i;
            var l;
            if (count !== 0) {
                var offsetSize = reader.readUint8();
                for (i = 0, l = count + 1; i < l; i++) {
                    offsets.push(getOffset(reader, offsetSize));
                }

                for (i = 0, l = count; i < l; i++) {
                    var value = reader.readBytes(offsets[i + 1] - offsets[i]);
                    if (conversionFn) {
                        value = conversionFn(value);
                    }
                    objects.push(value);
                }
            }

            return {
                objects: objects,
                startOffset: start,
                endOffset: reader.offset
            };
        }
390597
def qs_from_dict(qsdict, prefix=""):
    ''' 
    '''
    prefix = prefix + '.' if prefix else ""

    def descend(qsd):
        for key, val in sorted(qsd.items()):
            if val:
                yield qs_from_dict(val, prefix + key)
            else:
                yield prefix + key
    return ",".join(descend(qsdict))
1021424
def parse(self, xsl='text'):
        

        try:
            cmd_text, option_text = xsl.split(None, 1)
        except ValueError:
            cmd_text = xsl
            option_text = ''

        try:
            context, cmd = cmd_text.strip().lower().split(':', 1)
        except ValueError:
            cmd = cmd_text.lower()
            context = None

        if not cmd in DEFAULT_CMD_TO_CONTEXT_MAPPING:
            raise ParseError("unknown command %s" % cmd)

        if context and not context in CONTEXTS:
            raise ParseError("unknown context %s" % context)

        self.context = context
        self.cmd = cmd
        self.text = None
        self.meta_commands = []
        self.options = {}

        try:
            if cmd in ('choose', 'text', 'meta'):
                raise ValueError()
            option_name, expr = option_text.split('=', 1)
            option_name = option_name.strip().lower()
            expr = unescape(expr).strip("'").strip('"').strip()
            self.options = {option_name: expr}

        except ValueError:
            text = unescape(option_text)

            if cmd == 'meta':
                for mc in filter(lambda c: c, map(lambda c: c.strip(), text.lower().split(';'))):
                    if mc in META_COMMANDS:
                        # store in stack order
                        self.meta_commands = [mc] + self.meta_commands
                    else:
                        raise ParseError("unknown meta command %s" % self.text)

            else:
                self.text = text
819252
def parse_mtl(mtl):
    
    # decode bytes if necessary
    if hasattr(mtl, 'decode'):
        mtl = mtl.decode('utf-8')

    mtllib = None
    mtllibs = []

    # use universal newline splitting
    for line in str.splitlines(str(mtl).strip()):
        # clean leading/trailing whitespace and split
        line_split = line.strip().split()
        # needs to be at least two values
        if len(line_split) <= 1:
            continue
        # store the keys
        key = line_split[0]
        if key == 'newmtl':
            if mtllib:
                mtllibs.append(mtllib)
            mtllib = {'newmtl': line_split[1],
                      'map_Kd': None,
                      'Kd': None}
        elif key == 'map_Kd':
            mtllib[key] = line_split[1]
        elif key == 'Kd':
            mtllib[key] = [float(x) for x in line_split[1:]]
    if mtllib:
        mtllibs.append(mtllib)

    return mtllibs