diff options
author | scoder <none@none> | 2008-02-15 15:15:17 +0100 |
---|---|---|
committer | scoder <none@none> | 2008-02-15 15:15:17 +0100 |
commit | 512dfc5a334e971d7b83cf7978332142c5cf3eb3 (patch) | |
tree | 9c5070ac2827ab75b04b90235fab45af62ee4df8 /update-error-constants.py | |
parent | e056284013cf160ebc9cdd4f02cf4b30ac91f96c (diff) | |
download | python-lxml-512dfc5a334e971d7b83cf7978332142c5cf3eb3.tar.gz |
[svn r3305] r3525@delle: sbehnel | 2008-02-15 15:08:18 +0100
error type constants of XPath errors and XML Schema errors are not needed
--HG--
branch : trunk
Diffstat (limited to 'update-error-constants.py')
-rw-r--r-- | update-error-constants.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/update-error-constants.py b/update-error-constants.py index 5cc6de40..c607318b 100644 --- a/update-error-constants.py +++ b/update-error-constants.py @@ -22,13 +22,18 @@ ENUM_MAP = { 'xmlErrorLevel' : ('__ERROR_LEVELS', 'XML_ERR_'), 'xmlErrorDomain' : ('__ERROR_DOMAINS', 'XML_FROM_'), 'xmlParserErrors' : ('__PARSER_ERROR_TYPES', 'XML_'), - 'xmlXPathError' : ('__XPATH_ERROR_TYPES', ''), - 'xmlSchemaValidError' : ('__XMLSCHEMA_ERROR_TYPES', 'XML_'), +# 'xmlXPathError' : ('__XPATH_ERROR_TYPES', ''), +# 'xmlSchemaValidError' : ('__XMLSCHEMA_ERROR_TYPES', 'XML_'), 'xmlRelaxNGValidErr' : ('__RELAXNG_ERROR_TYPES', 'XML_'), } -ENUM_ORDER = ('xmlErrorLevel', 'xmlErrorDomain', 'xmlParserErrors', - 'xmlXPathError', 'xmlSchemaValidError', 'xmlRelaxNGValidErr') +ENUM_ORDER = ( + 'xmlErrorLevel', + 'xmlErrorDomain', + 'xmlParserErrors', +# 'xmlXPathError', +# 'xmlSchemaValidError', + 'xmlRelaxNGValidErr') COMMENT = """ # This section is generated by the script '%s'. @@ -65,20 +70,23 @@ def regenerate_file(filename, result): f.write(''.join(post)) f.close() +collect_text = etree.XPath("string()") +find_enums = etree.XPath( + "//html:pre[@class = 'programlisting' and contains(text(), 'Enum')]", + namespaces = {'html' : 'http://www.w3.org/1999/xhtml'}) + def parse_enums(html_dir, html_filename, enum_dict): PARSE_ENUM_NAME = re.compile('\s*enum\s+(\w+)\s*{', re.I).match PARSE_ENUM_VALUE = re.compile('\s*=\s+([0-9]+)\s*(?::\s*(.*))?').match tree = etree.parse(os.path.join(html_dir, html_filename)) - xpath = etree.XPathEvaluator( - tree, namespaces={'html' : 'http://www.w3.org/1999/xhtml'}) - collect_text = etree.XPath("string()") - - enums = xpath.evaluate("//html:pre[@class = 'programlisting' and contains(text(), 'Enum')]") + enums = find_enums(tree) for enum in enums: enum_name = PARSE_ENUM_NAME(collect_text(enum)) - if not enum_name or enum_name not in ENUM_MAP: + if not enum_name: continue enum_name = enum_name.group(1) + if enum_name not in ENUM_MAP: + continue print "Found enum", enum_name entries = [] for child in enum: @@ -96,8 +104,8 @@ def parse_enums(html_dir, html_filename, enum_dict): enum_dict = {} parse_enums(HTML_DIR, 'libxml-xmlerror.html', enum_dict) -parse_enums(HTML_DIR, 'libxml-xpath.html', enum_dict) -parse_enums(HTML_DIR, 'libxml-xmlschemas.html', enum_dict) +#parse_enums(HTML_DIR, 'libxml-xpath.html', enum_dict) +#parse_enums(HTML_DIR, 'libxml-xmlschemas.html', enum_dict) parse_enums(HTML_DIR, 'libxml-relaxng.html', enum_dict) # regenerate source files |