diff -r d8fccb2cd802 -r 468f4c8d3d5b Orb/python/orb/lib.py --- a/Orb/python/orb/lib.py Fri Apr 23 20:47:58 2010 +0100 +++ b/Orb/python/orb/lib.py Wed Aug 11 14:49:30 2010 +0100 @@ -17,9 +17,18 @@ import sys from optparse import OptionParser from cStringIO import StringIO -from xml.etree import ElementTree as etree +try: + from xml.etree import cElementTree as etree +except ImportError: + from xml.etree import ElementTree as etree + nmtoken_regex = re.compile("[^a-zA-Z0-9_\.]") +# Version to use in the DOCTYPE declaration +# Should match regex: v(\d+)\.(\d+)\.(\d+)(\S*) +# See Doxygen ditaelementprefix.cpp +#const char *DOCTYPE_VERSION = "v0.6.0"; +doctype_version = "v0.6.0" def scan(dir): for root, _, files in os.walk(dir): @@ -51,17 +60,17 @@ return """""" # cxxapiref DITA specialisation Doctype Identifiers elif doctype == "cxxUnion": - return """""" + return """""" % doctype_version elif doctype == "cxxStruct": - return """""" + return """""" % doctype_version elif doctype == "cxxPackage": - return """""" + return """""" % doctype_version elif doctype == "cxxFile": - return """""" + return """""" % doctype_version elif doctype == "cxxClass": - return """""" + return """""" % doctype_version elif doctype == "cxxAPIMap": - return """""" + return """""" % doctype_version else: raise Exception('Unknown Doctype \"%s\"' % doctype) @@ -83,7 +92,8 @@ def parse(self, xmlfile): try: root = etree.parse(xmlfile).getroot() - except xml.parsers.expat.ExpatError, e: + except Exception, e: + #except xml.parsers.expat.ExpatError, e: sys.stderr.write("ERROR: %s could not be parse: %s\n" % (xmlfile, str(e))) return "" if 'id' not in root.attrib: @@ -93,7 +103,7 @@ def main(func, version): usage = "usage: %prog " parser = OptionParser(usage, version='%prog ' + version) - (options, args) = parser.parse_args() + (_, args) = parser.parse_args() if len(args) < 1: parser.print_help() parser.error("Please supply the path to the XML content") @@ -135,22 +145,22 @@ self.assertEquals(doctype_identifier("bookmap"), """""") def test_i_can_return_a_cxxUnion_doctype_identifier(self): - self.assertEquals(doctype_identifier("cxxUnion"), """""") + self.assertEquals(doctype_identifier("cxxUnion"), """""" % doctype_version) def test_i_can_return_a_cxxStruct_doctype_identifier(self): - self.assertEquals(doctype_identifier("cxxStruct"), """""") + self.assertEquals(doctype_identifier("cxxStruct"), """""" % doctype_version) def test_i_can_return_a_cxxPackage_doctype_identifier(self): - self.assertEquals(doctype_identifier("cxxPackage"), """""") + self.assertEquals(doctype_identifier("cxxPackage"), """""" % doctype_version) def test_i_can_return_a_cxxFile_doctype_identifier(self): - self.assertEquals(doctype_identifier("cxxFile"), """""") + self.assertEquals(doctype_identifier("cxxFile"), """""" % doctype_version) def test_i_can_return_a_cxxClass_doctype_identifier(self): - self.assertEquals(doctype_identifier("cxxClass"), """""") + self.assertEquals(doctype_identifier("cxxClass"), """""" % doctype_version) def test_i_can_return_a_cxxAPIMap_doctype_identifier(self): - self.assertEquals(doctype_identifier("cxxAPIMap"), """""") + self.assertEquals(doctype_identifier("cxxAPIMap"), """""" % doctype_version) class Testget_valid_nmtoken(unittest.TestCase): @@ -189,17 +199,17 @@ self.assertTrue(id == "class_c_active_scheduler") brokencxxclass = """ - + CActiveScheduler -""" +""" % doctype_version cxxclass = """ - + CActiveScheduler -""" \ No newline at end of file +""" % doctype_version \ No newline at end of file