Dump current environment as a dictionary

    Arguments:
        context (dict, optional): Current context, defaults
            to the current environment.
554588
def dump(context=os.environ):
    

    output = {}
    for key, value in context.iteritems():
        if not key.startswith("BE_"):
            continue
        output[key[3:].lower()] = value

    return output
464291
def dumps(self, with_defaults=False):
        
        return self._rw.dump_config_to_string(self._config, with_defaults=with_defaults)
1230345
def initialize_env(env_file=None, fail_silently=True, load_globally=True):
    
    data = {}
    data.update(os.environ)
    if env_file:
        data.update(read_file_values(env_file, fail_silently))
    
    if load_globally:
        os.environ.update(data)
    
    return Environment(env_dict=data)
155757
def env(*vars, **kwargs):
    
    for v in vars:
        value = os.environ.get(v)
        if value:
            return value
    return kwargs.get('default', '')
1000260
def bind(self, environment):
        """"""
        rv = object.__new__(self.__class__)
        rv.__dict__.update(self.__dict__)
        rv.environment = environment
        return rv
252373
def _at_dump_context(self, calculator, rule, scope, block):
        
        sys.stderr.write("%s\n" % repr(rule.namespace._variables))
559692
def get_input(context, conf):
    
    name = conf['name']['value']
    prompt = conf['prompt']['value']
    default = conf['default']['value'] or conf['debug']['value']

    if context.submodule or context.inputs:
        value = context.inputs.get(name, default)
    elif not context.test:
        # we skip user interaction during tests
        raw = raw_input("%s (default=%s) " % (encode(prompt), encode(default)))
        value = raw or default
    else:
        value = default

    return value
280247
def main(context, no_color):
    
    if context.obj is None:
        context.obj = {}
    context.obj['no_color'] = no_color
19689
def config(env=DEFAULT_ENV, default=None, **overrides):
    """"""

    config = {}

    s = os.environ.get(env, default)

    if s:
        config = parse(s)

    overrides = dict([(k.upper(), v) for k, v in overrides.items()])

    config.update(overrides)

    return config
408584
def add_environment(self, environ):
        
        if isinstance(environ, dict):
            self._environment.update(environ)
1070424
def save_context(context):
    """"""
    file_path = _get_context_filepath()
    content = format_to_http_prompt(context, excluded_options=EXCLUDED_OPTIONS)
    with io.open(file_path, 'w', encoding='utf-8') as f:
        f.write(content)
827650
def inject_context(self, __context_dict__=None, **context):
        
        context = context or __context_dict__
        self.context_keys |= set(context.keys())
        for key, value in context.items():
            setattr(self, key, value)
        for command in self.subcommands.values():
            command.inject_context(context)
538352
def _copy_context_into_mutable(context):
    
    def make_mutable(val):
        if isinstance(val, Mapping):
            return dict(val)
        else:
            return val

    if not isinstance(context, (str, Mapping)):
        try:
            return [make_mutable(val) for val in context]
        except TypeError:
            pass
    return make_mutable(context)
424029
def _get_build_env(env):
    '''
    
    '''
    env_override = ''
    if env is None:
        return env_override
    if not isinstance(env, dict):
        raise SaltInvocationError(
            '\'env\' must be a Python dictionary'
        )
    for key, value in env.items():
        env_override += '{0}={1}\n'.format(key, value)
        env_override += 'export {0}\n'.format(key)
    return env_override
258355
def context(root, project=""):
    

    environment = os.environ.copy()
    environment.update({
        "BE_PROJECT": project,
        "BE_PROJECTROOT": (
            os.path.join(root, project).replace("\\", "/")
            if project else ""),
        "BE_PROJECTSROOT": root,
        "BE_ALIASDIR": "",
        "BE_CWD": root,
        "BE_CD": "",
        "BE_ROOT": "",
        "BE_TOPICS": "",
        "BE_DEVELOPMENTDIR": "",
        "BE_ACTIVE": "1",
        "BE_USER": "",
        "BE_SCRIPT": "",
        "BE_PYTHON": "",
        "BE_ENTER": "",
        "BE_TEMPDIR": "",
        "BE_PRESETSDIR": "",
        "BE_GITHUB_API_TOKEN": "",
        "BE_ENVIRONMENT": "",
        "BE_BINDING": "",
        "BE_TABCOMPLETION": ""
    })

    return environment
438612
def _environment_variables() -> Dict[str, str]:
    
    return {key: value
            for key, value in os.environ.items()
            if _is_encodable(value)}
1130594
def from_dict(cls, context_options_dict):
        """"""
        import copy

        context_options = copy.deepcopy(context_options_dict)

        tasks_inserted = context_options.pop('_tasks_inserted', False)

        insert_tasks = context_options.pop('insert_tasks', None)
        if insert_tasks:
            context_options['insert_tasks'] = path_to_reference(insert_tasks)

        # The constructor expects a reference to the persistence engine.
        persistence_engine = context_options.pop('persistence_engine', None)
        if persistence_engine:
            context_options['persistence_engine'] = path_to_reference(
                persistence_engine)

        # If there are callbacks, reconstitute them.
        callbacks = context_options.pop('callbacks', None)
        if callbacks:
            context_options['callbacks'] = decode_callbacks(callbacks)

        context = cls(**context_options)

        context._tasks_inserted = tasks_inserted

        return context