Trees | Indices | Help |
---|
|
1 # 2 # Copyright (c) 2001--2016 Red Hat, Inc. 3 # 4 # This software is licensed to you under the GNU General Public License, 5 # version 2 (GPLv2). There is NO WARRANTY for this software, express or 6 # implied, including the implied warranties of MERCHANTABILITY or FITNESS 7 # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 8 # along with this software; if not, see 9 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 10 # 11 # Red Hat trademarks are not licensed under GPLv2. No permission is 12 # granted to use or replicate Red Hat trademarks that are incorporated 13 # in this software or its documentation. 14 # 15 # 16 # This file implements a case insensitive dictionary on top of the 17 # UserDict standard python class 18 # 19 20 21 try: # python2 22 from UserDict import UserDict 23 from types import StringType 24 except ImportError: # python3 25 from collections import UserDict 26 StringType = bytes 27 from functools import reduce 28 29 # A dictionary with case insensitive keys3410236 """ Return the lower() of key if it is a string. """ 37 if isinstance(key, StringType): 38 return key.lower() 39 else: 40 return key41 42 # some methods used to make the class work as a dictionary 47 51 52 get = __getitem__ 53 58 6264 return self.kcase.values()65 68 72 76 77 # return this data as a real hash79 return reduce(lambda a, t, hc=self.kcase: 80 a.update({ hc[t[0]] : t[1]}) or a, self.data.items(), {})81 82 # return the data for marshalling84 return self.get_hash()85 86 # we need a setstate because of the __getstate__ presence screws up deepcopy 89 90 # get a dictionary out of this instance ({}.update doesn't get instances)92 return self.get_hash()93 97 98 # Expose an iterator. This would normally fail if there is no iter() 99 # function defined - but __iter__ will never be called on python 1.5.2101 return iter(self.data)
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Wed Mar 4 07:37:44 2020 | http://epydoc.sourceforge.net |