def _read_config(self):
        """
        returns the config as a dict.
        """
        default_config_filepath = Path2(os.path.dirname(__file__), DEAFULT_CONFIG_FILENAME)
        log.debug("Read defaults from: '%s'" % default_config_filepath)
        if not default_config_filepath.is_file():
            raise RuntimeError(
                "Internal error: Can't locate the default .ini file here: '%s'" % default_config_filepath
            )
        config = self._read_and_convert(default_config_filepath, all_values=True)
        log.debug("Defaults: %s", pprint.pformat(config))

        self.ini_filepath = get_ini_filepath()
        if not self.ini_filepath:
            # No .ini file made by user found
            # -> Create one into user home
            self.ini_filepath = get_user_ini_filepath()

            # We don't use shutil.copyfile here, so the line endings will
            # be converted e.g. under windows from \n to \n\r
            with default_config_filepath.open("r") as infile:
                with self.ini_filepath.open("w") as outfile:
                    outfile.write(infile.read())

            print("\n*************************************************************")
            print("Default config file was created into your home:")
            print("\t%s" % self.ini_filepath)
            print("Change it for your needs ;)")
            print("*************************************************************\n")
        else:
            print("\nread user configuration from:")
            print("\t%s\n" % self.ini_filepath)
            config.update(self._read_and_convert(self.ini_filepath, all_values=False))
            log.debug("RawConfig changed to: %s", pprint.pformat(config))

        return config
def _read_config ( self ) : default_config_filepath = Path2 ( os . path . dirname ( __file__ ) , DEAFULT_CONFIG_FILENAME ) log . debug ( "Read defaults from: '%s'" % default_config_filepath ) if not default_config_filepath . is_file ( ) : raise RuntimeError ( "Internal error: Can't locate the default .ini file here: '%s'" % default_config_filepath ) config = self . _read_and_convert ( default_config_filepath , all_values = True ) log . debug ( "Defaults: %s" , pprint . pformat ( config ) ) self . ini_filepath = get_ini_filepath ( ) if not self . ini_filepath : self . ini_filepath = get_user_ini_filepath ( ) with default_config_filepath . open ( "r" ) as infile : with self . ini_filepath . open ( "w" ) as outfile : outfile . write ( infile . read ( ) ) print ( "\n*************************************************************" ) print ( "Default config file was created into your home:" ) print ( "\t%s" % self . ini_filepath ) print ( "Change it for your needs ;)" ) print ( "*************************************************************\n" ) else : print ( "\nread user configuration from:" ) print ( "\t%s\n" % self . ini_filepath ) config . update ( self . _read_and_convert ( self . ini_filepath , all_values = False ) ) log . debug ( "RawConfig changed to: %s" , pprint . pformat ( config ) ) return config
returns the config as a dict.