From c273f490776fec5dfe97d55fdc00acad9e2ffac7 Mon Sep 17 00:00:00 2001
From: Bob Lantz <rlantz@cs.stanford.edu>
Date: Sun, 23 Nov 2014 11:06:12 -0800
Subject: [PATCH] type( foo ) is bar -> isinstance( foo, bar )

---
 mininet/link.py |  4 ++--
 mininet/node.py | 14 +++++++-------
 mininet/topo.py |  2 +-
 mininet/util.py |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/mininet/link.py b/mininet/link.py
index 29ee07f7..28fa757d 100644
--- a/mininet/link.py
+++ b/mininet/link.py
@@ -160,9 +160,9 @@ def setParam( self, results, method, **param ):
         f = getattr( self, method, None )
         if not f or value is None:
             return
-        if type( value ) is list:
+        if isinstance( value, list ):
             result = f( *value )
-        elif type( value ) is dict:
+        elif isinstance( value, dict ):
             result = f( **value )
         else:
             result = f( value )
diff --git a/mininet/node.py b/mininet/node.py
index b4ef54dd..1687b6ee 100644
--- a/mininet/node.py
+++ b/mininet/node.py
@@ -258,7 +258,7 @@ def sendCmd( self, *args, **kwargs ):
         assert not self.waiting
         printPid = kwargs.get( 'printPid', True )
         # Allow sendCmd( [ list ] )
-        if len( args ) == 1 and type( args[ 0 ] ) is list:
+        if len( args ) == 1 and isinstance( args[ 0 ], list ):
             cmd = args[ 0 ]
         # Allow sendCmd( cmd, arg1, arg2... )
         elif len( args ) > 0:
@@ -352,7 +352,7 @@ def popen( self, *args, **kwargs ):
                      [ 'mnexec', '-da', str( self.pid ) ] }
         defaults.update( kwargs )
         if len( args ) == 1:
-            if type( args[ 0 ] ) is list:
+            if isinstance( args[ 0 ], list ):
                 # popen([cmd, arg1, arg2...])
                 cmd = args[ 0 ]
             elif isinstance( args[ 0 ], basestring ):
@@ -539,9 +539,9 @@ def setParam( self, results, method, **param ):
         f = getattr( self, method, None )
         if not f:
             return
-        if type( value ) is list:
+        if isinstance( value, list ):
             result = f( *value )
-        elif type( value ) is dict:
+        elif isinstance( valude, dict ):
             result = f( **value )
         else:
             result = f( value )
@@ -774,7 +774,7 @@ def setCPUs( self, cores, mems=0 ):
         "Specify (real) cores that our cgroup can run on"
         if not cores:
             return
-        if type( cores ) is list:
+        if isinstance( cores, list ):
             cores = ','.join( [ str( c ) for c in cores ] )
         self.cgroupSet( resource='cpuset', param='cpus',
                         value=cores )
@@ -937,7 +937,7 @@ def TCReapply( intf ):
            over tc queuing disciplines. To resolve the conflict,
            we re-create the user switch's configuration, but as a
            leaf of the TCIntf-created configuration."""
-        if type( intf ) is TCIntf:
+        if isinstance( intf, TCIntf ):
             ifspeed = 10000000000 # 10 Gbps
             minspeed = ifspeed * 0.001
 
@@ -1097,7 +1097,7 @@ def TCReapply( intf ):
         """Unfortunately OVS and Mininet are fighting
            over tc queuing disciplines. As a quick hack/
            workaround, we clear OVS's and reapply our own."""
-        if type( intf ) is TCIntf:
+        if isinstance( intf, TCIntf ):
             intf.config( **intf.params )
 
     def attach( self, intf ):
diff --git a/mininet/topo.py b/mininet/topo.py
index 22d0c1f5..cfa581e0 100644
--- a/mininet/topo.py
+++ b/mininet/topo.py
@@ -45,7 +45,7 @@ def add_edge( self, src, dst, key=None, attr_dict=None, **attrs ):
         entry = self.edge[ dst ][ src ] = self.edge[ src ][ dst ]
         # If no key, pick next ordinal number
         if key is None:
-            keys = [ k for k in entry.keys() if type( k ) is int ]
+            keys = [ k for k in entry.keys() if isinstance( k, int ) ]
             key = max( [ 0 ] + keys ) + 1
         entry[ key ] = attr_dict
         return key
diff --git a/mininet/util.py b/mininet/util.py
index 1fbc5826..74a2424d 100644
--- a/mininet/util.py
+++ b/mininet/util.py
@@ -388,7 +388,7 @@ def sysctlTestAndSet( name, limit ):
     #read limit
     with open( name, 'r' ) as readFile:
         oldLimit = readFile.readline()
-        if type( limit ) is int:
+        if isinstance( limit, int ):
             #compare integer limits before overriding
             if int( oldLimit ) < limit:
                 with open( name, 'w' ) as writeFile:
-- 
GitLab