From UNB Archives and Special Collections
Jump to navigation Jump to search
  1. !/usr/local/bin/python
  1. Opens a file, grabs its filename - appends it to the top of the file and inserts ENDTITLE after it.
  2. Appends ENDPAGE at the end of the page.

import inspect, os from sys import argv

def line_prepender(filename,line):

   with open(filename,'r+') as f:
       content =,0)
       f.write(line.rstrip('\r\n') + '\n' + content)

def line_appender(filename,line): with open(filename, "a") as f: f.write(line)

script, filename = argv filetoOpen = open(filename) fileName = file = fileName.split("_")[0] lineattop = file + "\n" + "