ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/MW/tree2Html.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
Original Path: Python/NinoCode/MW/tree2Html.py
File size: 2795 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8 ## tree2Html.py
2     ## This program will create an HTML file with file links broken down by Foldername being the grouping and each
3     ## file being a bullet. DONT FORGET. IE does not like apostrophies!
4     ## EBorges
5     ## 11.12.03
6    
7     import os
8    
9     global masterDict
10    
11     def ListFiles(arg,dirName, names):
12     dirNameParts = dirName.split('\\')
13     grouping = dirNameParts[-2]
14     person = dirNameParts[-1]
15     headingInfo = "<HTML>\n<HEAD><H2><CENTER><b><u>\n"
16     footerInfo = '<BR><BR>\n<HR ALIGN="CENTER" WIDTH="65%">\n<CENTER><PRE>PRIVILEGED AND CONFIDENTIAL ATTORNEY WORK PRODUCT<BR>PREPARED IN ANTICIPATION OF LITIGATION<BR>CONTAINS OPINIONS AND CONCLUSIONS OF COUNSEL</PRE></CENTER>'
17     o= open(arg +"\\" + person +".html",'w')
18     o.write(headingInfo)
19     o.write(person)
20     o.write("</U></b></CENTER></H2></HEAD>\n<BODY>\n<DIR>\n")
21     for file in names:
22     o.write("<LI>")
23     o.write('<A HREF="../%s/%s/%s">'% (grouping,person,file))
24     o.write(os.path.splitext(file)[0]+"</A>"+"\n")
25     o.write(footerInfo)
26     o.write("</DIR></BODY></HTML>\n")
27     o.close()
28     AddToDict(grouping,person)
29     #print "Grouping = %s"% grouping
30     #print "Person = %s"% person
31     #print "Their files = %s"% names
32    
33     def AddToDict(grouping,person):
34     if masterDict.has_key(grouping):
35     masterDict[grouping].append(person)
36     else:
37     masterDict[grouping] = [person]
38    
39    
40     if __name__ == '__main__':
41     #projectFolder = r"C:\test_dir\Child_Proj\Presentation"
42     #projectFolder = r"\\ric3\gm\ford\Presentation"#\Plaintiff's Experts"
43     projectFolder = r"\\ercdis11\i\buildnew\Manny\Palmetto"
44     try:
45     os.mkdir(projectFolder + r"\html")
46     except:
47     pass
48     arguments = projectFolder + r"\html"
49     masterDict = {}
50     os.path.walk(projectFolder,ListFiles,arguments)
51     #masterHeader = "<HTML>\n<HEAD><H2><CENTER><b><u>\nCHILD GEOMETRY LITIGATION RESOURCES<br>Current through January 26, 2005<br>\n</U></b></CENTER></H2></HEAD>\n<BODY>\n"
52     masterHeader = "<HTML>\n<HEAD><H2><CENTER><b><u>\nCHILD GEOMETRY LITIGATION RESOURCES<br>Current through January 26, 2005<br>\n</U></b></CENTER></H2></HEAD>\n<BODY>\n"
53     masterFooter = '<BR><BR>\n<HR ALIGN="CENTER" WIDTH="65%">\n<CENTER><PRE>PRIVILEGED AND CONFIDENTIAL ATTORNEY WORK PRODUCT<BR>PREPARED IN ANTICIPATION OF LITIGATION<BR>CONTAINS OPINIONS AND CONCLUSIONS OF COUNSEL</PRE></CENTER>'
54     o = open(projectFolder + '\\'+'Disc_Content.html','w')
55     o.write(masterHeader)
56     for key in masterDict:
57     o.write('<DIR><LI><u>%s</u>\n<DIR>'%key)
58     for i in masterDict[key]:
59     o.write('<LI><A HREF="html/%s.html">%s</A>\n'%(i,i))
60     o.write('</DIR>\n</DIR>\n')
61     o.write(masterFooter)
62     o.write('</BODY></HTML>')
63     o.close()
64