def qurl(url, add=None, exclude=None, remove=None):
urlp = list(urlparse(url))<EOL>qp = parse_qsl(urlp[<NUM_LIT:4>])<EOL>add = add if add else {}<EOL>for name, value in add.items():<EOL><INDENT>if isinstance(value, (list, tuple)):<EOL><INDENT>value = [smart_str(v) for v in value]<EOL>qp = [p for p in qp if p[<NUM_LIT:0>] != name or p[<NUM_LIT:1>] not in value]<EOL>qp.extend([(name, smart_str(val)) for val in value])<EOL><DEDENT>else:<EOL><INDENT>qp = [p for p in qp if p[<NUM_LIT:0>] != name]<EOL>qp.append((name, smart_str(value)))<EOL><DEDENT><DEDENT>exclude = exclude if exclude else {}<EOL>for name, value in exclude.items():<EOL><INDENT>if not isinstance(value, (list, tuple)):<EOL><INDENT>value = [value]<EOL><DEDENT>value = [smart_str(v) for v in value]<EOL>qp = [p for p in qp if p[<NUM_LIT:0>] != name or p[<NUM_LIT:1>] not in value]<EOL><DEDENT>remove = remove if remove else []<EOL>for name in remove:<EOL><INDENT>qp = [p for p in qp if p[<NUM_LIT:0>] != name]<EOL><DEDENT>urlp[<NUM_LIT:4>] = urlencode(qp, True)<EOL>return urlunparse(urlp)<EOL>
Returns the url with changed parameters