#NEWLINE# def expand( self , url ) : #NEWLINE# #INDENT# params = { #NEWLINE# #INDENT# 'shortUrl' : url , #NEWLINE# #UNINDENT# } #NEWLINE# url = '{0}?key={1}' . format ( self . api_url , self . api_key ) #NEWLINE# response = self . _get ( url , params = params ) #NEWLINE# if response . ok : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# data = response . json ( ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise ExpandingErrorException ( 'There was an error expanding this url - {0}' . format ( response . content ) ) #NEWLINE# #UNINDENT# if ( 'longUrl' in data ) : #NEWLINE# #INDENT# return data [ 'longUrl' ] #NEWLINE# #UNINDENT# #UNINDENT# raise ExpandingErrorException ( 'There was an error expanding this url - {0}' . format ( response . content ) )