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.value() not in self.nameToMD5:
16  self.nameToMD5[name.value()] = md5
17  else:
18  raise Exception('Name %s already exists with md5 %s!'%(name.value(),self.nameToMD5[name.value()]))
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.value() in self.nameToMD5:
28  return self.nameToMD5[name.value()]
29  else:
30  return ''
31 
32 
33 central_id_registry = CentralIDRegistry()
34 
35 
36 
37 
centralIDRegistry.CentralIDRegistry.getNameFromMD5
def getNameFromMD5(self, md5)
Definition: centralIDRegistry.py:20
centralIDRegistry.CentralIDRegistry.getMD5FromName
def getMD5FromName(self, name)
Definition: centralIDRegistry.py:26
Exception
centralIDRegistry.CentralIDRegistry.__init__
def __init__(self)
Definition: centralIDRegistry.py:4
centralIDRegistry.CentralIDRegistry
Definition: centralIDRegistry.py:3
centralIDRegistry.CentralIDRegistry.nameToMD5
nameToMD5
Definition: centralIDRegistry.py:6
centralIDRegistry.CentralIDRegistry.register
def register(self, name, md5)
Definition: centralIDRegistry.py:8
centralIDRegistry.CentralIDRegistry.md5toName
md5toName
Definition: centralIDRegistry.py:5