Esempio n. 1
0
def print_status_report():

    # The site module maintains a count of the number of pages that have been
    # rendered into html and written to disk.
    num_rendered, num_written = site.rendered(), site.written()

    # We only want to print a report after a build run.
    if num_rendered == 0:
        return

    # Singluar or plural text?
    txt_rendered = "1 page" if num_rendered == 1 else "%s pages" % num_rendered
    txt_written = "1 page" if num_written == 1 else "%s pages" % num_written

    # The runtime() function gives the application's running time in seconds.
    time = site.runtime()
    average = time / num_rendered

    # Default status report.
    f = "%s rendered, %s written in %.2f seconds. %.4f seconds per page."
    default = f % (txt_rendered, txt_written, time, average)

    # Compact report.
    f = "Rendered: %5d  |  Written: %5d  |  Time: %5.2f sec  |  Avg: %.4f sec/pg"
    compact = f % (num_rendered, num_written, time, average)

    # Print the compact version if the default is too long or if the 'watch'
    # command is running.
    if len(default) > 80:
        print(compact)
    elif 'watching' in site.flags() and not 'firstwatch' in site.flags():
        print(compact)
    else:
        print(default)
Esempio n. 2
0
def print_status_report():
    num_rendered, num_written = site.rendered(), site.written()

    # We only want to print a report after a build run.
    if num_rendered == 0:
        return

    txt_rendered = "1 page" if num_rendered == 1 else "%s pages" % num_rendered
    txt_written = "1 page" if num_written == 1 else "%s pages" % num_written

    time = site.runtime()
    average = time / num_rendered

    status = "%s rendered, %s written in %.2f seconds. %.4f seconds per page."
    print(status % (txt_rendered, txt_written, time, average))