File: util.py

package info (click to toggle)
dart 6.13.2%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 56,948 kB
  • sloc: cpp: 274,310; python: 3,973; xml: 1,272; sh: 404; makefile: 31
file content (18 lines) | stat: -rw-r--r-- 472 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import inspect
import os
import os.path


def get_path_to_this_file():
    return inspect.getfile(inspect.currentframe())


def get_asset_path(rel_path, check_existing=False):
    if rel_path.startswith("/"):
        full_path = rel_path
    else:
        full_path = os.path.join(os.path.dirname(__file__), "../../data/", rel_path)
    if check_existing and not os.path.exists(full_path):
        raise IOError("File %s does not exist" % full_path)

    return full_path