This assembles the tool context. Private members are preceded by a '_'.

    :param tool:
    :param command:
    :return: dictionary containing the gcdt tool context
187268
def get_context(awsclient, env, tool, command, arguments=None):
    
    # TODO: elapsed, artifact(stack, depl-grp, lambda, api)
    if arguments is None:
        arguments = {}
    context = {
        '_awsclient': awsclient,
        'env': env,
        'tool': tool,
        'command': command,
        '_arguments': arguments,  # TODO clean up arguments -> args
        'version': __version__,
        'user': _get_user(),
        'plugins': get_plugin_versions().keys()
    }

    return context
239024
def cli(ctx):
    
    level = logger.level
    try:
        level_to_name = logging._levelToName
    # Fallback to pre-Python 3.4 internals.
    except AttributeError:
        level_to_name = logging._levelNames
    level_name = level_to_name.get(level, level)
    logger.debug('Verbosity set to {}.'.format(level_name))

    # Print help screen and exit if no sub-commands provided.
    if ctx.invoked_subcommand is None:
        click.echo(ctx.get_help())
        ctx.exit()

    # Load up global options to the context.
    ctx.obj = {}
949036
def get_command(self, ctx, name):
        """"""
        if not self._commands_dir:
            return defaults.get_command(ctx, name)

        ns = {}
        fn = os.path.join(self._commands_dir, name + '.py')

        try:
            with open(fn) as f:
                code = compile(f.read(), fn, 'exec')
        except IOError:
            return defaults.get_command(ctx, name)

        eval(code, ns, ns)

        CLI = 'cli'

        try:
            return ns[CLI]
        except KeyError:
            ctx.fail('`{}` not defined in "{}"'.format(CLI, name))
951153
def get_command(self, ctx, cmd_name):
        
        if cmd_name not in self._commands:
            logger.error("Command %s not available", cmd_name)
            return

        pkg_name = self._commands[cmd_name]

        try:
            mod = importlib.import_module(pkg_name)
        except ImportError:
            logger.exception("Command '%s' is not configured correctly. Unable to import '%s'", cmd_name, pkg_name)
            return

        if not hasattr(mod, "cli"):
            logger.error("Command %s is not configured correctly. It must expose an function called 'cli'", cmd_name)
            return

        return mod.cli
109850
def name(self):
        
        python = self._python
        if self._python.startswith('pypy'):
            # get_env_name adds py-prefix
            python = python[2:]
        return environment.get_env_name(self.tool_name, python, self._requirements)
248685
def check_tool(command):
    
    assert is_iterable_typed(command, basestring)
    #FIXME: why do we check the first and last elements????
    if check_tool_aux(command[0]) or check_tool_aux(command[-1]):
        return command
700016
def context(self, key, method):
        
        ctx = stack.top
        if ctx is not None:
            if not hasattr(ctx, key):
                setattr(ctx, key, method())
            return getattr(ctx, key)
175070
def to(self, command, **args):
        
        self.command = command
        self.args = args
        return self
144526
def unalias_tool(self, context_name, tool_name):
        
        data = self._context(context_name)
        aliases = data["tool_aliases"]
        if tool_name in aliases:
            del aliases[tool_name]
            self._flush_tools()
1245227
def from_dict(d: dict) -> 'SimpleCompiler':
        
        cmd = d['command']
        cmd_with_instrumentation = d.get('command_with_instrumentation', None)
        time_limit = d['time-limit']
        context = d['context']
        cmd_clean = d.get('command_clean', 'exit 0')
        return SimpleCompiler(command=cmd,
                              command_clean=cmd_clean,
                              command_with_instrumentation=cmd_with_instrumentation,
                              context=context,
                              time_limit=time_limit)
302712
def load_context(ctx_path, ctx_type, scm=None):
    
    if ctx_path == '-':
        return loads(sys.stdin.read(), ac_parser=ctx_type, ac_schema=scm)

    return load(ctx_path, ac_parser=ctx_type, ac_schema=scm)
823542
def context(self):
	
		
		
		return execution.Context(self.__base_dir, self.__prof_dir,
				self.__prof_name)
191522
def from_dict(cls, ctx):
        ''
        ctx = Context(ctx)
        s = cls()
        ContextFlags = ctx['ContextFlags']
        s.ContextFlags = ContextFlags
        for key in cls._others:
            if key != 'VectorRegister':
                setattr(s, key, ctx[key])
            else:
                w = ctx[key]
                v = (M128A * len(w))()
                i = 0
                for x in w:
                    y = M128A()
                    y.High = x >> 64
                    y.Low = x - (x >> 64)
                    v[i] = y
                    i += 1
                setattr(s, key, v)
        if (ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL:
            for key in cls._control:
                setattr(s, key, ctx[key])
        if (ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER:
            for key in cls._integer:
                setattr(s, key, ctx[key])
        if (ContextFlags & CONTEXT_SEGMENTS) == CONTEXT_SEGMENTS:
            for key in cls._segments:
                setattr(s, key, ctx[key])
        if (ContextFlags & CONTEXT_DEBUG_REGISTERS) == CONTEXT_DEBUG_REGISTERS:
            for key in cls._debug:
                setattr(s, key, ctx[key])
        if (ContextFlags & CONTEXT_MMX_REGISTERS) == CONTEXT_MMX_REGISTERS:
            xmm = s.FltSave.xmm
            for key in cls._mmx:
                y = M128A()
                y.High = x >> 64
                y.Low = x - (x >> 64)
                setattr(xmm, key, y)
        return s
1080666
def format_commands(self, ctx, formatter):
        
        core_commands, inenv_commands = [], []
        for subcommand in self.list_commands(ctx):
            cmd = self.get_command(ctx, subcommand)
            # What is this, the tool lied about a command.  Ignore it
            if cmd is None:
                continue

            help_ = cmd.short_help or ''
            if subcommand in self.sort_later:
                inenv_commands.append((subcommand, help_))
            else:
                core_commands.append((subcommand, help_))

        if core_commands:
            with formatter.section('Commands'):
                formatter.write_dl(core_commands)

        if inenv_commands:
            with formatter.section('Inenvs'):
                formatter.write_dl(inenv_commands)
667427
def _build_command_chain(self, command):
        
        next = command
        for intercepter in reversed(self._intercepters):
            next = InterceptedCommand(intercepter, next)
        self._commands_by_name[next.get_name()] = next
822672
def _tool_to_dict(tool, records, remapped):
    
    requirements = _requirements_to_dict(tool.requirements + tool.hints)
    inputs = []
    outputs = []
    for inp in tool.tool["inputs"]:
        ready_inp, records = _input_to_dict(inp, records, remapped)
        inputs.append(ready_inp)
    for outp in tool.tool["outputs"]:
        ready_outp, records = _output_to_dict(outp, records)
        outputs.append(ready_outp)
    out = {"name": _id_to_name(tool.tool["id"]),
           "baseCommand": " ".join(tool.tool["baseCommand"]),
           "arguments": [_arg_to_dict(a, requirements) for a in tool.tool["arguments"]],
           "inputs": inputs,
           "outputs": outputs,
           "requirements": requirements,
           "stdin": None, "stdout": None}
    return out, records
1245395
def get_command(self, ctx, name):
        """"""
        if name not in self.daemon_class.list_actions():
            return None

        # The context object is a Daemon object
        daemon = ctx.obj

        def subcommand(debug=False):
            """Call a daemonocle action."""
            if daemon.detach and debug:
                daemon.detach = False

            daemon.do_action(name)

        # Override the docstring for the function so that it shows up
        # correctly in the help output
        subcommand.__doc__ = daemon.get_action(name).__doc__

        if name == 'start':
            # Add a --debug option for start
            subcommand = click.option(
                '--debug', is_flag=True,
                help='Do NOT detach and run in the background.'
            )(subcommand)

        # Make it into a click command
        subcommand = click.command(
            name, options_metavar=self.options_metavar)(subcommand)

        return subcommand