Commits

bi...@4525493e-7705-40b1-a816-d608a930855b  committed b530d03

hooks for tid inspection from python

  • Participants
  • Parent commits ca8724a

Comments (0)

Files changed (2)

+2009-02-03  Sebastien Binet  <binet@farnsworth>
+
+	* tagging CLIDComps-00-05-02
+	* hooks for tid inspection from python
+	* M python/clidGenerator.py
+
 2009-01-19  Sebastien Binet  <binet@farnsworth>
 
 	* tagging CLIDComps-00-05-01

File python/clidGenerator.py

 import string, re, os, csv
 
 ## Athena CLID Generator Class
-class clidGenerator:
+class clidGenerator (object):
     "Athena CLID Generator"
     __clidGenerator_type = "Basic"
-    __clidGenerator_version = "$Revision: 1.3 $"
+    __clidGenerator_version = "$Revision: 1.4 $"
     # CLID Mask: Determines bits used for CLID
     __mask = 0x0FFFFFFF
     # CLID Repositories - Dictionaries of CLID<=>Name
     __clidRep = {} # Lookup by CLID
     __clidPkg = {} # Lookup by CLID
+    __clidTid = {} # Lookup by CLID
     __nameRep = {} # Lookup by ClassName
+    __tidRep  = {} # Lookup by typeid-name
     # CLID DataBase (Default = clid.db)
 #   __cliddb = os.getenv('CLIDDB')
     def __init__(self, db, debug=False):
                                            delimiter=';'):
                         row = [i.strip() for i in row]
                         if len(row) >= 3:
-                            self.__clidRep[int(row[0])] = row[1]
-                            self.__nameRep[row[1]] = int(row[0])
-                            self.__clidPkg[int(row[0])] = row[2]
+                            clid = int(row[0])
+                            class_name = row[1]
+                            pkg_name   = row[2]
+                            if len(row) > 3: tid_name = row[3]
+                            else:            tid_name = class_name
+                            
+                            self.__clidRep[clid] = class_name
+                            self.__clidPkg[clid] = pkg_name
+                            self.__clidTid[clid] = tid_name
+                            self.__nameRep[class_name] = clid
+                            self.__tidRep [tid_name]   = clid
+                            
                 else:
                     print "No CLID DataBase file <%s> " % cliddb        
         except Exception, err:
                 c = self.genClidFromName(className+'_')
         else:
             self.__clidRep[c] = n
+            self.__clidTid[c] = n # make typeid name the same than class-name
             self.__nameRep[n] = c
+            self.__tidRep [n] = c # idem
         return c
     def getClidFromName(self,className):
         "Get the CLID in the repository of class name <className>"
             return self.__nameRep[className]
         else:
             return None
+    def getClidFromTid(self,tidName):
+        "Get the CLID in the repository of typeid name <tidName>"
+        if tidName in self.__tidRep:
+            return self.__tidRep[tidName]
+        else:
+            return None
     def getNameFromClid(self,clid):
         "Get the class name in the repository with CLID <clid>"
         if self.__clidRep.has_key(clid):
             return self.__clidRep[clid]
         else:
             return None
+    def getTidFromClid(self,clid):
+        "Get the typeid name in the repository with CLID <clid>"
+        if clid in self.__clidTid:
+            return self.__clidTid[clid]
+        else:
+            return None
     def getPackageFromClid(self,clid):
         "Get the name of the package defining <clid>"
         if self.__clidPkg.has_key(clid):