def METHOD_NAME(config, global_only):
    """Persists locally or globally configuration object.
    Global configuration is updated only when :global_only: is True,
    otherwise, updates are written to local project configuration
    """
    filepath = project_context.global_config_path if global_only else project_context.local_config_path
    if global_only:
        with global_config_write_lock():
            os.umask(0)
            fd = os.open(filepath, os.O_CREAT | os.O_RDWR | os.O_TRUNC, 0o600)
            write_config(fd, config)
    else:
        write_config(filepath, config)