Changeset 4190 for trunk/tools/wikiapi2xml/createjQueryXMLDocs.py
- Timestamp:
- 12/16/07 22:08:02 (1 year ago)
- Files:
-
- 1 modified
-
trunk/tools/wikiapi2xml/createjQueryXMLDocs.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/wikiapi2xml/createjQueryXMLDocs.py
r4169 r4190 25 25 def printdebug(msg): 26 26 if opts.verbose != "false" and infoNode != None: 27 msgNode = doc.createElement("msg") 28 msgNode.appendChild(doc.createTextNode(msg)) 29 infoNode.appendChild(msgNode) 30 # print msg 31 # print >>sys.stderr, msg 27 if opts.debug == "false": 28 msgNode = doc.createElement("msg") 29 msgNode.appendChild(doc.createTextNode(msg)) 30 infoNode.appendChild(msgNode) 31 else: 32 print msg 33 # print >>sys.stderr, msg 32 34 33 35 # class to create static functions … … 45 47 self.startingUrl = "API" 46 48 self.exporterUrl = "http://docs.jquery.com/Special:Export"; 47 self.version = " Unknown"49 self.version = "" 48 50 self.convertLinks = "html" 49 51 self.verbose = "false" 52 self.debug = "false" 50 53 self.timestamp = "0" 51 54 self.parseOptions(form) … … 70 73 elif key == "verbose": 71 74 self.verbose = form.getvalue(key) 75 elif key == "debug": 76 self.debug = form.getvalue(key) 72 77 73 78 def url(self, url): … … 171 176 172 177 def exportXML(self, parent): 178 printdebug("Exporting '" + self.page.url + "'") 173 179 for child in self.children: 174 180 if (child != None): … … 185 191 186 192 def exportXML(self, parent): 193 global subcat 194 195 printdebug("Exporting '" + self.page.url + "'") 187 196 node = doc.createElement("cat") 188 197 node.setAttribute("value", self.page.url) 189 198 parent.appendChild(node) 199 # new cat so reset subcat 200 subcat = { 'name':'', 'node':None } 201 printdebug("Reset subcat to None"); 190 202 for child in self.children: 191 203 if (child != None): … … 379 391 arg['num'] = 0 380 392 arg['index'] = None 393 # create element as 'entry' initially till get a 'type' part then change it 381 394 node = doc.createElement("entry") 382 395 node.setAttribute("timestamp", self.page.timestamp) … … 384 397 # have left a subcat so reset 385 398 subcat = { 'name':'', 'node':None } 399 printdebug("Reset subcat to None"); 386 400 ## != "Documentation" because in the wiki some people are using it as a general header 387 401 elif self.page.header != "Unheadered" and self.page.header != "Documentation" and self.page.header != subcat['name']: … … 392 406 n.setAttribute('value', subcat['name']) 393 407 parent.appendChild(n) 408 printdebug("Set subcat to " + subcat['name']); 394 409 # if there is a subcat then append to that, otherwise go right to parent 395 410 if subcat['node'] != None: … … 479 494 return 480 495 if opts.supressContentType == "false": 481 print "Content-Type: text/xml\n" 496 if opts.debug == "false": 497 print "Content-Type: text/xml\n" 498 else: 499 print "Content-Type: text/plain\n" 482 500 483 501 impl = minidom.getDOMImplementation() … … 488 506 page = XMLPage(opts.startingUrl) 489 507 nodeTree = Node.factory(page) 490 doc.documentElement.setAttribute(" version", opts.version)508 doc.documentElement.setAttribute("startdoc", opts.startingUrl) 491 509 doc.documentElement.setAttribute("timestamp", opts.timestamp) 510 if opts.version != "": 511 doc.documentElement.setAttribute("version", opts.version) 492 512 if nodeTree == None: 493 513 errorNode = doc.createElement("error");
