File: assets.py

package info (click to toggle)
pytorch-text 0.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 11,560 kB
  • sloc: python: 14,197; cpp: 2,404; sh: 214; makefile: 20
file content (19 lines) | stat: -rw-r--r-- 472 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import glob
import os
import shutil
from pathlib import Path

_ASSET_DIR = (Path(__file__).parent.parent / "asset").resolve()


def get_asset_path(*path_components):
    """Get the path to the file under `test/assets` directory."""
    return str(_ASSET_DIR.joinpath(*path_components))


def conditional_remove(f):
    for path in glob.glob(f):
        if os.path.isfile(path):
            os.remove(path)
        elif os.path.isdir(path):
            shutil.rmtree(path)