environment/lib/python2.7/site-packages/IPython/config/loader.py
def _read_file_as_dict(self):
        """Load the config file into self.config, with recursive loading."""
        # This closure is made available in the namespace that is used
        # to exec the config file.  It allows users to call
        # load_subconfig('myconfig.py') to load config files recursively.
        # It needs to be a closure because it has references to self.path
        # and self.config.  The sub-config is loaded with the same path
        # as the parent, but it uses an empty config which is then merged
        # with the parents.

        # If a profile is specified, the config file will be loaded
        # from that profile

        def load_subconfig(fname, profile=None):
            # import here to prevent circular imports
            from IPython.core.profiledir import ProfileDir, ProfileDirError
            if profile is not None:
                try:
                    profile_dir = ProfileDir.find_profile_dir_by_name(
                            get_ipython_dir(),
                            profile,
                    )
                except ProfileDirError:
                    return
                path = profile_dir.location
            else:
                path = self.path
            loader = PyFileConfigLoader(fname, path)
            try:
                sub_config = loader.load_config()
            except ConfigFileNotFound:
                # Pass silently if the sub config is not there. This happens
                # when a user s using a profile, but not the default config.
                pass
            else:
                self.config._merge(sub_config)

        # Again, this needs to be a closure and should be used in config
        # files to get the config being loaded.
        def get_config():
            return self.config

        namespace = dict(load_subconfig=load_subconfig, get_config=get_config)
        fs_encoding = sys.getfilesystemencoding() or 'ascii'
        conf_filename = self.full_filename.encode(fs_encoding)
        py3compat.execfile(conf_filename, namespace)
def _read_file_as_dict(self):
        """Load the config file into self.config, with recursive loading."""
        # This closure is made available in the namespace that is used
        # to exec the config file.  It allows users to call
        # load_subconfig('myconfig.py') to load config files recursively.
        # It needs to be a closure because it has references to self.path
        # and self.config.  The sub-config is loaded with the same path
        # as the parent, but it uses an empty config which is then merged
        # with the parents.

        # If a profile is specified, the config file will be loaded
        # from that profile

        def load_subconfig(fname, profile=None):
            # import here to prevent circular imports
            from IPython.core.profiledir import ProfileDir, ProfileDirError
            if profile is not None:
                try:
                    profile_dir = ProfileDir.find_profile_dir_by_name(
                            get_ipython_dir(),
                            profile,
                    )
                except ProfileDirError:
                    return
                path = profile_dir.location
            else:
                path = self.path
            loader = PyFileConfigLoader(fname, path)
            try:
                sub_config = loader.load_config()
            except ConfigFileNotFound:
                # Pass silently if the sub config is not there. This happens
                # when a user s using a profile, but not the default config.
                pass
            else:
                self.config._merge(sub_config)

        # Again, this needs to be a closure and should be used in config
        # files to get the config being loaded.
        def get_config():
            return self.config

        namespace = dict(load_subconfig=load_subconfig, get_config=get_config)
        fs_encoding = sys.getfilesystemencoding() or 'ascii'
        conf_filename = self.full_filename.encode(fs_encoding)
        py3compat.execfile(conf_filename, namespace)
def _read_file_as_dict ( self ) : # This closure is made available in the namespace that is used # to exec the config file.  It allows users to call # load_subconfig('myconfig.py') to load config files recursively. # It needs to be a closure because it has references to self.path # and self.config.  The sub-config is loaded with the same path # as the parent, but it uses an empty config which is then merged # with the parents. # If a profile is specified, the config file will be loaded # from that profile def load_subconfig ( fname , profile = None ) : # import here to prevent circular imports from IPython . core . profiledir import ProfileDir , ProfileDirError if profile is not None : try : profile_dir = ProfileDir . find_profile_dir_by_name ( get_ipython_dir ( ) , profile , ) except ProfileDirError : return path = profile_dir . location else : path = self . path loader = PyFileConfigLoader ( fname , path ) try : sub_config = loader . load_config ( ) except ConfigFileNotFound : # Pass silently if the sub config is not there. This happens # when a user s using a profile, but not the default config. pass else : self . config . _merge ( sub_config ) # Again, this needs to be a closure and should be used in config # files to get the config being loaded. def get_config ( ) : return self . config namespace = dict ( load_subconfig = load_subconfig , get_config = get_config ) fs_encoding = sys . getfilesystemencoding ( ) or 'ascii' conf_filename = self . full_filename . encode ( fs_encoding ) py3compat . execfile ( conf_filename , namespace )
Load the config file into self.config, with recursive loading.
Load the config file into self . config with recursive loading .