def update_url(url, update_args=None, remove_args=None):
    scheme, sep, url_new = url.partition('://')
    if len(scheme) == len(url):
        scheme = ''
    else:
        url = '//' + url_new

    url_split = urlparse.urlsplit(url)
    query_dict = urlparse.parse_qs(url_split.query, keep_blank_values=True)

    # add args
    if update_args:
        query_dict.update(update_args)

    # remove args
    if remove_args:
        query_dict = dict([(k, query_dict.get(k)) for k in query_dict if k not in remove_args])

    query = make_qs(query_dict)
    return urlparse.urlunsplit((scheme, url_split.netloc, url_split.path, query, url_split.fragment))
dataset/ETHPy150Open glibin/tortik/tortik/util/__init__.py/update_url/original