예제 #1
0
파일: config.py 프로젝트: opcg/rez
def _load_config_py(filepath):
    from rez.vendor.six.six import exec_

    reserved = dict(
        # Standard Python module variables
        # Made available from within the module,
        # and later excluded from the `Config` class
        __name__=os.path.splitext(os.path.basename(filepath))[0],
        __file__=filepath,
        rez_version=__version__,
        ModifyList=ModifyList)

    globs = reserved.copy()
    result = {}

    with open(filepath) as f:
        try:
            code = compile(f.read(), filepath, 'exec')
            exec_(code, globs)
        except Exception as e:
            raise ConfigurationError(
                "Error loading configuration from %s: %s" % (filepath, str(e)))

    for k, v in globs.items():
        if k != '__builtins__' \
                and not ismodule(v) \
                and k not in reserved:
            result[k] = v

    return result
예제 #2
0
파일: config.py 프로젝트: sonictk/rez
def _load_config_py(filepath):
    from rez.vendor.six.six import exec_

    globs = dict(rez_version=__version__)
    result = {}

    with open(filepath) as f:
        try:
            code = compile(f.read(), filepath, "exec")
            exec_(code, _globs_=globs)
        except Exception, e:
            raise ConfigurationError("Error loading configuration from %s: %s" % (filepath, str(e)))
예제 #3
0
파일: config.py 프로젝트: sonictk/rez
def _load_config_py(filepath):
    from rez.vendor.six.six import exec_

    globs = dict(rez_version=__version__)
    result = {}

    with open(filepath) as f:
        try:
            code = compile(f.read(), filepath, 'exec')
            exec_(code, _globs_=globs)
        except Exception, e:
            raise ConfigurationError(
                "Error loading configuration from %s: %s" % (filepath, str(e)))