def findFile(name, path=['.'], env=None, all=False, sep=':'):
    """Search for a file with the given path
    
    Search path is argument 'path' then ENV (if given)
    If 'all' is set then return a list of all matching files,
    else just the first (or raises IOError)
    """
    from os.path import join, isfile
    from os import environ
    ret = []
    if env is not None and env in environ:
        opt = environ[env].split(sep)
        opt = map(str.strip, opt)
        path += opt
    for p in path:
        if p == '':
            continue
        f = join(p, name)
        if not isfile(f):
            continue
        if all:
            ret.append(f)
        else:
            return f
    if all:
        return ret
    else:
        raise IOError(name + ' not in path')
