import _queue


def wait(jobs, notify=True, queue=None):
    """Wait for jobs to finish.

    Only works on user jobs by default. To work on jobs so someone else,
    initialize a fyrd.queue.Queue class with their user info and pass as an
    argument to queue.

    Parameters
    ----------
    jobs : fyrd.job.Job or str or list of either (mixed list fine)
        A single job or list of jobs, either Job objects or job numbers
    notify : str, True, or False, optional
        If True, both notification address and wait_time must be set in
        the [notify] section of the config. A notification email will be
        sent if the time exceeds this time. This is the default.
        If a string is passed, notification is forced and the string must
        be the to address.
        False means no notification
    queue : fyrd.queue.Queue, optional
        An already initiated Queue class to use.

    Returns
    -------
    success : bool
        True if all jobs successful, false otherwise
    """
    q = queue if queue else _queue.default_queue()
    return q.wait(jobs, notify=notify)