[libvirt] [PATCHv2 0/8] Python related fixes

The following series fixes various issues related to the python bindings. Cole Robinson (8): configure: Add explict --with-python option. python: Remove FastParser from generator. python: Remove use of xmllib in generator.py python: Don't generate conflicting conn.createXML functions. python: Don't generate bindings for vir*Ref python: Use a pure python implementation of 'vir*GetConnect' python: Fix generated virInterface method names python: Add a newline after custom classes configure.in | 6 ++- python/generator.py | 117 ++++++++++++++++++++++----------------------------- 2 files changed, 55 insertions(+), 68 deletions(-)

--with-python currently already works for enabling/disabling the python bindings, but doesn't show up in the help output. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- configure.in | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/configure.in b/configure.in index cb5ce55..1d12237 100644 --- a/configure.in +++ b/configure.in @@ -1316,6 +1316,9 @@ dnl dnl check for python dnl +AC_ARG_WITH([python], +[ --with-python Build python bindings (on)],[],[with_python=yes]) + PYTHON_VERSION= PYTHON_INCLUDES= PYTHON_SITE_PACKAGES= @@ -1373,7 +1376,7 @@ if test "$with_python" != "no" ; then fi fi fi - if test "$with_python" != "" + if test "$with_python" != "yes" then pythondir='$(PYTHON_SITE_PACKAGES)' else @@ -1836,6 +1839,7 @@ AC_MSG_NOTICE([]) AC_MSG_NOTICE([ Debug: $enable_debug]) AC_MSG_NOTICE([ Warnings: $enable_compile_warnings]) AC_MSG_NOTICE([ Readline: $lv_use_readline]) +AC_MSG_NOTICE([ Python: $with_python]) AC_MSG_NOTICE([]) AC_MSG_NOTICE([Privileges]) AC_MSG_NOTICE([]) -- 1.6.5.rc2

On Fri, Oct 02, 2009 at 01:46:46PM -0400, Cole Robinson wrote:
--with-python currently already works for enabling/disabling the python bindings, but doesn't show up in the help output.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- configure.in | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/configure.in b/configure.in index cb5ce55..1d12237 100644 --- a/configure.in +++ b/configure.in @@ -1316,6 +1316,9 @@ dnl dnl check for python dnl
+AC_ARG_WITH([python], +[ --with-python Build python bindings (on)],[],[with_python=yes]) + PYTHON_VERSION= PYTHON_INCLUDES= PYTHON_SITE_PACKAGES= @@ -1373,7 +1376,7 @@ if test "$with_python" != "no" ; then fi fi fi - if test "$with_python" != "" + if test "$with_python" != "yes" then pythondir='$(PYTHON_SITE_PACKAGES)' else @@ -1836,6 +1839,7 @@ AC_MSG_NOTICE([]) AC_MSG_NOTICE([ Debug: $enable_debug]) AC_MSG_NOTICE([ Warnings: $enable_compile_warnings]) AC_MSG_NOTICE([ Readline: $lv_use_readline]) +AC_MSG_NOTICE([ Python: $with_python]) AC_MSG_NOTICE([]) AC_MSG_NOTICE([Privileges]) AC_MSG_NOTICE([])
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

FastParser uses sgmlop, a non-standard python module meant as a replacement for xmllib (which is deprecated since python 2.0). Fedora doesn't even carry this module, and the generator doesn't have high performance requirements, so just rip the code out. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 53 ++------------------------------------------------ 1 files changed, 3 insertions(+), 50 deletions(-) diff --git a/python/generator.py b/python/generator.py index 48ad14b..3d142e9 100755 --- a/python/generator.py +++ b/python/generator.py @@ -26,52 +26,9 @@ else: ####################################################################### import os import xmllib -try: - import sgmlop -except ImportError: - sgmlop = None # accelerator not available debug = 0 -if sgmlop: - class FastParser: - """sgmlop based XML parser. this is typically 15x faster - than SlowParser...""" - - def __init__(self, target): - - # setup callbacks - self.finish_starttag = target.start - self.finish_endtag = target.end - self.handle_data = target.data - self.handle_cdata = target.cdata - - # activate parser - self.parser = sgmlop.XMLParser() - self.parser.register(self) - self.feed = self.parser.feed - self.entity = { - "amp": "&", "gt": ">", "lt": "<", - "apos": "'", "quot": '"' - } - - def close(self): - try: - self.parser.close() - finally: - self.parser = self.feed = None # nuke circular reference - - def handle_entityref(self, entity): - # <string> entity - try: - self.handle_data(self.entity[entity]) - except KeyError: - self.handle_data("&%s;" % entity) - -else: - FastParser = None - - class SlowParser(xmllib.XMLParser): """slow but safe standard parser, based on the XML parser in Python's standard library.""" @@ -83,13 +40,9 @@ class SlowParser(xmllib.XMLParser): self.unknown_endtag = target.end xmllib.XMLParser.__init__(self) -def getparser(target = None): - # get the fastest available parser, and attach it to an - # unmarshalling object. return both objects. - if target is None: - target = docParser() - if FastParser: - return FastParser(target), target +def getparser(): + # Attach parser to an unmarshalling object. return both objects. + target = docParser() return SlowParser(target), target class docParser: -- 1.6.5.rc2

On Fri, Oct 02, 2009 at 01:46:47PM -0400, Cole Robinson wrote:
FastParser uses sgmlop, a non-standard python module meant as a replacement for xmllib (which is deprecated since python 2.0). Fedora doesn't even carry this module, and the generator doesn't have high performance requirements, so just rip the code out.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 53 ++------------------------------------------------ 1 files changed, 3 insertions(+), 50 deletions(-)
diff --git a/python/generator.py b/python/generator.py index 48ad14b..3d142e9 100755 --- a/python/generator.py +++ b/python/generator.py @@ -26,52 +26,9 @@ else: ####################################################################### import os import xmllib -try: - import sgmlop -except ImportError: - sgmlop = None # accelerator not available
debug = 0
-if sgmlop: - class FastParser: - """sgmlop based XML parser. this is typically 15x faster - than SlowParser...""" - - def __init__(self, target): - - # setup callbacks - self.finish_starttag = target.start - self.finish_endtag = target.end - self.handle_data = target.data - self.handle_cdata = target.cdata - - # activate parser - self.parser = sgmlop.XMLParser() - self.parser.register(self) - self.feed = self.parser.feed - self.entity = { - "amp": "&", "gt": ">", "lt": "<", - "apos": "'", "quot": '"' - } - - def close(self): - try: - self.parser.close() - finally: - self.parser = self.feed = None # nuke circular reference - - def handle_entityref(self, entity): - # <string> entity - try: - self.handle_data(self.entity[entity]) - except KeyError: - self.handle_data("&%s;" % entity) - -else: - FastParser = None - - class SlowParser(xmllib.XMLParser): """slow but safe standard parser, based on the XML parser in Python's standard library.""" @@ -83,13 +40,9 @@ class SlowParser(xmllib.XMLParser): self.unknown_endtag = target.end xmllib.XMLParser.__init__(self)
-def getparser(target = None): - # get the fastest available parser, and attach it to an - # unmarshalling object. return both objects. - if target is None: - target = docParser() - if FastParser: - return FastParser(target), target +def getparser(): + # Attach parser to an unmarshalling object. return both objects. + target = docParser() return SlowParser(target), target
class docParser:
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

xmllib has been deprecated since python 2.0, and running the generator throws a warning. Move to using xml.sax Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 23 +++++++++-------------- 1 files changed, 9 insertions(+), 14 deletions(-) diff --git a/python/generator.py b/python/generator.py index 3d142e9..9ec91d8 100755 --- a/python/generator.py +++ b/python/generator.py @@ -25,32 +25,27 @@ else: # ####################################################################### import os -import xmllib +import xml.sax debug = 0 -class SlowParser(xmllib.XMLParser): - """slow but safe standard parser, based on the XML parser in - Python's standard library.""" - - def __init__(self, target): - self.unknown_starttag = target.start - self.handle_data = target.data - self.handle_cdata = target.cdata - self.unknown_endtag = target.end - xmllib.XMLParser.__init__(self) - def getparser(): # Attach parser to an unmarshalling object. return both objects. target = docParser() - return SlowParser(target), target + parser = xml.sax.make_parser() + parser.setContentHandler(target) + return parser, target -class docParser: +class docParser(xml.sax.handler.ContentHandler): def __init__(self): self._methodname = None self._data = [] self.in_function = 0 + self.startElement = self.start + self.endElement = self.end + self.characters = self.data + def close(self): if debug: print "close" -- 1.6.5.rc2

On Fri, Oct 02, 2009 at 01:46:48PM -0400, Cole Robinson wrote:
xmllib has been deprecated since python 2.0, and running the generator throws a warning. Move to using xml.sax
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 23 +++++++++-------------- 1 files changed, 9 insertions(+), 14 deletions(-)
ACK, assuming xml.sax has been present since python 2.4 which is the minimum version we're able to build with. Daniel
diff --git a/python/generator.py b/python/generator.py index 3d142e9..9ec91d8 100755 --- a/python/generator.py +++ b/python/generator.py @@ -25,32 +25,27 @@ else: # ####################################################################### import os -import xmllib +import xml.sax
debug = 0
-class SlowParser(xmllib.XMLParser): - """slow but safe standard parser, based on the XML parser in - Python's standard library.""" - - def __init__(self, target): - self.unknown_starttag = target.start - self.handle_data = target.data - self.handle_cdata = target.cdata - self.unknown_endtag = target.end - xmllib.XMLParser.__init__(self) - def getparser(): # Attach parser to an unmarshalling object. return both objects. target = docParser() - return SlowParser(target), target + parser = xml.sax.make_parser() + parser.setContentHandler(target) + return parser, target
-class docParser: +class docParser(xml.sax.handler.ContentHandler): def __init__(self): self._methodname = None self._data = [] self.in_function = 0
+ self.startElement = self.start + self.endElement = self.end + self.characters = self.data + def close(self): if debug: print "close" -- 1.6.5.rc2
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Fri, Oct 02, 2009 at 01:46:48PM -0400, Cole Robinson wrote:
xmllib has been deprecated since python 2.0, and running the generator throws a warning. Move to using xml.sax
Thanks ! I need to apply this to other projects using generator ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

A special case in the generator wasn't doing its job, and duplicate conn.createXML functions were being generated. The bindings diff is: @@ -1079,14 +1079,6 @@ class virConnect: return __tmp def createXML(self, xmlDesc, flags): - """Create a new device on the VM host machine, for example, - virtual HBAs created using vport_create. """ - ret = libvirtmod.virNodeDeviceCreateXML(self._o, xmlDesc, flags) - if ret is None:raise libvirtError('virNodeDeviceCreateXML() failed', conn=self) - __tmp = virNodeDevice(self, _obj=ret) - return __tmp - - def createXML(self, xmlDesc, flags): """Launch a new guest domain, based on an XML description similar to the one returned by virDomainGetXMLDesc() This function may requires privileged access to the hypervisor. @@ -1327,6 +1319,14 @@ class virConnect: __tmp = virNetwork(self, _obj=ret) return __tmp + def nodeDeviceCreateXML(self, xmlDesc, flags): + """Create a new device on the VM host machine, for example, + virtual HBAs created using vport_create. """ + ret = libvirtmod.virNodeDeviceCreateXML(self._o, xmlDesc, flags) + if ret is None:raise libvirtError('virNodeDeviceCreateXML() failed', conn=self) + __tmp = virNodeDevice(self, _obj=ret) + return __tmp + def nodeDeviceLookupByName(self, name): """Lookup a node device by its name. """ ret = libvirtmod.virNodeDeviceLookupByName(self._o, name) Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/python/generator.py b/python/generator.py index 9ec91d8..758914e 100755 --- a/python/generator.py +++ b/python/generator.py @@ -767,7 +767,7 @@ def nameFixup(name, classe, type, file): elif name[0:13] == "virNodeDevice": if name[13:16] == "Get": func = string.lower(name[16]) + name[17:] - elif name[13:19] == "Lookup" or name[13:] == "Create": + elif name[13:19] == "Lookup" or name[13:19] == "Create": func = string.lower(name[3]) + name[4:] else: func = string.lower(name[13]) + name[14:] -- 1.6.5.rc2

On Fri, Oct 02, 2009 at 01:46:49PM -0400, Cole Robinson wrote:
A special case in the generator wasn't doing its job, and duplicate conn.createXML functions were being generated. The bindings diff is:
@@ -1079,14 +1079,6 @@ class virConnect: return __tmp
def createXML(self, xmlDesc, flags): - """Create a new device on the VM host machine, for example, - virtual HBAs created using vport_create. """ - ret = libvirtmod.virNodeDeviceCreateXML(self._o, xmlDesc, flags) - if ret is None:raise libvirtError('virNodeDeviceCreateXML() failed', conn=self) - __tmp = virNodeDevice(self, _obj=ret) - return __tmp - - def createXML(self, xmlDesc, flags): """Launch a new guest domain, based on an XML description similar to the one returned by virDomainGetXMLDesc() This function may requires privileged access to the hypervisor. @@ -1327,6 +1319,14 @@ class virConnect: __tmp = virNetwork(self, _obj=ret) return __tmp
+ def nodeDeviceCreateXML(self, xmlDesc, flags): + """Create a new device on the VM host machine, for example, + virtual HBAs created using vport_create. """ + ret = libvirtmod.virNodeDeviceCreateXML(self._o, xmlDesc, flags) + if ret is None:raise libvirtError('virNodeDeviceCreateXML() failed', conn=self) + __tmp = virNodeDevice(self, _obj=ret) + return __tmp + def nodeDeviceLookupByName(self, name): """Lookup a node device by its name. """ ret = libvirtmod.virNodeDeviceLookupByName(self._o, name)
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/python/generator.py b/python/generator.py index 9ec91d8..758914e 100755 --- a/python/generator.py +++ b/python/generator.py @@ -767,7 +767,7 @@ def nameFixup(name, classe, type, file): elif name[0:13] == "virNodeDevice": if name[13:16] == "Get": func = string.lower(name[16]) + name[17:] - elif name[13:19] == "Lookup" or name[13:] == "Create": + elif name[13:19] == "Lookup" or name[13:19] == "Create": func = string.lower(name[3]) + name[4:] else: func = string.lower(name[13]) + name[14:]
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

They are only for use in implementing the bindings, so shouldn't be exposed to regular API users. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/python/generator.py b/python/generator.py index 758914e..437de0c 100755 --- a/python/generator.py +++ b/python/generator.py @@ -333,6 +333,16 @@ skip_function = ( 'virStreamSendAll', 'virStreamRef', 'virStreamFree', + + # These have no use for bindings users. + "virConnectRef", + "virDomainRef", + "virInterfaceRef", + "virNetworkRef", + "virNodeDeviceRef", + "virSecretRef", + "virStoragePoolRef", + "virStorageVolRef", ) -- 1.6.5.rc2

On Fri, Oct 02, 2009 at 01:46:50PM -0400, Cole Robinson wrote:
They are only for use in implementing the bindings, so shouldn't be exposed to regular API users.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/python/generator.py b/python/generator.py index 758914e..437de0c 100755 --- a/python/generator.py +++ b/python/generator.py @@ -333,6 +333,16 @@ skip_function = ( 'virStreamSendAll', 'virStreamRef', 'virStreamFree', + + # These have no use for bindings users. + "virConnectRef", + "virDomainRef", + "virInterfaceRef", + "virNetworkRef", + "virNodeDeviceRef", + "virSecretRef", + "virStoragePoolRef", + "virStorageVolRef", )
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

The API docs explictly warn that we shouldn't use the C vir*GetConnect calls in bindings: doing so can close the internal connection pointer and cause things to get screwy. Implement these calls in python. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/python/generator.py b/python/generator.py index 437de0c..de5507e 100755 --- a/python/generator.py +++ b/python/generator.py @@ -343,6 +343,16 @@ skip_function = ( "virSecretRef", "virStoragePoolRef", "virStorageVolRef", + + # This functions shouldn't be called via the bindings (and even the docs + # contain an explicit warning to that effect). The equivalent should be + # implemented in pure python for each class + "virDomainGetConnect", + "virInterfaceGetConnect", + "virNetworkGetConnect", + "virSecretGetConnect", + "virStoragePoolGetConnect", + "virStorageVolGetConnect", ) @@ -641,6 +651,11 @@ classes_destructors = { #"virStream": "virStreamFree", } +class_skip_connect_impl = { + "virConnect" : True +} + + functions_noexcept = { 'virDomainGetID': True, 'virDomainGetName': True, @@ -1065,6 +1080,12 @@ def buildWrappers(): classes_destructors[classname]); classes.write(" self._o = None\n\n"); destruct=classes_destructors[classname] + + if not class_skip_connect_impl.has_key(classname): + # Build python safe 'connect' method + classes.write(" def connect(self):\n") + classes.write(" return self._conn\n\n") + flist = function_classes[classname] flist.sort(functionCompare) oldfile = "" -- 1.6.5.rc2

On Fri, Oct 02, 2009 at 01:46:51PM -0400, Cole Robinson wrote:
The API docs explictly warn that we shouldn't use the C vir*GetConnect calls in bindings: doing so can close the internal connection pointer and cause things to get screwy. Implement these calls in python.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/python/generator.py b/python/generator.py index 437de0c..de5507e 100755 --- a/python/generator.py +++ b/python/generator.py @@ -343,6 +343,16 @@ skip_function = ( "virSecretRef", "virStoragePoolRef", "virStorageVolRef", + + # This functions shouldn't be called via the bindings (and even the docs + # contain an explicit warning to that effect). The equivalent should be + # implemented in pure python for each class + "virDomainGetConnect", + "virInterfaceGetConnect", + "virNetworkGetConnect", + "virSecretGetConnect", + "virStoragePoolGetConnect", + "virStorageVolGetConnect", )
@@ -641,6 +651,11 @@ classes_destructors = { #"virStream": "virStreamFree", }
+class_skip_connect_impl = { + "virConnect" : True +} + + functions_noexcept = { 'virDomainGetID': True, 'virDomainGetName': True, @@ -1065,6 +1080,12 @@ def buildWrappers(): classes_destructors[classname]); classes.write(" self._o = None\n\n"); destruct=classes_destructors[classname] + + if not class_skip_connect_impl.has_key(classname): + # Build python safe 'connect' method + classes.write(" def connect(self):\n") + classes.write(" return self._conn\n\n") + flist = function_classes[classname] flist.sort(functionCompare) oldfile = ""
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

A mistake in the generator was causing virInterface methods to be generated with unpredicatable names ('ceUndefine', instead of just 'undefine'). This fixes the method names to match existing convention. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/python/generator.py b/python/generator.py index de5507e..17eaf1a 100755 --- a/python/generator.py +++ b/python/generator.py @@ -761,10 +761,10 @@ def nameFixup(name, classe, type, file): func = name[10:] func = string.lower(func[0:1]) + func[1:] elif name[0:15] == "virInterfaceGet": - func = name[13:] + func = name[15:] func = string.lower(func[0:1]) + func[1:] elif name[0:12] == "virInterface": - func = name[10:] + func = name[12:] func = string.lower(func[0:1]) + func[1:] elif name[0:12] == 'virSecretGet': func = name[12:] @@ -817,6 +817,9 @@ def nameFixup(name, classe, type, file): func = "OSType" if func == "xMLDesc": func = "XMLDesc" + if func == "mACString": + func = "MACString" + return func -- 1.6.5.rc2

On Fri, Oct 02, 2009 at 01:46:52PM -0400, Cole Robinson wrote:
A mistake in the generator was causing virInterface methods to be generated with unpredicatable names ('ceUndefine', instead of just 'undefine'). This fixes the method names to match existing convention.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/python/generator.py b/python/generator.py index de5507e..17eaf1a 100755 --- a/python/generator.py +++ b/python/generator.py @@ -761,10 +761,10 @@ def nameFixup(name, classe, type, file): func = name[10:] func = string.lower(func[0:1]) + func[1:] elif name[0:15] == "virInterfaceGet": - func = name[13:] + func = name[15:] func = string.lower(func[0:1]) + func[1:] elif name[0:12] == "virInterface": - func = name[10:] + func = name[12:] func = string.lower(func[0:1]) + func[1:] elif name[0:12] == 'virSecretGet': func = name[12:] @@ -817,6 +817,9 @@ def nameFixup(name, classe, type, file): func = "OSType" if func == "xMLDesc": func = "XMLDesc" + if func == "mACString": + func = "MACString" + return func
ACk Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Mon, Oct 05, 2009 at 01:40:44PM +0100, Daniel P. Berrange wrote:
On Fri, Oct 02, 2009 at 01:46:52PM -0400, Cole Robinson wrote:
A mistake in the generator was causing virInterface methods to be generated with unpredicatable names ('ceUndefine', instead of just 'undefine'). This fixes the method names to match existing convention.
I think at some point in the past I tried to fix this whole routine over, but my cleanup was too drastic and I never finished or send the patch, ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

In the generated bindings, custom classes are squashed against the following class, which hurts readability. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/python/generator.py b/python/generator.py index 17eaf1a..21b4137 100755 --- a/python/generator.py +++ b/python/generator.py @@ -1337,6 +1337,7 @@ def buildWrappers(): classes.write (" # %s methods from %s.py (hand coded)\n" % (classname,classname)) classes.write (" #\n") classes.writelines(extra.readlines()) + classes.write("\n") extra.close() except: pass -- 1.6.5.rc2

On Fri, Oct 02, 2009 at 01:46:53PM -0400, Cole Robinson wrote:
In the generated bindings, custom classes are squashed against the following class, which hurts readability.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- python/generator.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/python/generator.py b/python/generator.py index 17eaf1a..21b4137 100755 --- a/python/generator.py +++ b/python/generator.py @@ -1337,6 +1337,7 @@ def buildWrappers(): classes.write (" # %s methods from %s.py (hand coded)\n" % (classname,classname)) classes.write (" #\n") classes.writelines(extra.readlines()) + classes.write("\n") extra.close() except: pass
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Fri, Oct 02, 2009 at 01:46:45PM -0400, Cole Robinson wrote:
The following series fixes various issues related to the python bindings.
Cole Robinson (8): configure: Add explict --with-python option. python: Remove FastParser from generator. python: Remove use of xmllib in generator.py python: Don't generate conflicting conn.createXML functions. python: Don't generate bindings for vir*Ref python: Use a pure python implementation of 'vir*GetConnect' python: Fix generated virInterface method names python: Add a newline after custom classes
Very nice set of cleanups, ACK to the whole serie ! Thanks a lot :-) Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 10/05/2009 11:30 AM, Daniel Veillard wrote:
On Fri, Oct 02, 2009 at 01:46:45PM -0400, Cole Robinson wrote:
The following series fixes various issues related to the python bindings.
Cole Robinson (8): configure: Add explict --with-python option. python: Remove FastParser from generator. python: Remove use of xmllib in generator.py python: Don't generate conflicting conn.createXML functions. python: Don't generate bindings for vir*Ref python: Use a pure python implementation of 'vir*GetConnect' python: Fix generated virInterface method names python: Add a newline after custom classes
Very nice set of cleanups, ACK to the whole serie !
Thanks a lot :-)
Daniel
Thanks, pushed now. - Cole
participants (3)
-
Cole Robinson
-
Daniel P. Berrange
-
Daniel Veillard