示例#1
0
 def __init__(self):
     self.libdir = libdir  # noqa
     self.dataloc = _path_join(self.libdir, 'python-lib.bypy.frozen')
     self.filesystem_tree, self.extensions_map = marshal.loads(
         initialize_data_access(self.dataloc))
     self.develop_mode_path = None
     dv = getenv(DEVELOP_MODE_ENV_VAR) if DEVELOP_MODE_ENV_VAR else None
     if dv and _path_isdir(dv):
         self.develop_mode_path = abspath(dv)
示例#2
0
 def __init__(self):
     self.libdir = libdir  # noqa
     self.dataloc = _path_join(self.libdir, 'python-lib.bypy.frozen')
     self.filesystem_tree, self.extensions_map = marshal.loads(
         initialize_data_access(self.dataloc))
     self.develop_mode_path = None
     if PATH_TO_USER_ENV_VARS:
         try:
             read_user_env_vars()
         except Exception as err:
             print(
                 'Failed to read environment variables from:',
                 PATH_TO_USER_ENV_VARS, 'with error:', str(err))
     dv = getenv(DEVELOP_MODE_ENV_VAR) if DEVELOP_MODE_ENV_VAR else None
     if dv and _path_isdir(dv):
         self.develop_mode_path = abspath(dv)
示例#3
0
def unix_expandvars(text):
    ans = []
    allowed_chars = \
        'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'

    while text:
        idx = text.find('$')
        if idx == -1:
            ans.append(text)
            break
        if len(text) == idx + 1:
            ans.append(text)
            break
        ans.append(text[:idx])
        text = text[idx:]
        extent = 0
        if text.startswith('${'):
            close_idx = text.find('}')
            if close_idx > 1:
                extent = close_idx
        else:
            for i, c in enumerate(text):
                if i == 0:
                    continue
                if c not in allowed_chars:
                    extent = i - 1
                    break
            else:
                if not extent and i > 0:
                    extent = i
        if extent:
            var = text[1:extent+1]
            if var.startswith('{'):
                var = var[1:-1]
            val = getenv(var) or text[:extent+1]
            ans.append(val)
            text = text[extent+1:]
        else:
            ans.append('$')
            text = text[1:]

    return ''.join(ans)