def make_source()

in cbmc_viewer/sourcet.py [0:0]


def make_source(viewer_source, goto, source_method, srcdir,
                wkdir, exclude, extensions):
    """The implementation of make-source."""

    wkdir = srcloct.abspath(wkdir) if wkdir else None
    srcdir = srcloct.abspath(srcdir) if srcdir else None

    if viewer_source:
        logging.info("Sources by SourceFromJson")
        return SourceFromJson(viewer_source)

    # source_method was set to a reasonable value by optionst.defaults()
    # if it was not specified on the command line.

    if source_method == Sources.GOTO:
        if goto is None or wkdir is None or srcdir is None:
            fail("make-source: expected --goto and --srcdir and --wkdir")
        logging.info("Sources by SourceFromGoto")
        return SourceFromGoto(goto, wkdir, srcdir)

    if source_method == Sources.MAKE:
        if srcdir is None or wkdir is None:
            fail("make-source: expected --srcdir and --wkdir")
        logging.info("Sources by SourceFromMake")
        return SourceFromMake(srcdir, wkdir)

    if source_method == Sources.FIND:
        if srcdir is None:
            fail("make-source: expected --srcdir")
        logging.info("Sources by SourceFromFind")
        return SourceFromFind(srcdir, exclude, extensions)

    if source_method == Sources.WALK:
        if srcdir is None:
            fail("make-source: expected --srcdir")
        logging.info("Sources by SourceFromWalk")
        return SourceFromWalk(srcdir, exclude, extensions)

    logging.info("make-source: nothing to do")
    return Source()