Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:18

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 class CentralIDRegistry:
0004    def __init__(self):
0005        self.md5toName = {}
0006        self.nameToMD5 = {}
0007 
0008    def register(self,name,md5):
0009        #register md5 -> name
0010        if md5 not in self.md5toName:
0011            self.md5toName[md5] = name
0012        else:
0013            raise Exception('md5 %s already exists with name %s!'%(md5,self.md5toName[md5]))
0014        # register name -> md5
0015        if name.value() not in self.nameToMD5:
0016            self.nameToMD5[name.value()] = md5
0017        else:
0018            raise Exception('Name %s already exists with md5 %s!'%(name.value(),self.nameToMD5[name.value()]))
0019 
0020    def getNameFromMD5(self,md5):
0021        if md5 in self.md5toName:
0022            return self.md5toName[md5]
0023        else:
0024            return ''
0025 
0026    def getMD5FromName(self,name):
0027        if name.value() in self.nameToMD5:
0028            return self.nameToMD5[name.value()]
0029        else:
0030            return ''
0031 
0032 
0033 central_id_registry = CentralIDRegistry()
0034 
0035    
0036            
0037