#NEWLINE# @ library . filter #NEWLINE# def urlparams( url_ , hash = None , **query ) : #NEWLINE# #INDENT# 'Add a fragment and/or query paramaters to a URL.\n\n    New query params will be appended to exising parameters, except duplicate\n    names, which will be replaced.\n    ' #NEWLINE# url = urlparse . urlparse ( url_ ) #NEWLINE# fragment = ( hash if ( hash is not None ) else url . fragment ) #NEWLINE# query_dict = dict ( urlparse . parse_qsl ( url . query ) ) #NEWLINE# query_dict . update ( query ) #NEWLINE# query_string = urlencode ( [ ( k , v ) for ( k , v ) in query_dict . items ( ) if ( v is not None ) ] ) #NEWLINE# new = urlparse . ParseResult ( url . scheme , url . netloc , url . path , url . params , query_string , url ) #NEWLINE# return new . geturl ( )