(
            self, config_file_path: Optional[Text] = '',
            section: Optional[Text] = 'timesketch',
            load_cli_config: Optional[bool] = False)
Load the config from file.

        Args:
            config_file_path (str): Full path to the configuration file,
                if not supplied the default path will be used, which is
                the file RC_FILENAME inside the user's home directory.
            section (str): The configuration section to read from. This
                is optional and defaults to timesketch. This can be
                useful if you have multiple Timesketch servers to connect to,
                with each one of them having a separate section in the config
                file.
            load_cli_config (bool): Determine if the CLI config section should
                be loaded. This is optional and defaults to False.

        Raises:
          IOError if the file does not exist or config does not load.
Load the config from file.
Load the config from file .
def load_config_file(
            self, config_file_path: Optional[Text] = '',
            section: Optional[Text] = 'timesketch',
            load_cli_config: Optional[bool] = False):
        """Load the config from file.

        Args:
            config_file_path (str): Full path to the configuration file,
                if not supplied the default path will be used, which is
                the file RC_FILENAME inside the user's home directory.
            section (str): The configuration section to read from. This
                is optional and defaults to timesketch. This can be
                useful if you have multiple Timesketch servers to connect to,
                with each one of them having a separate section in the config
                file.
            load_cli_config (bool): Determine if the CLI config section should
                be loaded. This is optional and defaults to False.

        Raises:
          IOError if the file does not exist or config does not load.
        """
        if config_file_path:
            if not os.path.isfile(config_file_path):
                error_msg = (
                    'Unable to load config file, file {0:s} does not '
                    'exist.').format(config_file_path)
                logger.error(error_msg)
                raise IOError(error_msg)
        else:
            home_path = os.path.expanduser('~')
            config_file_path = os.path.join(home_path, self.RC_FILENAME)

        if not os.path.isfile(config_file_path):
            fw = open(config_file_path, 'a')
            fw.close()

        config = configparser.ConfigParser()
        try:
            files_read = config.read([config_file_path])
        except configparser.MissingSectionHeaderError as exc:
            raise IOError(
                'Unable to parse config file') from exc

        if not files_read:
            logger.warning('No config read')
            return

        if not section:
            section = 'timesketch'

        if section not in config.sections():
            logger.warning('No %s section in the config', section)
            return

        timesketch_config = config[section]
        for name, value in timesketch_config.items():
            self.set_config(name, value)

        if load_cli_config:
            if 'cli' not in config.sections():
                # Set default CLI config section
                config['cli'] = {
                    'sketch': '',
                    'output_format': 'tabular'
                }

            cli_config = config['cli']
            for name, value in cli_config.items():
                self.set_config(name, value)
def load_config_file ( self , config_file_path : Optional [ Text ] = '' , section : Optional [ Text ] = 'timesketch' , load_cli_config : Optional [ bool ] = False ) : if config_file_path : if not os . path . isfile ( config_file_path ) : error_msg = ( 'Unable to load config file, file {0:s} does not ' 'exist.' ) . format ( config_file_path ) logger . error ( error_msg ) raise IOError ( error_msg ) else : home_path = os . path . expanduser ( '~' ) config_file_path = os . path . join ( home_path , self . RC_FILENAME ) if not os . path . isfile ( config_file_path ) : fw = open ( config_file_path , 'a' ) fw . close ( ) config = configparser . ConfigParser ( ) try : files_read = config . read ( [ config_file_path ] ) except configparser . MissingSectionHeaderError as exc : raise IOError ( 'Unable to parse config file' ) from exc if not files_read : logger . warning ( 'No config read' ) return if not section : section = 'timesketch' if section not in config . sections ( ) : logger . warning ( 'No %s section in the config' , section ) return timesketch_config = config [ section ] for name , value in timesketch_config . items ( ) : self . set_config ( name , value ) if load_cli_config : if 'cli' not in config . sections ( ) : # Set default CLI config section config [ 'cli' ] = { 'sketch' : '' , 'output_format' : 'tabular' } cli_config = config [ 'cli' ] for name , value in cli_config . items ( ) : self . set_config ( name , value )