def save(self, filename=None):
        """ Saves the runtime configuration to disk.

        Parameters
        ----------
        filename: str or None, default=None
            writeable path to configuration filename.
            If None, use default location and filename.
        """
        if not filename:
            filename = self.DEFAULT_CONFIG_FILE_NAME
        else:
            filename = str(filename)
            # try to extract the path from filename and use is as cfg_dir
            head, tail = os.path.split(filename)
            if head:
                self._cfg_dir = head

            # we are search for .cfg files in cfg_dir so make sure it contains the proper extension.
            base, ext = os.path.splitext(tail)
            if ext != ".cfg":
                filename += ".cfg"

        # if we have no cfg dir, try to create it first. Return if it failed.
        if not self.cfg_dir or not os.path.isdir(self.cfg_dir) or not os.stat(self.cfg_dir) != os.W_OK:
            try:
                self.cfg_dir = self.DEFAULT_CONFIG_DIR
            except ConfigDirectoryException as cde:

                print(Config._format_msg('Could not create configuration directory "{dir}"! config.save() failed.'
                                          ' Please set a writeable location with config.cfg_dir = val. Error was {exc}'
                                          .format(dir=self.cfg_dir, exc=cde)))
                return

        filename = os.path.join(self.cfg_dir, filename)

        try:
            with open(filename, 'w') as fh:
                self._conf_values.write(fh)
        except IOError as ioe:
            print(Config._format_msg("Save failed with error %s" % ioe))
def save ( self , filename = None ) : if not filename : filename = self . DEFAULT_CONFIG_FILE_NAME else : filename = str ( filename ) head , tail = os . path . split ( filename ) if head : self . _cfg_dir = head base , ext = os . path . splitext ( tail ) if ext != ".cfg" : filename += ".cfg" if not self . cfg_dir or not os . path . isdir ( self . cfg_dir ) or not os . stat ( self . cfg_dir ) != os . W_OK : try : self . cfg_dir = self . DEFAULT_CONFIG_DIR except ConfigDirectoryException as cde : print ( Config . _format_msg ( 'Could not create configuration directory "{dir}"! config.save() failed.' ' Please set a writeable location with config.cfg_dir = val. Error was {exc}' . format ( dir = self . cfg_dir , exc = cde ) ) ) return filename = os . path . join ( self . cfg_dir , filename ) try : with open ( filename , 'w' ) as fh : self . _conf_values . write ( fh ) except IOError as ioe : print ( Config . _format_msg ( "Save failed with error %s" % ioe ) )
Saves the runtime configuration to disk.

        Parameters
        ----------
        filename: str or None, default=None
            writeable path to configuration filename.
            If None, use default location and filename.