On Sunday 31 December 2006 00:00, Kevin O'Gorman wrote:
> Hey, Jerry, wanna make a project team? I woulda done Python if I had
> thought it was gonna get big. It now seems like that would be a good idea.
> Care to:
> 1) share your code?
> 2) start a sourceforge project?
> 3) just tantalize us with your results?
>
It's far, far from being finished or polished... here it is:
#!/usr/bin/python
#
try:
import psyco
psyco.full()
except ImportError:
print "Non-Fatal error importing PSYCO"
pass
#
try:
import readline
except ImportError:
print "Fatal Error importing readline"
sys.exit(1)
#
try:
import struct
except ImportError:
print "Fatal Error importing struct"
sys.exit(1)
#
try:
import string
except ImportError:
print "Fatal Error importing string"
sys.exit(1)
#
try:
import sys
except ImportError:
print "Fatal Error imporing sys"
sys.exit(1)
#
try:
import os
except ImportError:
print "Fatal Error imporing os"
sys.exit(1)
al="array.list"
il="index.list"
ni="/var/www/localhost/htdocs/index2.html"
z=0
rightNow="today!"
version="1.0"
print "Every Damn Index - version ",version
print ""
print 'Scanning hard drive and creating list of all discovered files.'
print ""
os.system('tree -fixn --noreport -o '+il+' /')
print 'Construction of index list completed!'
print ""
print"Reading text from: ", il
print ""
#
# read index.list and create new array list
#
input=open(il,'r')
output=open(al,'w')
for line in input.readlines():
# strip off leading and trailing spaces
line = string.strip(line, " ")
# stip off CR's
line = string.rstrip(line,chr(10))
words=string.split(line,"/")
steps=len(words)
if words[steps-1]=="index.html":
output.writelines(line+chr(10))
words=string.split(line,".")
steps=len(words)
if words[steps-1]=="pdf":
output.writelines(line+chr(10))
words=string.split(line,".")
steps=len(words)
if words[steps-1]=="chm":
output.writelines(line+chr(10))
z=z+1
if z > 2000:
print ".",
z=0
print""
print "Successfully processed ",il
print""
input.close()
output.close()
print"Reading text from: "+al+" and building new "+ni
print""
input=open(al,'r')
output=open(ni,'w')
output.writelines('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'+chr(10))
output.writelines("<html>"+chr(10))
output.writelines("<head>"+chr(10))
output.writelines("<title>Evey Damn Index "+version+"- copyright Jerome D.
McBride - 2006</title>"+chr(10))
output.writelines('<meta name="GENERATOR" content="NONE">'+chr(10))
output.writelines('<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">'+chr(10))
#output.writelines('<img id= "logo"
src="http://www.expertsrt.com/images/xrt.png" alt="ERT Logo"
style="vertical-align:top"/>'+chr(10))
output.writelines("</head>"+chr(10))
output.writelines("<body>"+chr(10))
output.writelines("<hr>"+chr(10))
output.writelines("<strong> Every Damn Index - Version "+version+"
</strong>"+chr(10))
output.writelines("<hr>"+chr(10))
output.writelines("This page conatins a list of all available html
indexes, .pdf and .chm files"+chr(10))
output.writelines("created "+rightNow+chr(10))
output.writelines("<hr>"+chr(10))
output.writelines("<br>"+chr(10))
z=0
for line in input.readlines():
# strip off leading and trailing spaces
line = string.strip(line, " ")
# strip off leading and trailing slashes
line = string.strip(line, "/")
# stip off CR's
line = string.rstrip(line,chr(10))
print 'Looking for package info for:', line
#clean up previous info.dat file
os.system("rm info.dat 2>/dev/null 1>/dev/null")
os.system('/usr/bin/equery belongs '+line+' >info.dat')
inputData=open('info.dat','r')
infoText=inputData.read()
inputData.close()
if len(infoText)==0:
infoText="PNA/PNA"
words=string.split(infoText,"/")
steps=len(words)
groupName=words[0]
packageName=words[1]
output.writelines('<br>--'+packageName+'-- <a
href="'+line+'">documentation</a> found at '+line+'</br>'+chr(10))
output.writelines("<hr>"+chr(10))
output.writelines("The end..."+chr(10))
output.writelines("<br>"+chr(10))
output.writelines("</body>"+chr(10))
output.writelines("</html>"+chr(10))
print "New index2.html written to ",ni,"."
print ""
print "Program successfully shutdown."
print ""
input.close()
output.close()
os.system("rm "+al+" 2>/dev/null 1>/dev/null")
os.system("rm "+il+" 2>/dev/null 1>/dev/null")
os.system("rm info.dat 2>/dev/null 1>/dev/null")
sys.exit(0)
As for manning a project... time hasn't allowed me the pleasure of a decent
day off from work. I would, however, contribute as I can.
Cheers all and enjoy
--
Jerry McBride
--
[email protected] mailing list