Load the config value from various arguments.

def load_config(path):
    """Load the config value from various arguments."""
    config = ConfigParser()

    if len(config.read(path)) == 0:
        stderr_and_exit("Couldn't load config {0}\n".format(path))
    if not config.has_section('walls'):
        stderr_and_exit('Config missing [walls] section.\n')

    # Print out all of the missing keys
    keys = ['api_key', 'api_secret', 'tags', 'image_dir', 'width', 'height']
    for key in set(keys):
        if config.has_option('walls', key):
            keys.remove(key)
    if keys:
        stderr_and_exit("Missing config keys: '{0}'\n"
                        .format("', '".join(keys)))

    # Parse integer values
    int_keys = ['width', 'height']
    for key in set(int_keys):
        try:
            config.getint('walls', key)
            int_keys.remove(key)
        except ValueError:
            pass
    if int_keys:
        stderr_and_exit("The following must be integers: '{0}'\n"
                        .format("', '".join(int_keys)))

    # Check destination directory
    path = os.path.expanduser(config.get('walls', 'image_dir'))
    if not os.path.isdir(path):
        stderr_and_exit('The directory {0} does not exist.\n'
                        .format(config.get('walls', 'image_dir')))

    return config