Gets priority pairs from env.
481824
def _priority_from_env(self, val):
        """"""
        for part in val.split(':'):
            try:
                rule, priority = part.split('=')
                yield rule, int(priority)
            except ValueError:
                continue
300891
def file_envs(self, load=None):
        '''
        
        '''
        if load is None:
            load = {}
        load.pop('cmd', None)
        return self.envs(**load)
1290790
def _settings_from_env(self):
        """"""
        return {attr: self._val_from_env(env, attr)
                for env, attr in const.ENV_TO_ATTR.items()
                if env in os.environ}
206953
def list_commands(self, ctx):
        """"""
        env = ctx.ensure_object(environment.Environment)
        env.load()

        return sorted(env.list_commands(*self.path))
306124
def get_envs(self, log=True):
        """"""
        if log:
            logger.debug('')
#        return self._call_and_parse(['info', '--json'],
#                                    callback=lambda o, e: o['envs'])
        envs = os.listdir(os.sep.join([self.ROOT_PREFIX, 'envs']))
        envs = [os.sep.join([self.ROOT_PREFIX, 'envs', i]) for i in envs]

        valid_envs = [e for e in envs if os.path.isdir(e) and
                      self.environment_exists(prefix=e)]

        return valid_envs
843947
def detect_envlist(ini):
    """"""
    # Find the envs that tox knows about
    declared_envs = get_declared_envs(ini)

    # Find all the envs for all the desired factors given
    desired_factors = get_desired_factors(ini)

    # Reduce desired factors
    desired_envs = ['-'.join(env) for env in product(*desired_factors)]

    # Find matching envs
    return match_envs(declared_envs, desired_envs,
                      passthru=len(desired_factors) == 1)
808535
def _with_env(self, env):
        """"""
        res = self._browse(env, self._ids)
        return res
1292043
def get_all_kernel_specs_for_envs(self):
        """"""

        data = self._get_env_data()
        return {name: data[name][1] for name in data}
821478
def _get_envs(self):
        '''
        
        '''
        envs = set(['base'])
        if 'pillar_roots' in self.opts:
            envs.update(list(self.opts['pillar_roots']))
        return envs
754277
def _parse_service_env_vars(self, env_vars):
        
        env = {}
        for var in env_vars:
            # Yeah yeah.. it's less performant.. splitting twice.. who cares.
            k, v = var.split('=')
            env.update({k: v})
        return env
599248
def get_environment_paths(config, env):
    
    if env is None:
        return config.get(Config.DEFAULTS, 'environment')

    # Config option takes precedence over environment key.
    if config.has_option(Config.ENVIRONMENTS, env):
        env = config.get(Config.ENVIRONMENTS, env).replace(' ', '').split(';')
    else:
        env = os.getenv(env)
        if env:
            env = env.split(os.pathsep)
    return [i for i in env if i]
919435
def get_environment(self, environment_ids):
        

        uri = 'api/v3/environment/%s/' % environment_ids

        return super(ApiEnvironment, self).get(uri)
374790
def load_env(keys=[], name='NT', use_getpass=False):
    
    NT = namedtuple(name, keys)
    if use_getpass:
        values = [os.getenv(x) or getpass.getpass(x) for x in keys]
    else:
        values = [os.getenv(x) or input(x) for x in keys]
    return NT(*values)
545590
def env_vars(self):
        """"""
        if not self.no_libfaketime:
            faketime_filename = self.service_group.hitch_dir.faketime()

            env_vars = dict(os.environ)
            env_vars.update(self._env_vars)
            env_vars.update(faketime.get_environment_vars(faketime_filename))
        else:
            env_vars = dict(os.environ)
            env_vars.update(self._env_vars)
        return env_vars
599760
def _get_sorted(self, resources):
        
        tmp = []
        for resource in resources:
            path = resource._path
            # Each slash counts as 10 priority, each variable takes one away
            priority = path.count('/') * 10 - path.count('{')
            tmp.append((priority, resource))
        return [resource for prio, resource in reversed(sorted(tmp))]
155757
def env(*vars, **kwargs):
    
    for v in vars:
        value = os.environ.get(v)
        if value:
            return value
    return kwargs.get('default', '')
497561
def get_priority_rules(db) -> Iterable[PriorityRule]:
    """"""
    cur = db.cursor()
    cur.execute('SELECT id, regexp, priority FROM file_priority')
    for row in cur:
        yield PriorityRule(*row)