def load_config(app_name, *args, **kwargs):
configure_logging()<EOL>prefix = kwargs.get('<STR_LIT>', '<STR_LIT>')<EOL>verbose = kwargs.get('<STR_LIT>', False)<EOL>location = kwargs.get('<STR_LIT:location>', None)<EOL>passphrase = kwargs.get('<STR_LIT>',<EOL>os.getenv("<STR_LIT>" % app_name.upper(),<EOL>os.getenv("<STR_LIT>", None)))<EOL>confnames = args<EOL>if not location:<EOL><INDENT>location = os.getenv("<STR_LIT>" % app_name.upper(), None)<EOL><DEDENT>if not location:<EOL><INDENT>location = os.getenv("<STR_LIT>", None)<EOL>if location:<EOL><INDENT>location = "<STR_LIT>" % (location, app_name)<EOL><DEDENT><DEDENT>config = {}<EOL>for confname in confnames:<EOL><INDENT>content = None<EOL>if location and location.startswith('<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>import boto<EOL>_, bucket_name, prefix = urlparse(location)[:<NUM_LIT:3>]<EOL>try:<EOL><INDENT>conn = boto.connect_s3()<EOL>bucket = conn.get_bucket(bucket_name)<EOL>key_name = '<STR_LIT>' % (prefix, confname)<EOL>key = bucket.get_key(key_name)<EOL>content = key.get_contents_as_string()<EOL>if verbose:<EOL><INDENT>LOGGER.info("<STR_LIT>",<EOL>bucket_name, key_name)<EOL><DEDENT><DEDENT>except (boto.exception.NoAuthHandlerFound,<EOL>boto.exception.S3ResponseError) as _:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>except ImportError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if not content:<EOL><INDENT>confpath = locate_config(<EOL>confname, app_name, location=location,<EOL>prefix=prefix, verbose=verbose)<EOL>if confpath:<EOL><INDENT>with open(confpath, '<STR_LIT:rb>') as conffile:<EOL><INDENT>content = conffile.read()<EOL><DEDENT><DEDENT><DEDENT>if content:<EOL><INDENT>if passphrase:<EOL><INDENT>content = crypt.decrypt(content, passphrase)<EOL><DEDENT>if hasattr(content, '<STR_LIT>'):<EOL><INDENT>content = content.decode('<STR_LIT:utf-8>')<EOL><DEDENT>for line in content.split('<STR_LIT:\n>'):<EOL><INDENT>if not line.startswith('<STR_LIT:#>'):<EOL><INDENT>look = re.match(r'<STR_LIT>', line)<EOL>if look:<EOL><INDENT>try:<EOL><INDENT>config.update({look.group(<NUM_LIT:1>).upper():<EOL>eval(look.group(<NUM_LIT:2>), {}, {})})<EOL><DEDENT>except Exception:<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return config<EOL>
Given a path to a file, parse its lines in ini-like format, and then
set them in the current namespace.

Quiet by default. Set verbose to True to see the absolute path to the config
files printed on stderr.