File: decorators.py

package info (click to toggle)
python-moderngl-window 3.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 69,096 kB
  • sloc: python: 12,076; makefile: 21
file content (17 lines) | stat: -rw-r--r-- 518 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from contextlib import contextmanager
from pathlib import Path
from typing import Generator, Union

from moderngl_window.conf import settings


@contextmanager
def texture_dirs(paths: list[Union[Path, str]]) -> Generator[None, None, None]:
    """Context manager temporarily replacing texture paths
    Args:
        paths (list[Union[Path, str]]): list of paths
    """
    original_dirs = settings.DATA_DIRS
    settings.TEXTURE_DIRS = paths
    yield None
    settings.TEXTURE_DIRS = original_dirs