def _CreateConfigParserFromConfigFile(config_filename):
 if (not os.path.exists(config_filename)):
  raise StyleConfigError('"{0}" is not a valid style or file path'.format(config_filename))
 with open(config_filename) as style_file:
  config = py3compat.ConfigParser()
  config.read_file(style_file)
  if config_filename.endswith(SETUP_CONFIG):
   if (not config.has_section('yapf')):
    raise StyleConfigError('Unable to find section [yapf] in {0}'.format(config_filename))
  elif config_filename.endswith(LOCAL_STYLE):
   if (not config.has_section('style')):
    raise StyleConfigError('Unable to find section [style] in {0}'.format(config_filename))
  elif (not config.has_section('style')):
   raise StyleConfigError('Unable to find section [style] in {0}'.format(config_filename))
  return config

def _CreateConfigParserFromConfigFile ( config_filename ) : if ( not os . path . exists ( config_filename ) ) : raise StyleConfigError ( '"{0}" is not a valid style or file path' . format ( config_filename ) ) with open ( config_filename ) as style_file : config = py3compat . ConfigParser ( ) config . read_file ( style_file ) if config_filename . endswith ( SETUP_CONFIG ) : if ( not config . has_section ( 'yapf' ) ) : raise StyleConfigError ( 'Unable to find section [yapf] in {0}' . format ( config_filename ) ) elif config_filename . endswith ( LOCAL_STYLE ) : if ( not config . has_section ( 'style' ) ) : raise StyleConfigError ( 'Unable to find section [style] in {0}' . format ( config_filename ) ) elif ( not config . has_section ( 'style' ) ) : raise StyleConfigError ( 'Unable to find section [style] in {0}' . format ( config_filename ) ) return config
read the file and return a configparser object .