original_docstring: Finds Turbinia config file and loads it.
  
    Args:
      config_file(str): full path to config file
    
docstring: Finds Turbinia config file and loads it.
docstring_tokens: Finds Turbinia config file and loads it .
code: def LoadConfig(config_file=None):
    """Finds Turbinia config file and loads it.
  
    Args:
      config_file(str): full path to config file
    """
    # TODO(aarontp): Find way to not require global var here.  Maybe a singleton
    # pattern on the config class.
    # pylint: disable=global-statement
    global CONFIG
    if CONFIG and not config_file:
      log.debug(
          'Returning cached config from {0:s} instead of reloading config'.format(
              CONFIG.configSource))
      return CONFIG
  
    if not config_file:
      log.debug('No config specified. Looking in default locations for config.')
      # If the environment variable is set, take precedence over the pre-defined
      # CONFIGPATHs.
      configpath = CONFIGPATH
      if ENVCONFIGVAR in os.environ:
        configpath = os.environ[ENVCONFIGVAR].split(':')
  
      # Load first file found
      for _dir, _file in itertools.product(configpath, CONFIGFILES):
        if os.path.exists(os.path.join(_dir, _file)):
          config_file = os.path.join(_dir, _file)
          break
  
    if config_file is None:
      raise TurbiniaException('No config files found')
  
    log.debug('Loading config from {0:s}'.format(config_file))
    # Warn about using fallback source config, but it's currently necessary for
    # tests. See issue #446.
    if 'turbinia_config_tmpl' in config_file:
      log.warning('Using fallback source config. {0:s}'.format(CONFIG_MSG))
    try:
      _config = imp.load_source('config', config_file)
    except IOError as exception:
      message = (
          'Could not load config file {0:s}: {1!s}'.format(
              config_file, exception))
      log.error(message)
      raise TurbiniaException(message)
  
    _config.configSource = config_file
    ValidateAndSetConfig(_config)
  
    # Set the environment var for this so that we don't see the "No project ID
    # could be determined." warning later.
    if hasattr(_config, 'TURBINIA_PROJECT') and _config.TURBINIA_PROJECT:
      os.environ['GOOGLE_CLOUD_PROJECT'] = _config.TURBINIA_PROJECT
  
    CONFIG = _config
    log.debug(
        'Returning parsed config loaded from {0:s}'.format(CONFIG.configSource))
    return _config
code_tokens: def LoadConfig ( config_file = None ) : global CONFIG if CONFIG and not config_file : log . debug ( 'Returning cached config from {0:s} instead of reloading config' . format ( CONFIG . configSource ) ) return CONFIG if not config_file : log . debug ( 'No config specified. Looking in default locations for config.' ) configpath = CONFIGPATH if ENVCONFIGVAR in os . environ : configpath = os . environ [ ENVCONFIGVAR ] . split ( ':' ) for _dir , _file in itertools . product ( configpath , CONFIGFILES ) : if os . path . exists ( os . path . join ( _dir , _file ) ) : config_file = os . path . join ( _dir , _file ) break if config_file is None : raise TurbiniaException ( 'No config files found' ) log . debug ( 'Loading config from {0:s}' . format ( config_file ) ) if 'turbinia_config_tmpl' in config_file : log . warning ( 'Using fallback source config. {0:s}' . format ( CONFIG_MSG ) ) try : _config = imp . load_source ( 'config' , config_file ) except IOError as exception : message = ( 'Could not load config file {0:s}: {1!s}' . format ( config_file , exception ) ) log . error ( message ) raise TurbiniaException ( message ) _config . configSource = config_file ValidateAndSetConfig ( _config ) if hasattr ( _config , 'TURBINIA_PROJECT' ) and _config . TURBINIA_PROJECT : os . environ [ 'GOOGLE_CLOUD_PROJECT' ] = _config . TURBINIA_PROJECT CONFIG = _config log . debug ( 'Returning parsed config loaded from {0:s}' . format ( CONFIG . configSource ) ) return _config
short_docstring: Finds Turbinia config file and loads it.
short_docstring_tokens: Finds Turbinia config file and loads it .
comment: """Finds Turbinia config file and loads it.
  
    Args:
      config_file(str): full path to config file
    """$SEP$# TODO(aarontp): Find way to not require global var here.  Maybe a singleton$SEP$# pattern on the config class.$SEP$# pylint: disable=global-statement$SEP$# If the environment variable is set, take precedence over the pre-defined$SEP$# CONFIGPATHs.$SEP$# Load first file found$SEP$# Warn about using fallback source config, but it's currently necessary for$SEP$# tests. See issue #446.$SEP$# Set the environment var for this so that we don't see the "No project ID$SEP$# could be determined." warning later.