#NEWLINE# def expand( template , variables = None ) : #NEWLINE# #INDENT# '\n    Expand a URL template string using the passed variables\n    ' #NEWLINE# if ( variables is None ) : #NEWLINE# #INDENT# variables = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# return patterns . sub ( functools . partial ( _replace , variables ) , template )