Add custom() function for customizing constructors.
This commit is contained in:
+10
-1
@@ -4,7 +4,7 @@ from time import sleep
|
|||||||
from resource import setrlimit, RLIMIT_NPROC, RLIMIT_NOFILE
|
from resource import setrlimit, RLIMIT_NPROC, RLIMIT_NOFILE
|
||||||
from select import poll, POLLIN
|
from select import poll, POLLIN
|
||||||
from subprocess import call, check_call, Popen, PIPE, STDOUT
|
from subprocess import call, check_call, Popen, PIPE, STDOUT
|
||||||
from mininet.log import output, error
|
from mininet.log import output, info, error
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# Command execution support
|
# Command execution support
|
||||||
@@ -282,3 +282,12 @@ def numCores():
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
return 0
|
return 0
|
||||||
return numCores.ncores
|
return numCores.ncores
|
||||||
|
|
||||||
|
def custom( cls, **params ):
|
||||||
|
"Returns customized constructor for class cls."
|
||||||
|
def customized( *args, **kwargs):
|
||||||
|
kwargs.update( params )
|
||||||
|
return cls( *args, **kwargs )
|
||||||
|
return customized
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user