<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _context_build(self, pending=False):
 """ Create a context dict from standard task configuration. The context is constructed in a standard way and is passed to str.format() on configuration. The context consists of the entire os.environ, the config 'defines', and a set of pre-defined values which have a common prefix from 'context_prefix'. """

        log = self._params.get('log', self._discard)
        log.debug("called with pending=%s", pending)
        if pending:
            conf = self._config_pending
        else:
            conf = self._config_running
        if not conf:
            log.warning("No config available")
            conf = {}

        #  Initially create the context as a copy of the environment.
        #
        context = os.environ.copy()

        #  Merge in the built-in items.  It is important that these
        #  will override any values from the environment as they will
        #  have come from a parent instance of "taskforce".
        #
        context.update(
            {
                context_prefix+'instance': None,
                context_prefix+'pid': None,
                context_prefix+'name': self._name,
                context_prefix+'ppid': os.getpid(),
                context_prefix+'host': self._legion.host,
                context_prefix+'fqdn': self._legion.fqdn
            }
        )

        #  Add certain config values to the context
        for tag in ['user', 'group', 'pidfile', 'cwd']:
            if tag in conf:
                context[context_prefix+tag] = self._get(conf[tag], context=context)

        if self._legion._config_running:
            self._context_defines(context, self._legion._config_running)
        else:
            log.warning("No legion config available for defines")
        self._context_defines(context, conf)

        self._context_defaults(context, conf)
        if self._legion._config_running:
            self._context_defaults(context, self._legion._config_running)
        else:
            log.warning("No legion config available for defaults")

        return context