Bulbul's Programming Notes

Bulbul's home page

Python

Python Scripts

You find mostly two kinds of things here: little utility scripts and cgi-programs.

Little Scripts
  • compare-dirs.py: Compares the contents of two directories. It outputs four lists: files only in directory A, files only in directory B, files in both directories where the one in directory A is newer, and files in both directories where the one in directory B is newer.

    Usage:

    comparedirs.py dir1 dir2

  • copytree.py: For writing scripts to back up directories. Copies file to the backup directory only when needed (only updates backup directory. Writes a log telling you exactly which files were copied and which were skipped. I've zipped it up in copytree.zip with a sample copy job. Run sample-windows-copy-job.py, not copytree.py.

  • singlespace.py: single-spaces input in which every other line is an unwanted carriage return. Useful for when you receive a text document that has become doublespaced through conversion between operating systems.

    Usage:

    singlespace.py > doublespaced.txt < singlespaced.txt

CGI Programs
  • questionnaire: I wrote a framework for online questionnaires with three kinds of widgets: single line text field, multiline text field, and scale from 1 to 9. The files in questionnaire.zip contains Questionnaire.py, which is the HTML widget-writing code, and a couple of little debugging files. The file course-evals.py is a sample of a real questionnaire: with obligatory and optional fields, a preview before submission, and anonymous submission by e-mail. The data for each state in the program is stored in hidden fields in the HTML, and as such, no session data needs to be stored on the server. You may see the course-evals.py program running here.

  • I have an event calendar program where events of different categories are stored in separate python modules and then are integrated and displayed in a large on-line event list. I will eventually get the sources for this program up for your perusal. You may see the scripts in action here.

  • I have an elaborate on-line address book program which stores data in a flat-file database. I'll eventually get the code for this up as well.