def create_default_config(self):
        """Write default config file to disk.

        Backs up existing configuration file.

        Returns
        -------
        filename : string
            Path to config file.
        """
        filename = self.config_file.as_posix()
        logger.info("Creating default config file: %s", filename)
        config_dir = self.config_file.parent
        if not config_dir.exists():
            config_dir.mkdir(parents=True)
        if self.config_file.is_file():
            backup = filename + ".old"
            logger.info("Saving config file backup at: %s", backup)
            shutil.copy(filename, backup)
        with open(self.config_file, mode="w") as f:
            config_string = CONFIG_TEMPLATE.format(
                data_dir=self.default_config["data dir"],
                linewrap=self.default_config["linewrap"],
                colors=self.default_config["colors"],
                browser=self.default_config["web browser"],
            )
            f.write(config_string)
        return filename
def create_default_config ( self ) : filename = self . config_file . as_posix ( ) logger . info ( "Creating default config file: %s" , filename ) config_dir = self . config_file . parent if not config_dir . exists ( ) : config_dir . mkdir ( parents = True ) if self . config_file . is_file ( ) : backup = filename + ".old" logger . info ( "Saving config file backup at: %s" , backup ) shutil . copy ( filename , backup ) with open ( self . config_file , mode = "w" ) as f : config_string = CONFIG_TEMPLATE . format ( data_dir = self . default_config [ "data dir" ] , linewrap = self . default_config [ "linewrap" ] , colors = self . default_config [ "colors" ] , browser = self . default_config [ "web browser" ] , ) f . write ( config_string ) return filename
Write default config file to disk.

        Backs up existing configuration file.

        Returns
        -------
        filename : string
            Path to config file.