#NEWLINE# def url_to_file_name( url , query_params = None , post_params = None ) : #NEWLINE# #INDENT# file_name = url #NEWLINE# if file_name . startswith ( 'http://' ) : #NEWLINE# #INDENT# file_name = file_name [ 7 : ] #NEWLINE# #UNINDENT# if file_name . startswith ( 'https://' ) : #NEWLINE# #INDENT# file_name = file_name [ 8 : ] #NEWLINE# #UNINDENT# file_name = _ESCAPE_CHARACTERS_RE . sub ( '-' , file_name ) #NEWLINE# file_name = _TRIM_TRAILING_DASHES_RE . sub ( '' , file_name ) #NEWLINE# signature_data = [ ] #NEWLINE# if ( len ( file_name ) > 64 ) : #NEWLINE# #INDENT# signature_data . append ( file_name [ 64 : ] ) #NEWLINE# file_name = file_name [ : 64 ] #NEWLINE# #UNINDENT# if query_params : #NEWLINE# #INDENT# signature_data . append ( str ( url ) ) #NEWLINE# #UNINDENT# if post_params : #NEWLINE# #INDENT# signature_data . append ( str ( post_params ) ) #NEWLINE# #UNINDENT# if signature_data : #NEWLINE# #INDENT# signature = hashlib . md5 ( '-' . join ( signature_data ) ) . digest ( ) #NEWLINE# signature = base64 . urlsafe_b64encode ( signature ) #NEWLINE# signature = re . sub ( '=+$' , '' , signature ) #NEWLINE# file_name += ( '-' + signature ) #NEWLINE# #UNINDENT# return file_name