def parse_qs(s, *args, **kwargs): s = _reencode(s) orig = _parse_qs(s, *args, **kwargs) return { k.decode('utf-8'): [vv.decode('utf-8') for vv in v] for k, v in orig.items() }
def parse_qs(query): kwargs = dict() for k,v in _parse_qs(query).iteritems(): if len(v)==1: v = v[0] kwargs[k] = v return kwargs
def __init__(self, string): parts = urlparse.urlsplit(urllib.unquote(string)) if parts[0] != 'http' and parts[0] != 'https': raise ValueError('Invalid url: %s.' % string) if "@" in parts[1]: host = parts[1].split('@').pop() else: host = parts[1] self.hostname = host if parts[0] == 'http': self.port = 80 else: self.port = 443 if ":" in host: try: self.hostname, self.port = host.split(':') except: raise ValueError('Invalid url: %s.' % string) self.port = int(self.port) self.uri = "%s://%s" % (parts[0], host) if parts[2]: self.path = parts[2] else: self.path = '' if parts[3]: self.query = _parse_qs(parts[3]) else: self.query = {} self.username = parts.username self.password = parts.password
def parse_qs(qs): return dict((k, v[0] if len(v) == 1 else v) for (k, v) in _parse_qs(qs).iteritems())
def parse_qs(qs): return dict( (k, v[0] if len(v) == 1 else v) for (k, v) in _parse_qs(qs).iteritems())
def parse_qs(qs): # str -> Dict[str, List[str]] return {py2_decode(param): [py2_decode(a) for a in args] for param, args in _parse_qs(py2_encode(qs)).items()}
def parse_qs(*args, **kwargs): d = _parse_qs(*args, **kwargs) r = {} for k in d: r[k] = d[k][0] return r