Changeset 26
- Timestamp:
- 09/12/07 23:24:58 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
applications/FeatureProof/trunk/Lib/featureProof/logToHTML.py
r5 r26 1 from AppKit import NSBundle, NSURL 2 bundle = NSBundle.mainBundle() 3 path = bundle.pathForResource_ofType_("webDisclosureClosed", "png") 4 url = NSURL.fileURLWithPath_(path) 5 closedDisclosureImageURL = url.absoluteString() 6 path = bundle.pathForResource_ofType_("webDisclosureOpen", "png") 7 url = NSURL.fileURLWithPath_(path) 8 openDisclosureImageURL = url.absoluteString() 9 1 10 _head = u""" 2 11 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" … … 24 33 color: white; 25 34 margin: 0px -10px 0px -10px; 26 padding: 0px 10px 0px 10px;35 padding: 0px 10px 0px 20px; 27 36 border-bottom: 1px solid #fff; 28 37 } 29 38 39 h1.table { 40 background-image: url(%s); 41 background-repeat: no-repeat; 42 } 43 30 44 h2 { 45 background-image: url(%s); 46 background-repeat: no-repeat; 31 47 background-color: #333; 32 48 color: white; … … 34 50 35 51 h3 { 52 background-image: url(%s); 53 background-repeat: no-repeat; 36 54 background-color: #666; 37 color: black;55 color: white; 38 56 } 39 57 40 58 h4 { 59 padding-left: 10px; 41 60 background-color: #999; 42 61 color: black; … … 44 63 45 64 h5 { 65 padding-left: 10px; 46 66 background-color: #ccc; 47 67 color: black; … … 50 70 51 71 h6 { 72 padding-left: 10px; 52 73 background-color: #fff; 53 74 color: black; … … 89 110 90 111 </style> 112 113 <script type="text/javascript"> 114 115 function toggle(elementID) { 116 var element = document.getElementById(elementID); 117 var head = document.getElementById(elementID + "_head"); 118 if (element.style.display == "") { 119 element.style.display = "none"; 120 head.style.backgroundImage = "url(%s)"; 121 } else if (element.style.display != "block") { 122 element.style.display = "block"; 123 head.style.backgroundImage = "url(%s)"; 124 } else { 125 element.style.display = "none"; 126 head.style.backgroundImage = "url(%s)"; 127 } 128 } 129 130 </script> 131 91 132 </head> 92 <body>""" 133 <body>""" % (openDisclosureImageURL, openDisclosureImageURL, openDisclosureImageURL, closedDisclosureImageURL, openDisclosureImageURL, closedDisclosureImageURL) 93 134 94 135 _tail = u"""</body> 95 136 </html> 96 137 """ 138 139 elementIDCounter = 0 97 140 98 141 def logToHTML(xml): … … 130 173 <Element 'processing' at 0xe770> 131 174 """ 175 global elementIDCounter; 176 localID = elementIDCounter 177 elementIDCounter += 1 132 178 html = [] 133 179 name = element.get("name") 134 s = "<h1 >Table: <b>%s</b></h1>" % name180 s = "<h1 id=\"table%d_head\" class=\"table\" onclick=\"toggle('table%d');\">Table: <b>%s</b></h1>" % (localID, localID, name) 135 181 html.append(s) 182 html.append("<div id=\"table%d\">" % localID) 136 183 for i in element: 137 184 if i.tag == "featureStates": … … 143 190 elif i.tag == "results": 144 191 html += _logResults(i, name != "GSUB") 192 html.append("</div>") 145 193 return html 146 194 147 195 def _logFeatureStates(element): 148 html = ["<h2>Features:</h2>"] 196 global elementIDCounter; 197 localID = elementIDCounter 198 elementIDCounter += 1 199 html = ["<h2 id=\"features%d_head\" onclick=\"toggle('features%d');\">Features:</h2>" % (localID, localID), "<div id=\"features%d\">" % localID] 149 200 for i in element: 150 201 name = i.get("name") … … 156 207 s = '<p><span class="%s">✔</span> %s</p>' % (checkClass, name) 157 208 html.append(s) 209 html.append("</div>") 158 210 return html 159 211 160 212 def _logApplicableLookups(element): 161 html = ["<h2>Applicable Lookup Indices:</h2>"] 213 global elementIDCounter; 214 localID = elementIDCounter 215 elementIDCounter += 1 216 html = ["<h2 id=\"applicableLookupIndices%d_head\" onclick=\"toggle('applicableLookupIndices%d');\">Applicable Lookup Indices:</h2>" % (localID, localID), "<div id=\"applicableLookupIndices%d\">" % localID] 162 217 for i in element: 163 218 feature = i.get("feature") … … 167 222 if len(html) == 1: 168 223 html.append("<p>None</p>") 224 html.append("</div>") 169 225 return html 170 226 … … 185 241 186 242 def _logProcessing(element): 187 html = ["<h2>Lookup Application:</h2>"] 243 global elementIDCounter; 244 localID = elementIDCounter 245 elementIDCounter += 1 246 html = ["<h2 id=\"lookupApplication%d_head\" onclick=\"toggle('lookupApplication%d');\">Lookup Application:</h2>" % (localID, localID), "<div id=\"lookupApplication%d\">" % localID] 188 247 for i in element: 189 248 html += _logLookup(i) 249 html.append("</div>") 190 250 return html 191 251 192 252 def _logLookup(element): 253 global elementIDCounter; 254 localID = elementIDCounter 255 elementIDCounter += 1 193 256 html = [] 194 257 feature = element.get("feature") 195 258 index = element.get("index") 196 s = "<h3 >Feature: <b>%s</b> Lookup Index: <b>%s</b></h3>" % (feature, index)259 s = "<h3 id=\"lookup%d_head\" onclick=\"toggle('lookup%d');\">Feature: <b>%s</b> Lookup Index: <b>%s</b></h3>" % (localID, localID, feature, index) 197 260 html.append(s) 261 html.append("<div id=\"lookup%d\">" % localID) 198 262 for i in element: 199 263 html += _logSubTable(i) 264 html.append("</div>") 200 265 return html 201 266 applications/FeatureProof/trunk/setup.py
r5 r26 24 24 "Resources/English.lproj", 25 25 #"Resources/icon.icns" 26 "Resources/buttonAdd.tif", 27 "Resources/buttonRemove.tif", 28 "Resources/fileListButtonFill.tif", 29 "Resources/webDisclosureClosed.png", 30 "Resources/webDisclosureOpen.png", 26 31 ] 27 32
