#NEWLINE# def adjust_uri( self , uri , relativeto ) : #NEWLINE# #INDENT# 'Adjust the given ``uri`` based on the given relative URI.' #NEWLINE# key = ( uri , relativeto ) #NEWLINE# if ( key in self . _uri_cache ) : #NEWLINE# #INDENT# return self . _uri_cache [ key ] #NEWLINE# #UNINDENT# if ( uri [ 0 ] != '/' ) : #NEWLINE# #INDENT# if ( relativeto is not None ) : #NEWLINE# #INDENT# v = self . _uri_cache [ key ] = posixpath . join ( posixpath . dirname ( relativeto ) , uri ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# v = self . _uri_cache [ key ] = ( '/' + uri ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# v = self . _uri_cache [ key ] = uri #NEWLINE# #UNINDENT# return v