def config_parse(files=None, config=None, config_profile="<STR_LIT>", **kwargs):
local_config = config<EOL>config = __fcconfig<EOL>cfgparser = configparser.SafeConfigParser()<EOL>filenames = list()<EOL>filenames.append(os.path.join(os.path.expanduser('<STR_LIT>'), config_profile))<EOL>filenames.append(os.path.join(os.getcwd(), config_profile))<EOL>if files:<EOL><INDENT>if isinstance(files, string_types):<EOL><INDENT>filenames.append(files)<EOL><DEDENT>elif isinstance(files, Iterable):<EOL><INDENT>for f in files:<EOL><INDENT>if isinstance(f, IOBase):<EOL><INDENT>f = f.name<EOL><DEDENT>filenames.append(f)<EOL><DEDENT><DEDENT><DEDENT>cfgparser.read(filenames)<EOL>for keyval in cfgparser.items('<STR_LIT>'):<EOL><INDENT>__fcconfig[keyval[<NUM_LIT:0>]] = keyval[<NUM_LIT:1>]<EOL><DEDENT>for section in cfgparser.sections():<EOL><INDENT>config[section] = attrdict()<EOL>for option in cfgparser.options(section):<EOL><INDENT>if not config[option]:<EOL><INDENT>config[section][option] = cfgparser.get(section, option)<EOL><DEDENT><DEDENT><DEDENT>config.verbosity = int(config.verbosity)<EOL>if not config.root_url.endswith('<STR_LIT:/>'):<EOL><INDENT>config.root_url += '<STR_LIT:/>'<EOL><DEDENT>if os.path.isfile(config.credentials):<EOL><INDENT>os.environ[environment_vars.CREDENTIALS] = config.credentials<EOL><DEDENT>if local_config is not None:<EOL><INDENT>for key, value in local_config.items():<EOL><INDENT>config[key] = value<EOL><DEDENT><DEDENT>for key, value in kwargs.items():<EOL><INDENT>config[key] = value<EOL><DEDENT>return config<EOL>
Read initial configuration state, from named config files; store
this state within a config dictionary (which may be nested) whose keys may
also be referenced as attributes (safely, defaulting to None if unset).  A
config object may be passed in, as a way of accumulating or overwriting
configuration state; if one is NOT passed, the default config obj is used