CMS 3D CMS Logo

centralIDRegistry.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
4  def __init__(self):
5  self.md5toName = {}
6  self.nameToMD5 = {}
7 
8  def register(self,name,md5):
9  #register md5 -> name
10  if md5 not in self.md5toName:
11  self.md5toName[md5] = name
12  else:
13  raise Exception('md5 %s already exists with name %s!'%(md5,self.md5toName[md5]))
14  # register name -> md5
15  if name not in self.nameToMD5:
16  self.nameToMD5[name] = md5
17  else:
18  raise Exception('Name %s already exists with md5 %s!'%(name,self.nameToMD5[name]))
19 
20  def getNameFromMD5(self,md5):
21  if md5 in self.md5toName:
22  return self.md5toName[md5]
23  else:
24  return ''
25 
26  def getMD5FromName(self,name):
27  if name in self.nameToMD5:
28  return self.nameToMD5[name]
29  else:
30  return ''
31 
32 
33 central_id_registry = CentralIDRegistry()
34 
35 
36 
37