Athena CLID Generator Class.
More...
|
def | __init__ (self, db, debug=False) |
|
def | cleardb (self) |
|
def | readdb (self) |
|
def | setCLIDDB (self, db, debug) |
|
def | writedb (self, db) |
|
def | genClidFromName (self, className) |
|
def | getClidFromName (self, className) |
|
def | getClidFromTid (self, tidName) |
|
def | getNameFromClid (self, clid) |
|
def | getTidFromClid (self, clid) |
|
def | demangleClassName (self, s) |
|
def | isCollection (self, className) |
|
def | findPattern (self, s) |
|
Athena CLID Generator Class.
Athena CLID Generator
Definition at line 26 of file clidGenerator.py.
◆ __init__()
def python.clidGenerator.clidGenerator.__init__ |
( |
|
self, |
|
|
|
db, |
|
|
|
debug = False |
|
) |
| |
◆ cleardb()
def python.clidGenerator.clidGenerator.cleardb |
( |
|
self | ) |
|
Definition at line 40 of file clidGenerator.py.
41 clidGenerator.__clidRep = {}
42 clidGenerator.__nameRep = {}
◆ demangleClassName()
def python.clidGenerator.clidGenerator.demangleClassName |
( |
|
self, |
|
|
|
s |
|
) |
| |
◆ findPattern()
def python.clidGenerator.clidGenerator.findPattern |
( |
|
self, |
|
|
|
s |
|
) |
| |
Find the regular expression pattern s in dictionary.
Definition at line 141 of file clidGenerator.py.
141 def findPattern(self,s):
142 """Find the regular expression pattern s in dictionary."""
146 for k
in self.__clidRep.
keys():
147 if pat.match(
str(k))
or pat.match(self.__clidRep[k]):
148 results[k] = self.__clidRep[k]
◆ genClidFromName()
def python.clidGenerator.clidGenerator.genClidFromName |
( |
|
self, |
|
|
|
className |
|
) |
| |
Generate CLID from ClassName: A recursive hash with a bit
mask and validity range. Will check collisions against and
update CLID Repository.
Definition at line 89 of file clidGenerator.py.
89 def genClidFromName(self,className):
90 """Generate CLID from ClassName: A recursive hash with a bit
91 mask and validity range. Will check collisions against and
92 update CLID Repository."""
93 n = self.demangleClassName(className)
94 c = self.getClidFromName(className)
97 c =
py2_hash(className) & self.__mask
98 if c < 10001
or c > self.__mask:
99 c = self.genClidFromName(className+
'_')
100 if self.isCollection(className):
102 if c
in self.__clidRep:
103 if n != self.__clidRep[c]:
104 c = self.genClidFromName(className+
'_')
106 self.__clidRep[c] = n
107 self.__clidTid[c] = n
108 self.__nameRep[n] = c
109 self.__tidRep [n] = c
◆ getClidFromName()
def python.clidGenerator.clidGenerator.getClidFromName |
( |
|
self, |
|
|
|
className |
|
) |
| |
Get the CLID in the repository of class name <className>
Definition at line 112 of file clidGenerator.py.
112 def getClidFromName(self,className):
113 """Get the CLID in the repository of class name <className>"""
114 return self.__nameRep.
get(className,
None)
◆ getClidFromTid()
def python.clidGenerator.clidGenerator.getClidFromTid |
( |
|
self, |
|
|
|
tidName |
|
) |
| |
Get the CLID in the repository of typeid name <tidName>
Definition at line 116 of file clidGenerator.py.
116 def getClidFromTid(self,tidName):
117 """Get the CLID in the repository of typeid name <tidName>"""
118 return self.__tidRep.
get(tidName,
None)
◆ getNameFromClid()
def python.clidGenerator.clidGenerator.getNameFromClid |
( |
|
self, |
|
|
|
clid |
|
) |
| |
Get the class name in the repository with CLID <clid>
Definition at line 120 of file clidGenerator.py.
120 def getNameFromClid(self,clid):
121 """Get the class name in the repository with CLID <clid>"""
122 return self.__clidRep.
get(clid,
None)
◆ getTidFromClid()
def python.clidGenerator.clidGenerator.getTidFromClid |
( |
|
self, |
|
|
|
clid |
|
) |
| |
Get the typeid name in the repository with CLID <clid>
Definition at line 124 of file clidGenerator.py.
124 def getTidFromClid(self,clid):
125 """Get the typeid name in the repository with CLID <clid>"""
126 return self.__clidTid.
get(clid,
None)
◆ isCollection()
def python.clidGenerator.clidGenerator.isCollection |
( |
|
self, |
|
|
|
className |
|
) |
| |
Definition at line 137 of file clidGenerator.py.
137 def isCollection(self,className):
138 collMatch = re.search(
r'.*?Collection_*|.*?Container_*',className)
◆ readdb()
def python.clidGenerator.clidGenerator.readdb |
( |
|
self | ) |
|
Read CLID DataBase file
Definition at line 44 of file clidGenerator.py.
45 """Read CLID DataBase file"""
47 for cliddb
in self.__cliddbs:
48 if os.path.isfile(cliddb):
49 with open(cliddb,
'r')
as f_cliddb:
50 for row
in csv.reader (f_cliddb, delimiter=
';'):
51 row = [i.strip()
for i
in row]
55 tid_name = row[2]
if len(row)>2
else class_name
57 self.__clidRep[clid] = class_name
58 self.__clidTid[clid] = tid_name
59 self.__nameRep[class_name] = clid
60 self.__tidRep [tid_name] = clid
63 print (
"No CLID DataBase file <%s> " % cliddb)
64 except Exception
as err:
65 print (
"Error reading from CLID DataBase files <%s>:\n%s " % (
◆ setCLIDDB()
def python.clidGenerator.clidGenerator.setCLIDDB |
( |
|
self, |
|
|
|
db, |
|
|
|
debug |
|
) |
| |
Initializes a CLID Generator object with a CLID Database
Definition at line 69 of file clidGenerator.py.
69 def setCLIDDB(self, db, debug):
70 """Initializes a CLID Generator object with a CLID Database"""
73 if debug:
print (
"Using specified CLID DataBase files %s " % self.__cliddbs)
74 elif os.getenv(
'CLIDDB'):
76 self.__cliddbs.
append(os.getenv(
'CLIDDB'))
77 if debug:
print (
"Using DataBase file from CLIDDB env variable %s " % self.__cliddbs)
79 self.__cliddbs =
search_files(
'clid.db', os.getenv(
'DATAPATH'))
80 if debug:
print (
"Using DataBase file from DATAPATH %s " % self.__cliddbs)
◆ writedb()
def python.clidGenerator.clidGenerator.writedb |
( |
|
self, |
|
|
|
db |
|
) |
| |
Read CLID DataBase file
Definition at line 82 of file clidGenerator.py.
83 """Read CLID DataBase file"""
85 for k
in self.__clidRep.
keys():
86 output.write(
"%d "%k+self.__clidRep[k]+
"\n")
◆ __cliddbs
python.clidGenerator.clidGenerator.__cliddbs |
|
private |
◆ __clidRep
dictionary python.clidGenerator.clidGenerator.__clidRep = {} |
|
staticprivate |
◆ __clidTid
dictionary python.clidGenerator.clidGenerator.__clidTid = {} |
|
staticprivate |
◆ __mask
int python.clidGenerator.clidGenerator.__mask = 0x0FFFFFFF |
|
staticprivate |
◆ __nameRep
dictionary python.clidGenerator.clidGenerator.__nameRep = {} |
|
staticprivate |
◆ __tidRep
dictionary python.clidGenerator.clidGenerator.__tidRep = {} |
|
staticprivate |
The documentation for this class was generated from the following file: