mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
First pass at starting porting to python3
This commit is contained in:
@ -47,19 +47,19 @@ class docParser(xml.sax.handler.ContentHandler):
|
|||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if debug:
|
if debug:
|
||||||
print "close"
|
print("close")
|
||||||
|
|
||||||
def getmethodname(self):
|
def getmethodname(self):
|
||||||
return self._methodname
|
return self._methodname
|
||||||
|
|
||||||
def data(self, text):
|
def data(self, text):
|
||||||
if debug:
|
if debug:
|
||||||
print "data %s" % text
|
print("data %s" % text)
|
||||||
self._data.append(text)
|
self._data.append(text)
|
||||||
|
|
||||||
def start(self, tag, attrs):
|
def start(self, tag, attrs):
|
||||||
if debug:
|
if debug:
|
||||||
print "start %s, %s" % (tag, attrs)
|
print("start %s, %s" % (tag, attrs))
|
||||||
if tag == 'function':
|
if tag == 'function':
|
||||||
self._data = []
|
self._data = []
|
||||||
self.in_function = 1
|
self.in_function = 1
|
||||||
@ -69,9 +69,9 @@ class docParser(xml.sax.handler.ContentHandler):
|
|||||||
self.function_descr = None
|
self.function_descr = None
|
||||||
self.function_return = None
|
self.function_return = None
|
||||||
self.function_file = None
|
self.function_file = None
|
||||||
if attrs.has_key('name'):
|
if 'name' in attrs.keys():
|
||||||
self.function = attrs['name']
|
self.function = attrs['name']
|
||||||
if attrs.has_key('file'):
|
if 'file' in attrs.keys():
|
||||||
self.function_file = attrs['file']
|
self.function_file = attrs['file']
|
||||||
elif tag == 'cond':
|
elif tag == 'cond':
|
||||||
self._data = []
|
self._data = []
|
||||||
@ -82,29 +82,29 @@ class docParser(xml.sax.handler.ContentHandler):
|
|||||||
self.function_arg_name = None
|
self.function_arg_name = None
|
||||||
self.function_arg_type = None
|
self.function_arg_type = None
|
||||||
self.function_arg_info = None
|
self.function_arg_info = None
|
||||||
if attrs.has_key('name'):
|
if 'name' in attrs.keys():
|
||||||
self.function_arg_name = attrs['name']
|
self.function_arg_name = attrs['name']
|
||||||
if attrs.has_key('type'):
|
if 'type' in attrs.keys():
|
||||||
self.function_arg_type = attrs['type']
|
self.function_arg_type = attrs['type']
|
||||||
if attrs.has_key('info'):
|
if 'info' in attrs.keys():
|
||||||
self.function_arg_info = attrs['info']
|
self.function_arg_info = attrs['info']
|
||||||
elif tag == 'return':
|
elif tag == 'return':
|
||||||
if self.in_function == 1:
|
if self.in_function == 1:
|
||||||
self.function_return_type = None
|
self.function_return_type = None
|
||||||
self.function_return_info = None
|
self.function_return_info = None
|
||||||
self.function_return_field = None
|
self.function_return_field = None
|
||||||
if attrs.has_key('type'):
|
if 'type' in attrs.keys():
|
||||||
self.function_return_type = attrs['type']
|
self.function_return_type = attrs['type']
|
||||||
if attrs.has_key('info'):
|
if 'info' in attrs.keys():
|
||||||
self.function_return_info = attrs['info']
|
self.function_return_info = attrs['info']
|
||||||
if attrs.has_key('field'):
|
if 'field' in attrs.keys():
|
||||||
self.function_return_field = attrs['field']
|
self.function_return_field = attrs['field']
|
||||||
elif tag == 'enum':
|
elif tag == 'enum':
|
||||||
enum(attrs['type'],attrs['name'],attrs['value'])
|
enum(attrs['type'],attrs['name'],attrs['value'])
|
||||||
|
|
||||||
def end(self, tag):
|
def end(self, tag):
|
||||||
if debug:
|
if debug:
|
||||||
print "end %s" % tag
|
print("end %s" % tag)
|
||||||
if tag == 'function':
|
if tag == 'function':
|
||||||
if self.function != None:
|
if self.function != None:
|
||||||
function(self.function, self.function_descr,
|
function(self.function, self.function_descr,
|
||||||
@ -139,7 +139,7 @@ def function(name, desc, ret, args, file, cond):
|
|||||||
functions[name] = (desc, ret, args, file, cond)
|
functions[name] = (desc, ret, args, file, cond)
|
||||||
|
|
||||||
def enum(type, name, value):
|
def enum(type, name, value):
|
||||||
if not enums.has_key(type):
|
if type not in enums:
|
||||||
enums[type] = {}
|
enums[type] = {}
|
||||||
enums[type][name] = value
|
enums[type][name] = value
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ def skip_function(name):
|
|||||||
if name == "xmlValidateAttributeDecl":
|
if name == "xmlValidateAttributeDecl":
|
||||||
return 1
|
return 1
|
||||||
if name == "xmlPopInputCallbacks":
|
if name == "xmlPopInputCallbacks":
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -353,10 +353,10 @@ def print_function_wrapper(name, output, export, include):
|
|||||||
try:
|
try:
|
||||||
(desc, ret, args, file, cond) = functions[name]
|
(desc, ret, args, file, cond) = functions[name]
|
||||||
except:
|
except:
|
||||||
print "failed to get function %s infos"
|
print("failed to get function %s infos")
|
||||||
return
|
return
|
||||||
|
|
||||||
if skipped_modules.has_key(file):
|
if file in skipped_modules:
|
||||||
return 0
|
return 0
|
||||||
if skip_function(name) == 1:
|
if skip_function(name) == 1:
|
||||||
return 0
|
return 0
|
||||||
@ -376,7 +376,7 @@ def print_function_wrapper(name, output, export, include):
|
|||||||
if arg[1][0:6] == "const ":
|
if arg[1][0:6] == "const ":
|
||||||
arg[1] = arg[1][6:]
|
arg[1] = arg[1][6:]
|
||||||
c_args = c_args + " %s %s;\n" % (arg[1], arg[0])
|
c_args = c_args + " %s %s;\n" % (arg[1], arg[0])
|
||||||
if py_types.has_key(arg[1]):
|
if arg[1] in py_types:
|
||||||
(f, t, n, c) = py_types[arg[1]]
|
(f, t, n, c) = py_types[arg[1]]
|
||||||
if (f == 'z') and (name in foreign_encoding_args) and (num_bufs == 0):
|
if (f == 'z') and (name in foreign_encoding_args) and (num_bufs == 0):
|
||||||
f = 't#'
|
f = 't#'
|
||||||
@ -398,9 +398,9 @@ def print_function_wrapper(name, output, export, include):
|
|||||||
c_call = c_call + ", "
|
c_call = c_call + ", "
|
||||||
c_call = c_call + "%s" % (arg[0])
|
c_call = c_call + "%s" % (arg[0])
|
||||||
else:
|
else:
|
||||||
if skipped_types.has_key(arg[1]):
|
if arg[1] in skipped_types:
|
||||||
return 0
|
return 0
|
||||||
if unknown_types.has_key(arg[1]):
|
if arg[1] in unknown_types:
|
||||||
lst = unknown_types[arg[1]]
|
lst = unknown_types[arg[1]]
|
||||||
lst.append(name)
|
lst.append(name)
|
||||||
else:
|
else:
|
||||||
@ -422,7 +422,7 @@ def print_function_wrapper(name, output, export, include):
|
|||||||
else:
|
else:
|
||||||
c_call = "\n %s(%s);\n" % (name, c_call)
|
c_call = "\n %s(%s);\n" % (name, c_call)
|
||||||
ret_convert = " Py_INCREF(Py_None);\n return(Py_None);\n"
|
ret_convert = " Py_INCREF(Py_None);\n return(Py_None);\n"
|
||||||
elif py_types.has_key(ret[0]):
|
elif ret[0] in py_types:
|
||||||
(f, t, n, c) = py_types[ret[0]]
|
(f, t, n, c) = py_types[ret[0]]
|
||||||
c_return = " %s c_retval;\n" % (ret[0])
|
c_return = " %s c_retval;\n" % (ret[0])
|
||||||
if file == "python_accessor" and ret[2] != None:
|
if file == "python_accessor" and ret[2] != None:
|
||||||
@ -431,16 +431,16 @@ def print_function_wrapper(name, output, export, include):
|
|||||||
c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
|
c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
|
||||||
ret_convert = " py_retval = libxml_%sWrap((%s) c_retval);\n" % (n,c)
|
ret_convert = " py_retval = libxml_%sWrap((%s) c_retval);\n" % (n,c)
|
||||||
ret_convert = ret_convert + " return(py_retval);\n"
|
ret_convert = ret_convert + " return(py_retval);\n"
|
||||||
elif py_return_types.has_key(ret[0]):
|
elif ret[0] in py_return_types:
|
||||||
(f, t, n, c) = py_return_types[ret[0]]
|
(f, t, n, c) = py_return_types[ret[0]]
|
||||||
c_return = " %s c_retval;\n" % (ret[0])
|
c_return = " %s c_retval;\n" % (ret[0])
|
||||||
c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
|
c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
|
||||||
ret_convert = " py_retval = libxml_%sWrap((%s) c_retval);\n" % (n,c)
|
ret_convert = " py_retval = libxml_%sWrap((%s) c_retval);\n" % (n,c)
|
||||||
ret_convert = ret_convert + " return(py_retval);\n"
|
ret_convert = ret_convert + " return(py_retval);\n"
|
||||||
else:
|
else:
|
||||||
if skipped_types.has_key(ret[0]):
|
if ret[0] in skipped_types:
|
||||||
return 0
|
return 0
|
||||||
if unknown_types.has_key(ret[0]):
|
if ret[0] in unknown_types:
|
||||||
lst = unknown_types[ret[0]]
|
lst = unknown_types[ret[0]]
|
||||||
lst.append(name)
|
lst.append(name)
|
||||||
else:
|
else:
|
||||||
@ -512,19 +512,19 @@ def buildStubs():
|
|||||||
(parser, target) = getparser()
|
(parser, target) = getparser()
|
||||||
parser.feed(data)
|
parser.feed(data)
|
||||||
parser.close()
|
parser.close()
|
||||||
except IOError, msg:
|
except IOError as msg:
|
||||||
try:
|
try:
|
||||||
f = open(os.path.join(srcPref,"..","doc","libxml2-api.xml"))
|
f = open(os.path.join(srcPref,"..","doc","libxml2-api.xml"))
|
||||||
data = f.read()
|
data = f.read()
|
||||||
(parser, target) = getparser()
|
(parser, target) = getparser()
|
||||||
parser.feed(data)
|
parser.feed(data)
|
||||||
parser.close()
|
parser.close()
|
||||||
except IOError, msg:
|
except IOError as msg:
|
||||||
print file, ":", msg
|
print(file, ":", msg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
n = len(functions.keys())
|
n = len(list(functions.keys()))
|
||||||
print "Found %d functions in libxml2-api.xml" % (n)
|
print("Found %d functions in libxml2-api.xml" % (n))
|
||||||
|
|
||||||
py_types['pythonObject'] = ('O', "pythonObject", "pythonObject", "pythonObject")
|
py_types['pythonObject'] = ('O', "pythonObject", "pythonObject", "pythonObject")
|
||||||
try:
|
try:
|
||||||
@ -533,12 +533,12 @@ def buildStubs():
|
|||||||
(parser, target) = getparser()
|
(parser, target) = getparser()
|
||||||
parser.feed(data)
|
parser.feed(data)
|
||||||
parser.close()
|
parser.close()
|
||||||
except IOError, msg:
|
except IOError as msg:
|
||||||
print file, ":", msg
|
print(file, ":", msg)
|
||||||
|
|
||||||
|
|
||||||
print "Found %d functions in libxml2-python-api.xml" % (
|
print("Found %d functions in libxml2-python-api.xml" % (
|
||||||
len(functions.keys()) - n)
|
len(list(functions.keys())) - n))
|
||||||
nb_wrap = 0
|
nb_wrap = 0
|
||||||
failed = 0
|
failed = 0
|
||||||
skipped = 0
|
skipped = 0
|
||||||
@ -569,12 +569,12 @@ def buildStubs():
|
|||||||
export.close()
|
export.close()
|
||||||
wrapper.close()
|
wrapper.close()
|
||||||
|
|
||||||
print "Generated %d wrapper functions, %d failed, %d skipped\n" % (nb_wrap,
|
print("Generated %d wrapper functions, %d failed, %d skipped\n" % (nb_wrap,
|
||||||
failed, skipped)
|
failed, skipped))
|
||||||
print "Missing type converters: "
|
print("Missing type converters: ")
|
||||||
for type in unknown_types.keys():
|
for type in list(unknown_types.keys()):
|
||||||
print "%s:%d " % (type, len(unknown_types[type])),
|
print("%s:%d " % (type, len(unknown_types[type])))
|
||||||
print
|
print()
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
#
|
#
|
||||||
@ -699,40 +699,40 @@ def nameFixup(name, classe, type, file):
|
|||||||
l = len(classe)
|
l = len(classe)
|
||||||
if name[0:l] == listname:
|
if name[0:l] == listname:
|
||||||
func = name[l:]
|
func = name[l:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:12] == "xmlParserGet" and file == "python_accessor":
|
elif name[0:12] == "xmlParserGet" and file == "python_accessor":
|
||||||
func = name[12:]
|
func = name[12:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:12] == "xmlParserSet" and file == "python_accessor":
|
elif name[0:12] == "xmlParserSet" and file == "python_accessor":
|
||||||
func = name[12:]
|
func = name[12:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:10] == "xmlNodeGet" and file == "python_accessor":
|
elif name[0:10] == "xmlNodeGet" and file == "python_accessor":
|
||||||
func = name[10:]
|
func = name[10:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:9] == "xmlURIGet" and file == "python_accessor":
|
elif name[0:9] == "xmlURIGet" and file == "python_accessor":
|
||||||
func = name[9:]
|
func = name[9:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:9] == "xmlURISet" and file == "python_accessor":
|
elif name[0:9] == "xmlURISet" and file == "python_accessor":
|
||||||
func = name[6:]
|
func = name[6:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:11] == "xmlErrorGet" and file == "python_accessor":
|
elif name[0:11] == "xmlErrorGet" and file == "python_accessor":
|
||||||
func = name[11:]
|
func = name[11:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:17] == "xmlXPathParserGet" and file == "python_accessor":
|
elif name[0:17] == "xmlXPathParserGet" and file == "python_accessor":
|
||||||
func = name[17:]
|
func = name[17:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:11] == "xmlXPathGet" and file == "python_accessor":
|
elif name[0:11] == "xmlXPathGet" and file == "python_accessor":
|
||||||
func = name[11:]
|
func = name[11:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:11] == "xmlXPathSet" and file == "python_accessor":
|
elif name[0:11] == "xmlXPathSet" and file == "python_accessor":
|
||||||
func = name[8:]
|
func = name[8:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:15] == "xmlOutputBuffer" and file != "python":
|
elif name[0:15] == "xmlOutputBuffer" and file != "python":
|
||||||
func = name[15:]
|
func = name[15:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:20] == "xmlParserInputBuffer" and file != "python":
|
elif name[0:20] == "xmlParserInputBuffer" and file != "python":
|
||||||
func = name[20:]
|
func = name[20:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:9] == "xmlRegexp" and file == "xmlregexp":
|
elif name[0:9] == "xmlRegexp" and file == "xmlregexp":
|
||||||
func = "regexp" + name[9:]
|
func = "regexp" + name[9:]
|
||||||
elif name[0:6] == "xmlReg" and file == "xmlregexp":
|
elif name[0:6] == "xmlReg" and file == "xmlregexp":
|
||||||
@ -747,19 +747,19 @@ def nameFixup(name, classe, type, file):
|
|||||||
func = name[9:]
|
func = name[9:]
|
||||||
elif name[0:11] == "xmlACatalog":
|
elif name[0:11] == "xmlACatalog":
|
||||||
func = name[11:]
|
func = name[11:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:l] == classe:
|
elif name[0:l] == classe:
|
||||||
func = name[l:]
|
func = name[l:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:7] == "libxml_":
|
elif name[0:7] == "libxml_":
|
||||||
func = name[7:]
|
func = name[7:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:6] == "xmlGet":
|
elif name[0:6] == "xmlGet":
|
||||||
func = name[6:]
|
func = name[6:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
elif name[0:3] == "xml":
|
elif name[0:3] == "xml":
|
||||||
func = name[3:]
|
func = name[3:]
|
||||||
func = string.lower(func[0:1]) + func[1:]
|
func = func[0:1].lower() + func[1:]
|
||||||
else:
|
else:
|
||||||
func = name
|
func = name
|
||||||
if func[0:5] == "xPath":
|
if func[0:5] == "xPath":
|
||||||
@ -797,11 +797,29 @@ def functionCompare(info1, info2):
|
|||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def cmp_to_key(mycmp):
|
||||||
|
'Convert a cmp= function into a key= function'
|
||||||
|
class K(object):
|
||||||
|
def __init__(self, obj, *args):
|
||||||
|
self.obj = obj
|
||||||
|
def __lt__(self, other):
|
||||||
|
return mycmp(self.obj, other.obj) < 0
|
||||||
|
def __gt__(self, other):
|
||||||
|
return mycmp(self.obj, other.obj) > 0
|
||||||
|
def __eq__(self, other):
|
||||||
|
return mycmp(self.obj, other.obj) == 0
|
||||||
|
def __le__(self, other):
|
||||||
|
return mycmp(self.obj, other.obj) <= 0
|
||||||
|
def __ge__(self, other):
|
||||||
|
return mycmp(self.obj, other.obj) >= 0
|
||||||
|
def __ne__(self, other):
|
||||||
|
return mycmp(self.obj, other.obj) != 0
|
||||||
|
return K
|
||||||
def writeDoc(name, args, indent, output):
|
def writeDoc(name, args, indent, output):
|
||||||
if functions[name][0] is None or functions[name][0] == "":
|
if functions[name][0] is None or functions[name][0] == "":
|
||||||
return
|
return
|
||||||
val = functions[name][0]
|
val = functions[name][0]
|
||||||
val = string.replace(val, "NULL", "None")
|
val = val.replace("NULL", "None")
|
||||||
output.write(indent)
|
output.write(indent)
|
||||||
output.write('"""')
|
output.write('"""')
|
||||||
while len(val) > 60:
|
while len(val) > 60:
|
||||||
@ -809,7 +827,7 @@ def writeDoc(name, args, indent, output):
|
|||||||
val = val[1:]
|
val = val[1:]
|
||||||
continue
|
continue
|
||||||
str = val[0:60]
|
str = val[0:60]
|
||||||
i = string.rfind(str, " ")
|
i = str.rfind(" ")
|
||||||
if i < 0:
|
if i < 0:
|
||||||
i = 60
|
i = 60
|
||||||
str = val[0:i]
|
str = val[0:i]
|
||||||
@ -859,13 +877,13 @@ def buildWrappers():
|
|||||||
ctypes.append(type)
|
ctypes.append(type)
|
||||||
ctypes_processed[type] = ()
|
ctypes_processed[type] = ()
|
||||||
for type in sorted(classes_type.keys()):
|
for type in sorted(classes_type.keys()):
|
||||||
if ctypes_processed.has_key(type):
|
if type in ctypes_processed:
|
||||||
continue
|
continue
|
||||||
tinfo = classes_type[type]
|
tinfo = classes_type[type]
|
||||||
if not classes_processed.has_key(tinfo[2]):
|
if tinfo[2] not in classes_processed:
|
||||||
classes_list.append(tinfo[2])
|
classes_list.append(tinfo[2])
|
||||||
classes_processed[tinfo[2]] = ()
|
classes_processed[tinfo[2]] = ()
|
||||||
|
|
||||||
ctypes.append(type)
|
ctypes.append(type)
|
||||||
ctypes_processed[type] = ()
|
ctypes_processed[type] = ()
|
||||||
|
|
||||||
@ -914,9 +932,9 @@ def buildWrappers():
|
|||||||
txt.write(" Generated Classes for libxml2-python\n\n")
|
txt.write(" Generated Classes for libxml2-python\n\n")
|
||||||
|
|
||||||
txt.write("#\n# Global functions of the module\n#\n\n")
|
txt.write("#\n# Global functions of the module\n#\n\n")
|
||||||
if function_classes.has_key("None"):
|
if "None" in function_classes:
|
||||||
flist = function_classes["None"]
|
flist = function_classes["None"]
|
||||||
flist.sort(functionCompare)
|
flist = sorted(flist, key=cmp_to_key(functionCompare))
|
||||||
oldfile = ""
|
oldfile = ""
|
||||||
for info in flist:
|
for info in flist:
|
||||||
(index, func, name, ret, args, file) = info
|
(index, func, name, ret, args, file) = info
|
||||||
@ -936,7 +954,7 @@ def buildWrappers():
|
|||||||
writeDoc(name, args, ' ', classes)
|
writeDoc(name, args, ' ', classes)
|
||||||
|
|
||||||
for arg in args:
|
for arg in args:
|
||||||
if classes_type.has_key(arg[1]):
|
if arg[1] in classes_type:
|
||||||
classes.write(" if %s is None: %s__o = None\n" %
|
classes.write(" if %s is None: %s__o = None\n" %
|
||||||
(arg[0], arg[0]))
|
(arg[0], arg[0]))
|
||||||
classes.write(" else: %s__o = %s%s\n" %
|
classes.write(" else: %s__o = %s%s\n" %
|
||||||
@ -951,26 +969,26 @@ def buildWrappers():
|
|||||||
if n != 0:
|
if n != 0:
|
||||||
classes.write(", ")
|
classes.write(", ")
|
||||||
classes.write("%s" % arg[0])
|
classes.write("%s" % arg[0])
|
||||||
if classes_type.has_key(arg[1]):
|
if arg[1] in classes_type:
|
||||||
classes.write("__o")
|
classes.write("__o")
|
||||||
n = n + 1
|
n = n + 1
|
||||||
classes.write(")\n")
|
classes.write(")\n")
|
||||||
if ret[0] != "void":
|
if ret[0] != "void":
|
||||||
if classes_type.has_key(ret[0]):
|
if ret[0] in classes_type:
|
||||||
#
|
#
|
||||||
# Raise an exception
|
# Raise an exception
|
||||||
#
|
#
|
||||||
if functions_noexcept.has_key(name):
|
if name in functions_noexcept:
|
||||||
classes.write(" if ret is None:return None\n")
|
classes.write(" if ret is None:return None\n")
|
||||||
elif string.find(name, "URI") >= 0:
|
elif name.find("URI") >= 0:
|
||||||
classes.write(
|
classes.write(
|
||||||
" if ret is None:raise uriError('%s() failed')\n"
|
" if ret is None:raise uriError('%s() failed')\n"
|
||||||
% (name))
|
% (name))
|
||||||
elif string.find(name, "XPath") >= 0:
|
elif name.find("XPath") >= 0:
|
||||||
classes.write(
|
classes.write(
|
||||||
" if ret is None:raise xpathError('%s() failed')\n"
|
" if ret is None:raise xpathError('%s() failed')\n"
|
||||||
% (name))
|
% (name))
|
||||||
elif string.find(name, "Parse") >= 0:
|
elif name.find("Parse") >= 0:
|
||||||
classes.write(
|
classes.write(
|
||||||
" if ret is None:raise parserError('%s() failed')\n"
|
" if ret is None:raise parserError('%s() failed')\n"
|
||||||
% (name))
|
% (name))
|
||||||
@ -990,7 +1008,7 @@ def buildWrappers():
|
|||||||
if classname == "None":
|
if classname == "None":
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if classes_ancestor.has_key(classname):
|
if classname in classes_ancestor:
|
||||||
txt.write("\n\nClass %s(%s)\n" % (classname,
|
txt.write("\n\nClass %s(%s)\n" % (classname,
|
||||||
classes_ancestor[classname]))
|
classes_ancestor[classname]))
|
||||||
classes.write("class %s(%s):\n" % (classname,
|
classes.write("class %s(%s):\n" % (classname,
|
||||||
@ -1003,7 +1021,7 @@ def buildWrappers():
|
|||||||
classes.write(" raise TypeError, ")
|
classes.write(" raise TypeError, ")
|
||||||
classes.write("'%s needs a PyCObject argument'\n" % \
|
classes.write("'%s needs a PyCObject argument'\n" % \
|
||||||
classname)
|
classname)
|
||||||
if reference_keepers.has_key(classname):
|
if classname in reference_keepers:
|
||||||
rlist = reference_keepers[classname]
|
rlist = reference_keepers[classname]
|
||||||
for ref in rlist:
|
for ref in rlist:
|
||||||
classes.write(" self.%s = None\n" % ref[1])
|
classes.write(" self.%s = None\n" % ref[1])
|
||||||
@ -1020,14 +1038,14 @@ def buildWrappers():
|
|||||||
txt.write("Class %s()\n" % (classname))
|
txt.write("Class %s()\n" % (classname))
|
||||||
classes.write("class %s:\n" % (classname))
|
classes.write("class %s:\n" % (classname))
|
||||||
classes.write(" def __init__(self, _obj=None):\n")
|
classes.write(" def __init__(self, _obj=None):\n")
|
||||||
if reference_keepers.has_key(classname):
|
if classname in reference_keepers:
|
||||||
list = reference_keepers[classname]
|
list = reference_keepers[classname]
|
||||||
for ref in list:
|
for ref in list:
|
||||||
classes.write(" self.%s = None\n" % ref[1])
|
classes.write(" self.%s = None\n" % ref[1])
|
||||||
classes.write(" if _obj != None:self._o = _obj;return\n")
|
classes.write(" if _obj != None:self._o = _obj;return\n")
|
||||||
classes.write(" self._o = None\n\n")
|
classes.write(" self._o = None\n\n")
|
||||||
destruct=None
|
destruct=None
|
||||||
if classes_destructors.has_key(classname):
|
if classname in classes_destructors:
|
||||||
classes.write(" def __del__(self):\n")
|
classes.write(" def __del__(self):\n")
|
||||||
classes.write(" if self._o != None:\n")
|
classes.write(" if self._o != None:\n")
|
||||||
classes.write(" libxml2mod.%s(self._o)\n" %
|
classes.write(" libxml2mod.%s(self._o)\n" %
|
||||||
@ -1035,7 +1053,7 @@ def buildWrappers():
|
|||||||
classes.write(" self._o = None\n\n")
|
classes.write(" self._o = None\n\n")
|
||||||
destruct=classes_destructors[classname]
|
destruct=classes_destructors[classname]
|
||||||
flist = function_classes[classname]
|
flist = function_classes[classname]
|
||||||
flist.sort(functionCompare)
|
flist = sorted(flist, key=cmp_to_key(functionCompare))
|
||||||
oldfile = ""
|
oldfile = ""
|
||||||
for info in flist:
|
for info in flist:
|
||||||
(index, func, name, ret, args, file) = info
|
(index, func, name, ret, args, file) = info
|
||||||
@ -1067,7 +1085,7 @@ def buildWrappers():
|
|||||||
writeDoc(name, args, ' ', classes)
|
writeDoc(name, args, ' ', classes)
|
||||||
n = 0
|
n = 0
|
||||||
for arg in args:
|
for arg in args:
|
||||||
if classes_type.has_key(arg[1]):
|
if arg[1] in classes_type:
|
||||||
if n != index:
|
if n != index:
|
||||||
classes.write(" if %s is None: %s__o = None\n" %
|
classes.write(" if %s is None: %s__o = None\n" %
|
||||||
(arg[0], arg[0]))
|
(arg[0], arg[0]))
|
||||||
@ -1085,31 +1103,31 @@ def buildWrappers():
|
|||||||
classes.write(", ")
|
classes.write(", ")
|
||||||
if n != index:
|
if n != index:
|
||||||
classes.write("%s" % arg[0])
|
classes.write("%s" % arg[0])
|
||||||
if classes_type.has_key(arg[1]):
|
if arg[1] in classes_type:
|
||||||
classes.write("__o")
|
classes.write("__o")
|
||||||
else:
|
else:
|
||||||
classes.write("self")
|
classes.write("self")
|
||||||
if classes_type.has_key(arg[1]):
|
if arg[1] in classes_type:
|
||||||
classes.write(classes_type[arg[1]][0])
|
classes.write(classes_type[arg[1]][0])
|
||||||
n = n + 1
|
n = n + 1
|
||||||
classes.write(")\n")
|
classes.write(")\n")
|
||||||
if ret[0] != "void":
|
if ret[0] != "void":
|
||||||
if classes_type.has_key(ret[0]):
|
if ret[0] in classes_type:
|
||||||
#
|
#
|
||||||
# Raise an exception
|
# Raise an exception
|
||||||
#
|
#
|
||||||
if functions_noexcept.has_key(name):
|
if name in functions_noexcept:
|
||||||
classes.write(
|
classes.write(
|
||||||
" if ret is None:return None\n")
|
" if ret is None:return None\n")
|
||||||
elif string.find(name, "URI") >= 0:
|
elif name.find("URI") >= 0:
|
||||||
classes.write(
|
classes.write(
|
||||||
" if ret is None:raise uriError('%s() failed')\n"
|
" if ret is None:raise uriError('%s() failed')\n"
|
||||||
% (name))
|
% (name))
|
||||||
elif string.find(name, "XPath") >= 0:
|
elif name.find("XPath") >= 0:
|
||||||
classes.write(
|
classes.write(
|
||||||
" if ret is None:raise xpathError('%s() failed')\n"
|
" if ret is None:raise xpathError('%s() failed')\n"
|
||||||
% (name))
|
% (name))
|
||||||
elif string.find(name, "Parse") >= 0:
|
elif name.find("Parse") >= 0:
|
||||||
classes.write(
|
classes.write(
|
||||||
" if ret is None:raise parserError('%s() failed')\n"
|
" if ret is None:raise parserError('%s() failed')\n"
|
||||||
% (name))
|
% (name))
|
||||||
@ -1131,7 +1149,7 @@ def buildWrappers():
|
|||||||
# See reference_keepers for the list
|
# See reference_keepers for the list
|
||||||
#
|
#
|
||||||
tclass = classes_type[ret[0]][2]
|
tclass = classes_type[ret[0]][2]
|
||||||
if reference_keepers.has_key(tclass):
|
if tclass in reference_keepers:
|
||||||
list = reference_keepers[tclass]
|
list = reference_keepers[tclass]
|
||||||
for pref in list:
|
for pref in list:
|
||||||
if pref[0] == classname:
|
if pref[0] == classname:
|
||||||
@ -1141,22 +1159,22 @@ def buildWrappers():
|
|||||||
# return the class
|
# return the class
|
||||||
#
|
#
|
||||||
classes.write(" return __tmp\n")
|
classes.write(" return __tmp\n")
|
||||||
elif converter_type.has_key(ret[0]):
|
elif ret[0] in converter_type:
|
||||||
#
|
#
|
||||||
# Raise an exception
|
# Raise an exception
|
||||||
#
|
#
|
||||||
if functions_noexcept.has_key(name):
|
if name in functions_noexcept:
|
||||||
classes.write(
|
classes.write(
|
||||||
" if ret is None:return None")
|
" if ret is None:return None")
|
||||||
elif string.find(name, "URI") >= 0:
|
elif name.find("URI") >= 0:
|
||||||
classes.write(
|
classes.write(
|
||||||
" if ret is None:raise uriError('%s() failed')\n"
|
" if ret is None:raise uriError('%s() failed')\n"
|
||||||
% (name))
|
% (name))
|
||||||
elif string.find(name, "XPath") >= 0:
|
elif name.find("XPath") >= 0:
|
||||||
classes.write(
|
classes.write(
|
||||||
" if ret is None:raise xpathError('%s() failed')\n"
|
" if ret is None:raise xpathError('%s() failed')\n"
|
||||||
% (name))
|
% (name))
|
||||||
elif string.find(name, "Parse") >= 0:
|
elif name.find("Parse") >= 0:
|
||||||
classes.write(
|
classes.write(
|
||||||
" if ret is None:raise parserError('%s() failed')\n"
|
" if ret is None:raise parserError('%s() failed')\n"
|
||||||
% (name))
|
% (name))
|
||||||
@ -1177,7 +1195,7 @@ def buildWrappers():
|
|||||||
for type,enum in enums.items():
|
for type,enum in enums.items():
|
||||||
classes.write("# %s\n" % type)
|
classes.write("# %s\n" % type)
|
||||||
items = enum.items()
|
items = enum.items()
|
||||||
items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
|
items = sorted(items, key=(lambda i: int(i[1])))
|
||||||
for name,value in items:
|
for name,value in items:
|
||||||
classes.write("%s = %s\n" % (name,value))
|
classes.write("%s = %s\n" % (name,value))
|
||||||
classes.write("\n")
|
classes.write("\n")
|
||||||
|
@ -11,7 +11,7 @@ class libxmlError(Exception): pass
|
|||||||
def pos_id(o):
|
def pos_id(o):
|
||||||
i = id(o)
|
i = id(o)
|
||||||
if (i < 0):
|
if (i < 0):
|
||||||
return (sys.maxint - i)
|
return (sys.maxsize - i)
|
||||||
return i
|
return i
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -79,7 +79,7 @@ class ioReadWrapper(ioWrapper):
|
|||||||
self._o = libxml2mod.xmlCreateInputBuffer(self, enc)
|
self._o = libxml2mod.xmlCreateInputBuffer(self, enc)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
print "__del__"
|
print("__del__")
|
||||||
self.io_close()
|
self.io_close()
|
||||||
if self._o != None:
|
if self._o != None:
|
||||||
libxml2mod.xmlFreeParserInputBuffer(self._o)
|
libxml2mod.xmlFreeParserInputBuffer(self._o)
|
||||||
@ -95,10 +95,10 @@ class ioWriteWrapper(ioWrapper):
|
|||||||
def __init__(self, _obj, enc = ""):
|
def __init__(self, _obj, enc = ""):
|
||||||
# print "ioWriteWrapper.__init__", _obj
|
# print "ioWriteWrapper.__init__", _obj
|
||||||
if type(_obj) == type(''):
|
if type(_obj) == type(''):
|
||||||
print "write io from a string"
|
print("write io from a string")
|
||||||
self.o = None
|
self.o = None
|
||||||
elif type(_obj) == types.InstanceType:
|
elif type(_obj) == types.InstanceType:
|
||||||
print "write io from instance of %s" % (_obj.__class__)
|
print("write io from instance of %s" % (_obj.__class__))
|
||||||
ioWrapper.__init__(self, _obj)
|
ioWrapper.__init__(self, _obj)
|
||||||
self._o = libxml2mod.xmlCreateOutputBuffer(self, enc)
|
self._o = libxml2mod.xmlCreateOutputBuffer(self, enc)
|
||||||
else:
|
else:
|
||||||
@ -357,7 +357,7 @@ class xmlCore:
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
return xmlDoc(_obj=ret)
|
return xmlDoc(_obj=ret)
|
||||||
raise AttributeError,attr
|
raise AttributeError(attr)
|
||||||
else:
|
else:
|
||||||
parent = property(get_parent, None, None, "Parent node")
|
parent = property(get_parent, None, None, "Parent node")
|
||||||
children = property(get_children, None, None, "First child node")
|
children = property(get_children, None, None, "First child node")
|
||||||
@ -400,7 +400,7 @@ class xmlCore:
|
|||||||
prefixes=None,
|
prefixes=None,
|
||||||
with_comments=0):
|
with_comments=0):
|
||||||
if nodes:
|
if nodes:
|
||||||
nodes = map(lambda n: n._o, nodes)
|
nodes = [n._o for n in nodes]
|
||||||
return libxml2mod.xmlC14NDocDumpMemory(
|
return libxml2mod.xmlC14NDocDumpMemory(
|
||||||
self.get_doc()._o,
|
self.get_doc()._o,
|
||||||
nodes,
|
nodes,
|
||||||
@ -414,7 +414,7 @@ class xmlCore:
|
|||||||
prefixes=None,
|
prefixes=None,
|
||||||
with_comments=0):
|
with_comments=0):
|
||||||
if nodes:
|
if nodes:
|
||||||
nodes = map(lambda n: n._o, nodes)
|
nodes = [n._o for n in nodes]
|
||||||
return libxml2mod.xmlC14NDocSaveTo(
|
return libxml2mod.xmlC14NDocSaveTo(
|
||||||
self.get_doc()._o,
|
self.get_doc()._o,
|
||||||
nodes,
|
nodes,
|
||||||
@ -502,7 +502,7 @@ class xmlCoreDepthFirstItertor:
|
|||||||
self.parents = []
|
self.parents = []
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return self
|
||||||
def next(self):
|
def __next__(self):
|
||||||
while 1:
|
while 1:
|
||||||
if self.node:
|
if self.node:
|
||||||
ret = self.node
|
ret = self.node
|
||||||
@ -513,7 +513,7 @@ class xmlCoreDepthFirstItertor:
|
|||||||
parent = self.parents.pop()
|
parent = self.parents.pop()
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
self.node = parent.next
|
self.node = parent.__next__
|
||||||
|
|
||||||
#
|
#
|
||||||
# implements the breadth-first iterator for libxml2 DOM tree
|
# implements the breadth-first iterator for libxml2 DOM tree
|
||||||
@ -524,12 +524,12 @@ class xmlCoreBreadthFirstItertor:
|
|||||||
self.parents = []
|
self.parents = []
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return self
|
||||||
def next(self):
|
def __next__(self):
|
||||||
while 1:
|
while 1:
|
||||||
if self.node:
|
if self.node:
|
||||||
ret = self.node
|
ret = self.node
|
||||||
self.parents.append(self.node)
|
self.parents.append(self.node)
|
||||||
self.node = self.node.next
|
self.node = self.node.__next__
|
||||||
return ret
|
return ret
|
||||||
try:
|
try:
|
||||||
parent = self.parents.pop()
|
parent = self.parents.pop()
|
||||||
@ -564,10 +564,10 @@ def nodeWrap(o):
|
|||||||
def xpathObjectRet(o):
|
def xpathObjectRet(o):
|
||||||
otype = type(o)
|
otype = type(o)
|
||||||
if otype == type([]):
|
if otype == type([]):
|
||||||
ret = map(xpathObjectRet, o)
|
ret = list(map(xpathObjectRet, o))
|
||||||
return ret
|
return ret
|
||||||
elif otype == type(()):
|
elif otype == type(()):
|
||||||
ret = map(xpathObjectRet, o)
|
ret = list(map(xpathObjectRet, o))
|
||||||
return tuple(ret)
|
return tuple(ret)
|
||||||
elif otype == type('') or otype == type(0) or otype == type(0.0):
|
elif otype == type('') or otype == type(0) or otype == type(0.0):
|
||||||
return o
|
return o
|
||||||
@ -603,7 +603,7 @@ def registerErrorHandler(f, ctx):
|
|||||||
"""Register a Python written function to for error reporting.
|
"""Register a Python written function to for error reporting.
|
||||||
The function is called back as f(ctx, error). """
|
The function is called back as f(ctx, error). """
|
||||||
import sys
|
import sys
|
||||||
if not sys.modules.has_key('libxslt'):
|
if 'libxslt' not in sys.modules:
|
||||||
# normal behaviour when libxslt is not imported
|
# normal behaviour when libxslt is not imported
|
||||||
ret = libxml2mod.xmlRegisterErrorHandler(f,ctx)
|
ret = libxml2mod.xmlRegisterErrorHandler(f,ctx)
|
||||||
else:
|
else:
|
||||||
@ -682,8 +682,9 @@ class relaxNgValidCtxtCore:
|
|||||||
libxml2mod.xmlRelaxNGSetValidErrors(self._o, err_func, warn_func, arg)
|
libxml2mod.xmlRelaxNGSetValidErrors(self._o, err_func, warn_func, arg)
|
||||||
|
|
||||||
|
|
||||||
def _xmlTextReaderErrorFunc((f,arg),msg,severity,locator):
|
def _xmlTextReaderErrorFunc(xxx_todo_changeme,msg,severity,locator):
|
||||||
"""Intermediate callback to wrap the locator"""
|
"""Intermediate callback to wrap the locator"""
|
||||||
|
(f,arg) = xxx_todo_changeme
|
||||||
return f(arg,msg,severity,xmlTextReaderLocator(locator))
|
return f(arg,msg,severity,xmlTextReaderLocator(locator))
|
||||||
|
|
||||||
class xmlTextReaderCore:
|
class xmlTextReaderCore:
|
||||||
|
@ -32,7 +32,7 @@ except:
|
|||||||
if WITHDLLS:
|
if WITHDLLS:
|
||||||
# libxml dlls (expected in ROOT/bin)
|
# libxml dlls (expected in ROOT/bin)
|
||||||
dlls = [ 'iconv.dll','libxml2.dll','libxslt.dll','libexslt.dll' ]
|
dlls = [ 'iconv.dll','libxml2.dll','libxslt.dll','libexslt.dll' ]
|
||||||
dlls = map(lambda dll: os.path.join(ROOT,'bin',dll),dlls)
|
dlls = [os.path.join(ROOT,'bin',dll) for dll in dlls]
|
||||||
|
|
||||||
# create __init__.py for the libxmlmods package
|
# create __init__.py for the libxmlmods package
|
||||||
if not os.path.exists("libxmlmods"):
|
if not os.path.exists("libxmlmods"):
|
||||||
@ -70,7 +70,7 @@ for dir in includes_dir:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if xml_includes == "":
|
if xml_includes == "":
|
||||||
print "failed to find headers for libxml2: update includes_dir"
|
print("failed to find headers for libxml2: update includes_dir")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
iconv_includes=""
|
iconv_includes=""
|
||||||
@ -80,7 +80,7 @@ for dir in includes_dir:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if iconv_includes == "":
|
if iconv_includes == "":
|
||||||
print "failed to find headers for libiconv: update includes_dir"
|
print("failed to find headers for libiconv: update includes_dir")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# those are added in the linker search path for libraries
|
# those are added in the linker search path for libraries
|
||||||
@ -103,8 +103,8 @@ if missing("libxml2-py.c") or missing("libxml2.py"):
|
|||||||
except:
|
except:
|
||||||
import generator
|
import generator
|
||||||
except:
|
except:
|
||||||
print "failed to find and generate stubs for libxml2, aborting ..."
|
print("failed to find and generate stubs for libxml2, aborting ...")
|
||||||
print sys.exc_type, sys.exc_value
|
print(sys.exc_info()[0], sys.exc_info()[1])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
head = open("libxml.py", "r")
|
head = open("libxml.py", "r")
|
||||||
@ -124,13 +124,13 @@ if missing("libxml2-py.c") or missing("libxml2.py"):
|
|||||||
with_xslt=0
|
with_xslt=0
|
||||||
if missing("libxslt-py.c") or missing("libxslt.py"):
|
if missing("libxslt-py.c") or missing("libxslt.py"):
|
||||||
if missing("xsltgenerator.py") or missing("libxslt-api.xml"):
|
if missing("xsltgenerator.py") or missing("libxslt-api.xml"):
|
||||||
print "libxslt stub generator not found, libxslt not built"
|
print("libxslt stub generator not found, libxslt not built")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
import xsltgenerator
|
import xsltgenerator
|
||||||
except:
|
except:
|
||||||
print "failed to generate stubs for libxslt, aborting ..."
|
print("failed to generate stubs for libxslt, aborting ...")
|
||||||
print sys.exc_type, sys.exc_value
|
print(sys.exc_info()[0], sys.exc_info()[1])
|
||||||
else:
|
else:
|
||||||
head = open("libxsl.py", "r")
|
head = open("libxsl.py", "r")
|
||||||
generated = open("libxsltclass.py", "r")
|
generated = open("libxsltclass.py", "r")
|
||||||
@ -157,7 +157,7 @@ if with_xslt == 1:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if xslt_includes == "":
|
if xslt_includes == "":
|
||||||
print "failed to find headers for libxslt: update includes_dir"
|
print("failed to find headers for libxslt: update includes_dir")
|
||||||
with_xslt = 0
|
with_xslt = 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ except:
|
|||||||
if WITHDLLS:
|
if WITHDLLS:
|
||||||
# libxml dlls (expected in ROOT/bin)
|
# libxml dlls (expected in ROOT/bin)
|
||||||
dlls = [ 'iconv.dll','libxml2.dll','libxslt.dll','libexslt.dll' ]
|
dlls = [ 'iconv.dll','libxml2.dll','libxslt.dll','libexslt.dll' ]
|
||||||
dlls = map(lambda dll: os.path.join(ROOT,'bin',dll),dlls)
|
dlls = [os.path.join(ROOT,'bin',dll) for dll in dlls]
|
||||||
|
|
||||||
# create __init__.py for the libxmlmods package
|
# create __init__.py for the libxmlmods package
|
||||||
if not os.path.exists("libxmlmods"):
|
if not os.path.exists("libxmlmods"):
|
||||||
@ -70,7 +70,7 @@ for dir in includes_dir:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if xml_includes == "":
|
if xml_includes == "":
|
||||||
print "failed to find headers for libxml2: update includes_dir"
|
print("failed to find headers for libxml2: update includes_dir")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
iconv_includes=""
|
iconv_includes=""
|
||||||
@ -80,7 +80,7 @@ for dir in includes_dir:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if iconv_includes == "":
|
if iconv_includes == "":
|
||||||
print "failed to find headers for libiconv: update includes_dir"
|
print("failed to find headers for libiconv: update includes_dir")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# those are added in the linker search path for libraries
|
# those are added in the linker search path for libraries
|
||||||
@ -103,8 +103,8 @@ if missing("libxml2-py.c") or missing("libxml2.py"):
|
|||||||
except:
|
except:
|
||||||
import generator
|
import generator
|
||||||
except:
|
except:
|
||||||
print "failed to find and generate stubs for libxml2, aborting ..."
|
print("failed to find and generate stubs for libxml2, aborting ...")
|
||||||
print sys.exc_type, sys.exc_value
|
print(sys.exc_info()[0], sys.exc_info()[1])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
head = open("libxml.py", "r")
|
head = open("libxml.py", "r")
|
||||||
@ -124,13 +124,13 @@ if missing("libxml2-py.c") or missing("libxml2.py"):
|
|||||||
with_xslt=0
|
with_xslt=0
|
||||||
if missing("libxslt-py.c") or missing("libxslt.py"):
|
if missing("libxslt-py.c") or missing("libxslt.py"):
|
||||||
if missing("xsltgenerator.py") or missing("libxslt-api.xml"):
|
if missing("xsltgenerator.py") or missing("libxslt-api.xml"):
|
||||||
print "libxslt stub generator not found, libxslt not built"
|
print("libxslt stub generator not found, libxslt not built")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
import xsltgenerator
|
import xsltgenerator
|
||||||
except:
|
except:
|
||||||
print "failed to generate stubs for libxslt, aborting ..."
|
print("failed to generate stubs for libxslt, aborting ...")
|
||||||
print sys.exc_type, sys.exc_value
|
print(sys.exc_info()[0], sys.exc_info()[1])
|
||||||
else:
|
else:
|
||||||
head = open("libxsl.py", "r")
|
head = open("libxsl.py", "r")
|
||||||
generated = open("libxsltclass.py", "r")
|
generated = open("libxsltclass.py", "r")
|
||||||
@ -157,7 +157,7 @@ if with_xslt == 1:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if xslt_includes == "":
|
if xslt_includes == "":
|
||||||
print "failed to find headers for libxslt: update includes_dir"
|
print("failed to find headers for libxslt: update includes_dir")
|
||||||
with_xslt = 0
|
with_xslt = 0
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user