| 1 |
# Symbol to module mapping |
| 2 |
# |
| 3 |
# This relies on a few tables and some regexes. |
| 4 |
|
| 5 |
import re |
| 6 |
|
| 7 |
moduleMap = { |
| 8 |
'HTMLtree': 'HTML', |
| 9 |
'HTMLparser': 'HTML', |
| 10 |
'c14n': 'C14N', |
| 11 |
'catalog': 'CATALOG', |
| 12 |
'debugXML': 'DEBUG', |
| 13 |
'nanohttp': 'HTTP', |
| 14 |
'pattern': 'PATTERN', |
| 15 |
'relaxng': 'RELAXNG', |
| 16 |
'schemasInternals': 'SCHEMAS', |
| 17 |
'schematron': 'SCHEMATRON', |
| 18 |
'xinclude': 'XINCLUDE', |
| 19 |
'xlink': 'XPTR', |
| 20 |
'xmlautomata': 'REGEXP', |
| 21 |
'xmlmodule': 'MODULES', |
| 22 |
'xmlreader': 'READER', |
| 23 |
'xmlregexp': 'REGEXP', |
| 24 |
'xmlsave': 'OUTPUT', |
| 25 |
'xmlschemas': 'SCHEMAS', |
| 26 |
'xmlschemastypes': 'SCHEMAS', |
| 27 |
'xmlwriter': 'WRITER', |
| 28 |
'xpath': 'XPATH', |
| 29 |
'xpathInternals': 'XPATH', |
| 30 |
'xpointer': 'XPTR', |
| 31 |
} |
| 32 |
|
| 33 |
symbolMap1 = { |
| 34 |
# not VALID |
| 35 |
'xmlValidateNCName': '', |
| 36 |
'xmlValidateNMToken': '', |
| 37 |
'xmlValidateName': '', |
| 38 |
'xmlValidateQName': '', |
| 39 |
|
| 40 |
'htmlDefaultSAXHandlerInit': 'HTML', |
| 41 |
'xmlSAX2InitHtmlDefaultSAXHandler': 'HTML', |
| 42 |
|
| 43 |
'xmlRegisterHTTPPostCallbacks': 'HTTP', |
| 44 |
|
| 45 |
'__xmlOutputBufferCreateFilename': 'OUTPUT', |
| 46 |
'xmlAttrSerializeTxtContent': 'OUTPUT', |
| 47 |
'xmlUTF8ToIsolat1': 'OUTPUT', |
| 48 |
'xmlSprintfElementContent': 'OUTPUT', |
| 49 |
|
| 50 |
'xmlCreatePushParserCtxt': 'PUSH', |
| 51 |
'xmlParseChunk': 'PUSH', |
| 52 |
|
| 53 |
'xmlParseBalancedChunkMemory': 'SAX1', |
| 54 |
'xmlParseBalancedChunkMemoryRecover': 'SAX1', |
| 55 |
'xmlParseDoc': 'SAX1', |
| 56 |
'xmlParseEntity': 'SAX1', |
| 57 |
'xmlParseExternalEntity': 'SAX1', |
| 58 |
'xmlParseFile': 'SAX1', |
| 59 |
'xmlParseMemory': 'SAX1', |
| 60 |
'xmlSAXDefaultVersion': 'SAX1', |
| 61 |
'xmlSetupParserForBuffer': 'SAX1', |
| 62 |
|
| 63 |
'xmlCtxtGetValidCtxt': 'VALID', |
| 64 |
'xmlFreeValidCtxt': 'VALID', |
| 65 |
'xmlNewValidCtxt': 'VALID', |
| 66 |
|
| 67 |
'xmlCatalogConvert': 'SGML_CATALOG', |
| 68 |
'xmlConvertSGMLCatalog': 'SGML_CATALOG', |
| 69 |
'xmlLoadSGMLSuperCatalog': 'SGML_CATALOG', |
| 70 |
} |
| 71 |
|
| 72 |
symbolMap2 = { |
| 73 |
# not OUTPUT (should be fixed in xmlIO.h) |
| 74 |
'xmlOutputBufferCreateFilenameDefault': '', |
| 75 |
|
| 76 |
'xmlXPathDebugDumpCompExpr': 'DEBUG', |
| 77 |
'xmlXPathDebugDumpObject': 'DEBUG', |
| 78 |
'xmlSchemaDump': 'DEBUG', |
| 79 |
'xmlRelaxNGDump': 'DEBUG', |
| 80 |
|
| 81 |
'xmlACatalogDump': 'OUTPUT', |
| 82 |
'xmlCatalogDump': 'OUTPUT', |
| 83 |
'xmlIOHTTPOpenW': 'OUTPUT', |
| 84 |
'xmlNanoHTTPSave': 'OUTPUT', |
| 85 |
'xmlRegisterHTTPPostCallbacks': 'OUTPUT', |
| 86 |
'xmlRelaxNGDumpTree': 'OUTPUT', |
| 87 |
|
| 88 |
'xmlTextReaderPreservePattern': 'PATTERN', |
| 89 |
|
| 90 |
'htmlCreatePushParserCtxt': 'PUSH', |
| 91 |
'htmlParseChunk': 'PUSH', |
| 92 |
|
| 93 |
'xmlValidBuildContentModel': 'REGEXP', |
| 94 |
'xmlValidatePopElement': 'REGEXP', |
| 95 |
'xmlValidatePushCData': 'REGEXP', |
| 96 |
'xmlValidatePushElement': 'REGEXP', |
| 97 |
|
| 98 |
'xmlTextReaderRelaxNGSetSchema': 'RELAXNG', |
| 99 |
'xmlTextReaderRelaxNGValidate': 'RELAXNG', |
| 100 |
'xmlTextReaderRelaxNGValidateCtxt': 'RELAXNG', |
| 101 |
|
| 102 |
'xmlTextReaderSchemaValidate': 'SCHEMAS', |
| 103 |
'xmlTextReaderSchemaValidateCtxt': 'SCHEMAS', |
| 104 |
'xmlTextReaderSetSchema': 'SCHEMAS', |
| 105 |
|
| 106 |
'xmlTextReaderReadInnerXml': 'WRITER', |
| 107 |
'xmlTextReaderReadOuterXml': 'WRITER', |
| 108 |
} |
| 109 |
|
| 110 |
outputRegex = '|'.join(( |
| 111 |
'^(html|xml(Buf)?)(Doc(Content|Format)?|Elem|Node)Dump', |
| 112 |
'^(html|xml)Save(Format)?File', |
| 113 |
'^xmlDump.*(Decl|Table)', |
| 114 |
'^xml(Alloc)?OutputBuffer', |
| 115 |
'^xml.*OutputCallbacks', |
| 116 |
)) |
| 117 |
|
| 118 |
def findModules(filename, symbol): |
| 119 |
module1 = symbolMap1.get(symbol) |
| 120 |
|
| 121 |
if module1 is None: |
| 122 |
module1 = moduleMap.get(filename) |
| 123 |
|
| 124 |
if module1 is None: |
| 125 |
if re.search('^xml(Ctxt)?Valid|Parse(DTD|Dtd)', symbol): |
| 126 |
module1 = 'VALID' |
| 127 |
elif re.search('^xml(Recover|SAX(User)?Parse)', symbol): |
| 128 |
module1 = 'SAX1' |
| 129 |
elif re.search('^xmlIOHTTP', symbol): |
| 130 |
module1 = 'HTTP' |
| 131 |
|
| 132 |
module2 = symbolMap2.get(symbol) |
| 133 |
|
| 134 |
if module2 is None: |
| 135 |
if re.search(outputRegex, symbol): |
| 136 |
if module1 is None: |
| 137 |
module1 = 'OUTPUT' |
| 138 |
else: |
| 139 |
module2 = 'OUTPUT' |
| 140 |
|
| 141 |
if module1 is None: |
| 142 |
module1 = '' |
| 143 |
if module2 is None: |
| 144 |
module2 = '' |
| 145 |
|
| 146 |
return module1, module2 |