#! /usr/bin/env python
#  -*- Python -*-

import string
import support
import sys

def collect(fp):
    names = []
    while 1:
        line = fp.readline()
        if not line:
            break
        line = string.strip(line)
        if line:
            names.append(line)
        else:
            names = []
    return names

def main():
    options = support.Options()
    options.columns = 4
    options.variables["title"] = "Acknowledgements"
    options.parse(sys.argv[1:])
    names = collect(sys.stdin)
    percol = (len(names) + options.columns - 1) / options.columns
    colnums = []
    for i in range(options.columns):
        colnums.append(percol*i)
    options.aesop_type = "information"
    fp = options.get_output_file()
    fp.write(string.rstrip(options.get_header()) + "\n")
    fp.write(THANKS + "\n")
    fp.write('
\n')
    for i in range(percol):
        fp.write("  \n")
        for j in colnums:
            try:
                fp.write("     %s\n" % names[i + j])
            except IndexError:
                pass
        fp.write("  
\n")
    fp.write("
\n")
    fp.write(string.rstrip(options.get_footer()) + "\n")
    fp.close()

THANKS = '''\

These people have contributed in some way to the Python
documentation.  This list is probably not complete -- if you feel that
you or anyone else should be on this list, please let us know (send
email to docs@python.org (mailto:docs@python.org)), and
we will be glad to correct the problem.

It is only with the input and contributions of the Python community
that Python has such wonderful documentation -- Thank You!

'''

if __name__ == "__main__":
    main()
