#NEWLINE# def __init__( self , profile_directory = None ) : #NEWLINE# #INDENT# '\n        Initialises a new instance of a Firefox Profile\n\n        :args:\n         - profile_directory: Directory of profile that you want to use.\n           This defaults to None and will create a new\n           directory when object is created.\n        ' #NEWLINE# if ( not FirefoxProfile . DEFAULT_PREFERENCES ) : #NEWLINE# #INDENT# with open ( os . path . join ( os . path . dirname ( __file__ ) , WEBDRIVER_PREFERENCES ) ) as default_prefs : #NEWLINE# #INDENT# FirefoxProfile . DEFAULT_PREFERENCES = json . load ( default_prefs ) #NEWLINE# #UNINDENT# #UNINDENT# self . default_preferences = copy . deepcopy ( FirefoxProfile . DEFAULT_PREFERENCES [ 'mutable' ] ) #NEWLINE# self . native_events_enabled = True #NEWLINE# self . profile_dir = profile_directory #NEWLINE# self . tempfolder = None #NEWLINE# if ( self . profile_dir is None ) : #NEWLINE# #INDENT# self . profile_dir = self . _create_tempfolder ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . tempfolder = tempfile . mkdtemp ( ) #NEWLINE# newprof = os . path . join ( self . tempfolder , 'webdriver-py-profilecopy' ) #NEWLINE# shutil . copytree ( self . profile_dir , newprof , ignore = shutil . ignore_patterns ( 'parent.lock' , 'lock' , '.parentlock' ) ) #NEWLINE# self . profile_dir = newprof #NEWLINE# self . _read_existing_userjs ( os . path . join ( self . profile_dir , 'user.js' ) ) #NEWLINE# #UNINDENT# self . extensionsDir = os . path . join ( self . profile_dir , 'extensions' ) #NEWLINE# self . userPrefs = os . path . join ( profile_directory . profile_dir , 'user.js' )