def getConfig(filepath=None):  
parser = configparser.ConfigParser()<EOL>filepaths = []<EOL>home = os.getenv("<STR_LIT>")<EOL>if home:<EOL><INDENT>default_filepath = os.path.join(home, "<STR_LIT>")<EOL>if os.path.isfile(default_filepath):<EOL><INDENT>filepaths.append(default_filepath)<EOL><DEDENT><DEDENT>env_filepath = os.getenv("<STR_LIT>")<EOL>if env_filepath and os.path.isfile(env_filepath):<EOL><INDENT>filepaths.append(env_filepath)<EOL><DEDENT>for cfg_file in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>cwd_filepath = os.path.join(os.getcwd(), cfg_file)<EOL>if os.path.isfile(cwd_filepath):<EOL><INDENT>filepaths.append(cwd_filepath)<EOL><DEDENT><DEDENT>if filepath and os.path.isfile(filepath):<EOL><INDENT>filepaths.append(filepath)<EOL><DEDENT>if filepaths:<EOL><INDENT>global files_loaded<EOL>files_loaded = filepaths<EOL>read_func = getattr(parser, '<STR_LIT>', getattr(parser, '<STR_LIT>'))<EOL>for filepath in filepaths:<EOL><INDENT>if filepath.endswith('<STR_LIT>'):<EOL><INDENT>with open(filepath) as f:<EOL><INDENT>read_func(f)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>read_func(ConfigFile(filepath))<EOL><DEDENT><DEDENT><DEDENT>return parser<EOL>
Get the Green config file settings.

All available config files are read.  If settings are in multiple configs,
the last value encountered wins.  Values specified on the command-line take
precedence over all config file settings.

Returns: A ConfigParser object.