def get_temp_copy(path): """Returns a copy of the file with the same extension""" ext = os.path.splitext(path)[-1] fd, filename = mkstemp(suffix=ext) os.close(fd) shutil.copy(path, filename) return filename
def get_temp_empty(ext=""): """Returns an empty file with the extension""" fd, filename = mkstemp(suffix=ext) os.close(fd) return filename