]> xenbits.xensource.com Git - libvirt.git/commitdiff
apibuild: Use isinstance for type checking
authorRadostin Stoyanov <rstoyanov1@gmail.com>
Tue, 20 Mar 2018 06:48:44 +0000 (06:48 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 20 Mar 2018 12:13:35 +0000 (12:13 +0000)
The isinstance() function [1] returns true if an object argument is an
instance of a classinfo argument or of a direct, indirect subclass
thereof.

1: https://docs.python.org/3/library/functions.html#isinstance

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
docs/apibuild.py

index 17d14a0c55be641daba2ccddb57ca28567ca7787..832f04ab15bf43362b15f68a8ba209318f0d5a5a 100755 (executable)
@@ -742,7 +742,7 @@ class CParser:
         return line
 
     def cleanupComment(self):
-        if type(self.comment) != type(""):
+        if not isinstance(self.comment, str):
             return
         # remove the leading * on multi-line comments
         lines = self.comment.splitlines(True)
@@ -2223,9 +2223,8 @@ class docBuilder:
             output.write("    <struct name='%s' file='%s' type='%s'" % (
                      name, self.modulename_file(id.header), id.info))
             name = id.info[7:]
-            if name in self.idx.structs and ( \
-               type(self.idx.structs[name].info) == type(()) or
-                type(self.idx.structs[name].info) == type([])):
+            if (name in self.idx.structs and
+                    isinstance(self.idx.structs[name].info, (list, tuple))):
                 output.write(">\n")
                 try:
                     for field in self.idx.structs[name].info: