#NEWLINE# def parse( self , mappings , use_default_path = False ) : #NEWLINE# #INDENT# 'Parse a list of map strings (mappings)\n\n        Accepts two distinct formats:\n        1. If there are exactly two entries then these may be the source base URI\n        and the destination base path. Neither may contain an equals (=) sign.\n        2. For any number of mapping stings interpret each as a mapping URI=path. \n        These are in the order they will be tried.\n        \n        And if use_default_path is True then a third:\n        3. If there is exactly one entry and it does not contain an equals (=)\n        sign then a safe local path is created based on the source base URI. In\n        the case that the source base URI is a local path already then an indentity \n        mapping is used.\n        ' #NEWLINE# if ( use_default_path and ( len ( mappings ) == 1 ) and ( re . search ( '=' , mappings [ 0 ] ) == None ) ) : #NEWLINE# #INDENT# path = self . path_from_uri ( mappings [ 0 ] ) #NEWLINE# self . logger . warning ( ( 'Using URI mapping: %s -> %s' % ( mappings [ 0 ] , path ) ) ) #NEWLINE# self . mappings . append ( Map ( mappings [ 0 ] , path ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( len ( mappings ) == 2 ) and ( re . search ( '=' , mappings [ 0 ] ) == None ) and ( re . search ( '=' , mappings [ 1 ] ) == None ) ) : #NEWLINE# #INDENT# self . mappings . append ( Map ( mappings [ 0 ] , mappings [ 1 ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for mapping in mappings : #NEWLINE# #INDENT# l = mapping . split ( '=' ) #NEWLINE# if ( len ( l ) != 2 ) : #NEWLINE# #INDENT# raise MapperError ( ( 'Bad mapping argument (%s), got %s' % ( mapping , str ( l ) ) ) ) #NEWLINE# #UNINDENT# ( src_uri , dst_path ) = l #NEWLINE# for map in self . mappings : #NEWLINE# #INDENT# if ( src_uri == map . src_uri ) : #NEWLINE# #INDENT# raise MapperError ( ( 'Attempt to set duplicate mapping for source URI %s (with destination path %s)' % ( src_uri , dst_path ) ) ) #NEWLINE# #UNINDENT# if ( dst_path == map . dst_path ) : #NEWLINE# #INDENT# raise MapperError ( ( 'Attempt to set duplicate mapping for destination path %s (with source URI %s)' % ( dst_path , src_uri ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . mappings . append ( Map ( src_uri , dst_path ) )