def whichgen(command, path=None, verbose=<NUM_LIT:0>, exts=None): 
matches = []<EOL>if path is None:<EOL><INDENT>using_given_path = <NUM_LIT:0><EOL>path = os.environ.get("<STR_LIT>", "<STR_LIT>").split(os.pathsep)<EOL>if sys.platform.startswith("<STR_LIT>"):<EOL><INDENT>path.insert(<NUM_LIT:0>, os.curdir)  <EOL><DEDENT><DEDENT>else:<EOL><INDENT>using_given_path = <NUM_LIT:1><EOL><DEDENT>if sys.platform.startswith("<STR_LIT>"):<EOL><INDENT>if exts is None:<EOL><INDENT>exts = os.environ.get("<STR_LIT>", "<STR_LIT>").split(os.pathsep)<EOL>for ext in exts:<EOL><INDENT>if ext.lower() == "<STR_LIT>":<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>exts = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL><DEDENT><DEDENT>elif not isinstance(exts, list):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if exts is not None:<EOL><INDENT>raise WhichError("<STR_LIT>" % sys.platform)<EOL><DEDENT>exts = []<EOL><DEDENT>if os.sep in command or os.altsep and os.altsep in command:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>for i, dir_name in enumerate(path):<EOL><INDENT>if sys.platform.startswith("<STR_LIT>") and len(dir_name) >= <NUM_LIT:2> and dir_name[<NUM_LIT:0>] == '<STR_LIT:">' and dir_name[-<NUM_LIT:1>] == '<STR_LIT:">':<EOL><INDENT>dir_name = dir_name[<NUM_LIT:1>:-<NUM_LIT:1>]<EOL><DEDENT>for ext in ['<STR_LIT>']+exts:<EOL><INDENT>abs_name = os.path.abspath(os.path.normpath(os.path.join(dir_name, command+ext)))<EOL>if os.path.isfile(abs_name):<EOL><INDENT>if using_given_path:<EOL><INDENT>from_where = "<STR_LIT>" % i<EOL><DEDENT>elif not sys.platform.startswith("<STR_LIT>"):<EOL><INDENT>from_where = "<STR_LIT>" % i<EOL><DEDENT>elif i == <NUM_LIT:0>:<EOL><INDENT>from_where = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>from_where = "<STR_LIT>" % (i-<NUM_LIT:1>)<EOL><DEDENT>match = _cull((abs_name, from_where), matches, verbose)<EOL>if match:<EOL><INDENT>if verbose:<EOL><INDENT>yield match<EOL><DEDENT>else:<EOL><INDENT>yield match[<NUM_LIT:0>]<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>match = _get_registered_executable(command)<EOL>if match is not None:<EOL><INDENT>match = _cull(match, matches, verbose)<EOL>if match:<EOL><INDENT>if verbose:<EOL><INDENT>yield match<EOL><DEDENT>else:<EOL><INDENT>yield match[<NUM_LIT:0>]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Return a generator of full paths to the given command.

    "command" is a the name of the executable to search for.
    "path" is an optional alternate path list to search. The default it
        to use the PATH environment variable.
    "verbose", if true, will cause a 2-tuple to be returned for each
        match. The second element is a textual description of where the
        match was found.
    "exts" optionally allows one to specify a list of extensions to use
        instead of the standard list for this system. This can
        effectively be used as an optimization to, for example, avoid
        stat's of "foo.vbs" when searching for "foo" and you know it is
        not a VisualBasic script but ".vbs" is on PATHEXT. This option
        is only supported on Windows.

    This method returns a generator which yields either full paths to
    the given command or, if verbose, tuples of the form (<path to
    command>, <where path found>).