import sys

def fill_template(temp, args, longname, filename, url):
    """
    Takes a template string (temp) and replaces all template keywords with
    information from commandline arguments.
    """
    temp = temp.replace('OWNER_NAME', args.copyright_holder)
    temp = temp.replace('COPYRIGHT_YEAR', args.year)
    temp = temp.replace('PROGRAM_NAME', args.program_name)
    temp = temp.replace('LICENSE_LONGNAME', longname)
    temp = temp.replace('LICENSE_FILENAME', filename)
    temp = temp.replace('LICENSE_URL', url)
    return temp

def exit(bad=False):
        if bad:
            print 'The operation was not completed successfully.'
            sys.exit(1)
        else:
            sys.exit(0)

@@ -3,16 +3,32 @@
 port sys
+%0Aimport textwrap
 %0A%0Adef fi
@@ -719,8 +719,1115 @@
 exit(0)%0A
+%0Adef wrap_paragraphs(readlines_list, textwidth=80):%0A    %22%22%22 Takes a list of strings called readlines_list and returns a single%0A    string with lines wrapped to textwidth columns.  readlines_list should%0A    follow the format produced by calls to open().readlines().  %22%22%22%0A%0A    def split_paragraph(readlines_list):%0A        %22%22%22 Transform the readlines_list into a nested list.  Each list in the%0A        output represents the lines of an unwrapped or improperly wrapped%0A        paragraph. %22%22%22%0A%0A        list_of_lists = %5B%5D%0A        para_list = %5B%5D%0A        for line in readlines_list:%0A            if line ==  '%5Cn':%0A                list_of_lists.append(para_list)%0A                para_list = %5B%5D%0A            else:%0A                para_list.append(line)%0A        list_of_lists.append(para_list)%0A        return list_of_lists%0A%0A    paragraph_list = split_paragraph(readlines_list)%0A%0A    wrapped_list = %5B%5D%0A    for para in paragraph_list:%0A        newlines = textwrap.wrap(''.join(para),textwidth)%0A        wrapped_list.extend(newlines)%0A        wrapped_list.append('%5Cn') # Separate paragraphs%0A    return '%5Cn'.join(wrapped_list)%0A%0A

Add function that extends textwrap.wrap to multi-paragraph inputs.