Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:53

0001 class Options(dict):
0002 
0003     def __init__(self, *args, **kw):
0004         dict.__init__(self, *args, **kw)
0005         self.readKeys = set()
0006 
0007     def __getitem__(self, key):
0008         self.readKeys.add(key)
0009         return self.get(key,None)
0010 
0011     def _unreadKeys(self):
0012         """return unused keys"""
0013         return set([a for a in self if a not in self.readKeys])
0014     unreadKeys = property(_unreadKeys)
0015 
0016 
0017 ##########################
0018 if __name__ == "__main__":
0019     import unittest
0020     class TestOptions(unittest.TestCase):
0021         def testOptions(self):
0022             a = Options()
0023             a["A"] = 3
0024             a["B"] = 3
0025             a["A"]
0026             self.assertEqual(a.readKeys, set(["A"]))
0027             self.assertEqual(a.unreadKeys, set(["B"]))                        
0028 
0029     unittest.main()