timid/main.py
def _processor(args):
    """
    A ``cli_tools`` processor function that interfaces between the
    command line and the ``timid()`` function.  This function is
    responsible for allocating a ``timid.context.Context`` object and
    initializing the activated extensions, and for calling those
    extensions' ``finalize()`` method.

    :param args: The ``argparse.Namespace`` object containing the
                 results of argument processing.
    """

    # Begin by initializing a context
    args.ctxt = context.Context(args.verbose, args.debug, args.directory)

    # Now set up the extension set
    args.exts = extensions.ExtensionSet.activate(args.ctxt, args)

    # Update the environment and the variables
    args.ctxt.environment.update(args.environment)
    args.ctxt.variables.update(args.variables)

    # Call the actual timid() function
    try:
        result = yield

    # If an exception occurred, give the extensions an opportunity to
    # handle it
    except Exception as exc:
        if args.debug:
            # Make sure we emit a proper traceback
            traceback.print_exc(file=sys.stderr)

        # The exception is the result, from the point of view of the
        # extensions
        result = exc

    # Allow the extensions to handle the result
    result = args.exts.finalize(args.ctxt, result)

    # If the final result is an exception, convert it to a string for
    # yielding back to cli_tools
    if isinstance(result, Exception):
        result = str(result)

    # This line is covered, but coverage appears to be missing it for
    # some reason
    yield result
def _processor(args):
    """
    A ``cli_tools`` processor function that interfaces between the
    command line and the ``timid()`` function.  This function is
    responsible for allocating a ``timid.context.Context`` object and
    initializing the activated extensions, and for calling those
    extensions' ``finalize()`` method.

    :param args: The ``argparse.Namespace`` object containing the
                 results of argument processing.
    """

    # Begin by initializing a context
    args.ctxt = context.Context(args.verbose, args.debug, args.directory)

    # Now set up the extension set
    args.exts = extensions.ExtensionSet.activate(args.ctxt, args)

    # Update the environment and the variables
    args.ctxt.environment.update(args.environment)
    args.ctxt.variables.update(args.variables)

    # Call the actual timid() function
    try:
        result = yield

    # If an exception occurred, give the extensions an opportunity to
    # handle it
    except Exception as exc:
        if args.debug:
            # Make sure we emit a proper traceback
            traceback.print_exc(file=sys.stderr)

        # The exception is the result, from the point of view of the
        # extensions
        result = exc

    # Allow the extensions to handle the result
    result = args.exts.finalize(args.ctxt, result)

    # If the final result is an exception, convert it to a string for
    # yielding back to cli_tools
    if isinstance(result, Exception):
        result = str(result)

    # This line is covered, but coverage appears to be missing it for
    # some reason
    yield result
A ``cli_tools`` processor function that interfaces between the
    command line and the ``timid()`` function.  This function is
    responsible for allocating a ``timid.context.Context`` object and
    initializing the activated extensions, and for calling those
    extensions' ``finalize()`` method.

    :param args: The ``argparse.Namespace`` object containing the
                 results of argument processing.