Quieter helpers initialisation, isderived() alternative to isinstance().
* New: In CRL.python.helpers, all methods make use of the quiet mode to allow completly silent initialisation. Introduce isderived() function to check the derivation relationship of two C++ encapsulated classes by Isobar. The Python isinstance do not work, all C++ wrapped classes are of the base type 'type'. isderived() uses the MRO mechanism (Method Resolution Order) as a workaround. I can't find in the documentation if it's the expected behavior or if i did miss something in when building my classes.
This commit is contained in:
parent
41856f8c50
commit
bdc474d7fc
|
@ -25,6 +25,7 @@ import re
|
|||
import traceback
|
||||
import Hurricane
|
||||
|
||||
quiet = False
|
||||
sysConfDir = None
|
||||
ndaConfDir = None
|
||||
symbolicTechno = 'cmos'
|
||||
|
@ -39,6 +40,13 @@ moduleGlobals = globals()
|
|||
def stype ( o ): return str(type(o)).split("'")[1]
|
||||
|
||||
|
||||
def isderived ( derived, base ):
|
||||
btype = base.mro()[0]
|
||||
for dtype in derived.mro():
|
||||
if dtype == btype: return True
|
||||
return False
|
||||
|
||||
|
||||
def truncPath ( path ):
|
||||
if len(path) < 70: return path
|
||||
return '.../'+os.sep.join(path.split(os.sep)[-4:])
|
||||
|
@ -246,13 +254,16 @@ def setTraceLevel ( level ):
|
|||
return
|
||||
|
||||
|
||||
def initTechno ( quiet ):
|
||||
def initTechno ( argQuiet ):
|
||||
global quiet
|
||||
global ndaConfDir
|
||||
global realDir
|
||||
global realTechno
|
||||
global symbolicDir
|
||||
global symbolicTechno
|
||||
|
||||
quiet = argQuiet
|
||||
|
||||
technoFiles = [ sysConfDir+'/techno.conf' ]
|
||||
if os.getenv('HOME'):
|
||||
technoFiles += [ os.getenv('HOME')+'/.coriolis2/techno.py' ]
|
||||
|
|
|
@ -80,8 +80,10 @@ def runScript ( scriptPath, editor ):
|
|||
|
||||
except ImportError, e:
|
||||
module = str(e).split()[-1]
|
||||
print '[ERROR] The <%s> script cannot be loaded.' % module
|
||||
print ' Please check your design hierarchy.'
|
||||
print '[ERROR] The <%s> script cannot be loaded.' % os.path.basename(scriptPath)
|
||||
print ' Please check your design hierarchy or the Python syntax.'
|
||||
print ' Error was:'
|
||||
print ' %s\n' % e
|
||||
except Exception, e:
|
||||
print '[ERROR] An exception occured while loading the Stratus script module:'
|
||||
print ' <%s>\n' % (scriptPath)
|
||||
|
|
Loading…
Reference in New Issue