help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: yow


From: TheFlyingDutchman
Subject: Re: yow
Date: Fri, 24 Oct 2008 00:53:06 -0700 (PDT)
User-agent: G2/1.0

>
> Eeep, I just did a wget of that file, and now it's worse:

I don't know Emacs Lisp so I wrote this little program in Python to
convert the HTML from that page into an Emacs yow.lines. You have to
save the page into a text file with Internet Explorer (not Firefox)
and then run this program to produce yow.lines.
__________________________________________________________________________________________________________________________

# convert  HTML page source representing "yow.lines" to an Emacs
usable format
# --------------------------------------------------------------
# save (File-Save As...)
# 
http://olympus.het.brown.edu/cgi-bin/dwww?type=file&location=/usr/share/doc/emacs21-common/etc/yow.lines
# to a html or text file using Internet Explorer 6 (not Firefox which
requires slightly different processing for
# what it saves)
# Use that file as input to this program. This program will output a
file called yow.lines.
# Copy yow.lines to the directory referenced in the Emacs variable ->
data-directory <- . (eg: "c:/Program Files/Emacs/etc")
import sys
import os

if __name__ == "__main__":

    if  len(sys.argv) == 1:
        print "ERROR: You must input the name of the file to convert
to yow.lines"
        exit(1)
    if os.path.exists(sys.argv[1]):
        f_input = open( sys.argv[1] )
        f_output = open( "yow.lines",'w')
    else:
        print "ERROR: File " + sys.argv[1] + " not found"
        exit(2)
    print "will convert html page source to usable yow.lines"
    dataHit = False
    finished = False
    f_output.write("Zippy the pinhead data base.\n")
    for line in f_input.readlines():
        if line[0] != '<' and not finished:
            outputLine = line.rstrip("\n\r")
            outputLine = outputLine.replace("&amp;","&")
            if outputLine.startswith("A can of ASPARAGUS"):
                dataHit = True
                f_output.write( chr(0) + "\n")
            if len(outputLine) > 0:
                lastChar = outputLine[-1]
                if lastChar in ['!', '?', '.'] and dataHit:
                    outputLine = outputLine + chr(0) + "\n"
                else:
                    outputLine = outputLine + "\n"
                f_output.write(outputLine)
            if outputLine.startswith("Zippy's brain cells are
straining to bridge synapses..."):
                finished = True
    f_input.close()
    f_output.close()
    print "program %s ended successfully" % (sys.argv[0])


reply via email to

[Prev in Thread] Current Thread [Next in Thread]