def pretty_seconds(s, precision=1):
    """Convert a number of seconds into a single text string with a decimal
    number followed by the largest single unit of time that causes the result
    to be greater than one.
    """
    fmt = '%%.%df' % precision
    if s < 1:
        fmt = '%d'
        val = s * 1000.0
        ext = 'ms'
    elif s < 60:
        val = s
        ext = 's'
    elif s < 3600:
        val = s / 60.0
        ext = 'm'
    elif s < 86400:
        val = s / 3600.0
        ext = 'hr'
    elif s < 604800:
        val = s / 86400.0
        ext = 'day'
    elif s < 31449600:
        val = s / 604800.0
        ext = 'wk'
    else:
        val = s / 31449600.0
        ext = 'yr'
    if abs(val - int(val)) < 1e-06:
        fmt = '%d'
    result = fmt % val + ext
    return result
