File size: 1,783 Bytes
870b85a
 
 
3f15e9f
870b85a
 
 
 
 
3f15e9f
870b85a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Locations used by the asset curation tools.

Every location comes from an environment variable and there are no machine-specific defaults: an unset variable stops the script and
names the variable to set (see site.example.env). `S` is the root of this repository and needs no setting.
"""
import os
import sys
from pathlib import Path

S = str(Path(__file__).resolve().parents[2])        # tools/asset_curation/curation_paths.py -> repository root

VARIABLES = {
    'R': ('RHG_WORK_ROOT', 'working root that holds the retrieval, audit and release directories'),
    'W': ('RHG_CURATION_WORK', 'working directory of the curation run (releases, decisions, e2e runs)'),
    'A': ('RHG_ASSET_AUDIT', 'output directory of the asset audit'),
    'AUDIT_SCRIPTS': ('RHG_ASSET_AUDIT_SCRIPTS', 'helper scripts of the asset audit'),
    'L': ('RHG_RETRIEVAL_DIR', 'directory with the retrieval sqlite files'),
    'B': ('RHG_HSSD_ROOT', 'root of the HSSD asset library (contains semantics/ and scenes/)'),
    'PARENT_RELEASE': ('RHG_PARENT_RELEASE', 'attribute_releases.json that publish_art.py replaces'),
}


def __getattr__(name):
    """Resolve a location when it is first used, so a script only needs the variables it really reads."""
    if name in VARIABLES:
        variable, meaning = VARIABLES[name]
        value = os.environ.get(variable)
        if not value:
            raise SystemExit('%s is not set: %s. Set it (see tools/asset_curation/site.example.env).' % (variable, meaning))
        return value
    raise AttributeError(name)


def add_usd_site():
    """Put the directory with the `pxr` (usd-core) package on sys.path when RHG_USD_SITE names one."""
    site = os.environ.get('RHG_USD_SITE')
    if site and site not in sys.path:
        sys.path.insert(0, site)