code: def _writable_sample_file(file, warn=True, wfun=None):
      
      if wfun is None:
          wfun = lambda x, y: '"{}" is not writable; use "{}" instead'.format(x, y)
      dir = os.path.dirname(file)
      dir = os.getcwd() if dir == '' else dir
      if os.access(dir, os.W_OK):
          return file
      else:
          dir2 = tempfile.mkdtemp()
          if warn:
              logger.warning(wfun(dir, dir2))
          return os.path.join(dir2, os.path.basename(file))
docs: Check to see if file is writable, if not use temporary file