def find_good_temp_dir(candidate_temp_dirs):
    """
    Given a list of candidate temp directories extracted from ``ansible.cfg``,
    combine it with the Python-builtin list of candidate directories used by
    :mod:`tempfile`, then iteratively try each until one is found that is both
    writeable and executable.

    :param list candidate_temp_dirs:
        List of candidate $variable-expanded and tilde-expanded directory paths
        that may be usable as a temporary directory.
    """
    paths = [os.path.expandvars(os.path.expanduser(p))
             for p in candidate_temp_dirs]
    paths.extend(tempfile._candidate_tempdir_list())

    for path in paths:
        if is_good_temp_dir(path):
            LOG.debug('Selected temp directory: %r (from %r)', path, paths)
            return path

    raise IOError(MAKE_TEMP_FAILED_MSG % {
        'paths': '\n    '.join(paths),
    })
def find_good_temp_dir ( candidate_temp_dirs ) : paths = [ os . path . expandvars ( os . path . expanduser ( p ) ) for p in candidate_temp_dirs ] paths . extend ( tempfile . _candidate_tempdir_list ( ) ) for path in paths : if is_good_temp_dir ( path ) : LOG . debug ( 'Selected temp directory: %r (from %r)' , path , paths ) return path raise IOError ( MAKE_TEMP_FAILED_MSG % { 'paths' : '\n    ' . join ( paths ) , } )
Given a list of candidate temp directories extracted from ``ansible.cfg``,
    combine it with the Python-builtin list of candidate directories used by
    :mod:`tempfile`, then iteratively try each until one is found that is both
    writeable and executable.

    :param list candidate_temp_dirs:
        List of candidate $variable-expanded and tilde-expanded directory paths
        that may be usable as a temporary directory.