#NEWLINE# def build_output_directory( self , path ) : #NEWLINE# #INDENT# '\n        Set the output directory for extracted files.\n\n        @path - The path to the file that data will be extracted from.\n\n        Returns None.\n        ' #NEWLINE# if ( not has_key ( self . extraction_directories , path ) ) : #NEWLINE# #INDENT# basedir = os . path . dirname ( path ) #NEWLINE# basename = os . path . basename ( path ) #NEWLINE# if ( self . directory is None ) : #NEWLINE# #INDENT# self . directory = os . getcwd ( ) #NEWLINE# #UNINDENT# if ( basedir != self . directory ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# subdir = basedir . split ( self . directory ) [ 1 ] [ 1 : ] #NEWLINE# #UNINDENT# except IndexError as e : #NEWLINE# #INDENT# subdir = '' #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# subdir = '' #NEWLINE# #UNINDENT# if self . output_directory_override : #NEWLINE# #INDENT# output_directory = os . path . join ( self . directory , subdir , self . output_directory_override ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# outdir = os . path . join ( self . directory , subdir , ( '_' + basename ) ) #NEWLINE# output_directory = unique_file_name ( outdir , extension = 'extracted' ) #NEWLINE# #UNINDENT# if ( not os . path . exists ( output_directory ) ) : #NEWLINE# #INDENT# os . mkdir ( output_directory ) #NEWLINE# #UNINDENT# self . extraction_directories [ path ] = output_directory #NEWLINE# self . output [ path ] . directory = ( os . path . realpath ( output_directory ) + os . path . sep ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# output_directory = self . extraction_directories [ basename ] #NEWLINE# #UNINDENT# return output_directory