PageRenderTime 49ms CodeModel.GetById 35ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/GUI/Generic/Enumerations.py

https://bitbucket.org/alsh/pygui-mirror
Python | 16 lines | 10 code | 3 blank | 3 comment | 3 complexity | 7453ef07b596f36fd9cc373f266368ab MD5 | raw file
 1#
 2#   PyGUI - Enumerated type facilities
 3#
 4
 5class EnumMap(dict):
 6
 7    def __init__(self, __name__, *args, **kwds):
 8        self.name = __name__
 9        dict.__init__(self, *args, **kwds)
10    
11    def __getitem__(self, key):
12        try:
13            return dict.__getitem__(self, key)
14        except KeyError:
15            raise ValueError("Invalid %s '%s', should be one of %s" %
16                (self.name, key, ", ".join(["'%s'" % val for val in self.keys()])))