Package backend :: Package common :: Module rhnFlags
[hide private]
[frames] | no frames]

Source Code for Module backend.common.rhnFlags

 1  # Copyright (c) 2008--2016 Red Hat, Inc. 
 2  # 
 3  # This software is licensed to you under the GNU General Public License, 
 4  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 5  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 6  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 7  # along with this software; if not, see 
 8  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
 9  # 
10  # Red Hat trademarks are not licensed under GPLv2. No permission is 
11  # granted to use or replicate Red Hat trademarks that are incorporated 
12  # in this software or its documentation. 
13  # 
14  # Small class that handles a global flags structure. the globale dictionary 
15  # used to hold the flags gets initialized on demand 
16  # 
17   
18  __F = {} 
19   
20   
21 -def set(name, value=1):
22 """ 23 set value 24 """ 25 # pylint: disable=W0622,W0602 26 global __F 27 if not name: 28 return None 29 name = name.lower() 30 __F[name] = value 31 return None
32 33
34 -def get(name):
35 """ 36 get value 37 """ 38 if not name: 39 return None 40 name = name.lower() 41 return __F.get(name)
42 43
44 -def test(name):
45 """ 46 test value 47 """ 48 if not name: 49 return 0 50 name = name.lower() 51 return (name in __F) and __F[name]
52 53
54 -def reset():
55 """ 56 reset all 57 """ 58 __F.clear()
59 60
61 -def all():
62 """ 63 return all flags in a dict 64 """ 65 # pylint: disable=W0622 66 return __F
67