(env)
| 78 | |
| 79 | @contextmanager |
| 80 | def _temporary_folder(env): |
| 81 | base = env.temp_path |
| 82 | try: |
| 83 | os.makedirs(base) |
| 84 | except OSError: |
| 85 | pass |
| 86 | |
| 87 | folder = tempfile.mkdtemp(prefix=".deploytemp", dir=base) |
| 88 | scratch = os.path.join(folder, "scratch") |
| 89 | os.mkdir(scratch) |
| 90 | os.chmod(scratch, 0o755) |
| 91 | try: |
| 92 | yield scratch |
| 93 | finally: |
| 94 | try: |
| 95 | shutil.rmtree(folder) |
| 96 | except (IOError, OSError): |
| 97 | pass |
| 98 | |
| 99 | |
| 100 | class PublishError(LektorException): |