It's pretty simple - The bs_file method reads a file, asks BS to prettify its content, and writes the result to the file again.Do note that BS takes a lot of liberty in interpreting files - it might add tags where it decides they're missing etc.
To use the script, run it and provide the filenames you wish to prettify as arguments, e.g. /tmp/bs.py index.html