MCPcopy Create free account
hub / github.com/ActiveState/code / Key

Class Key

recipes/Python/498148_Proposal_standard_winreg/recipe-498148.py:139–267  ·  view source on GitHub ↗

Key(**kwargs) -> Key Key(key=int) -> Key Key(key=PyHKEY) -> Key Key(key=Key) -> Key Key(key=int, sub_key=str) -> Key Key(key=PyHKEY, sub_key=str) -> Key Key(key=Key, sub_key=str) -> Key Key(key=int, sam=int) -> Key Key(key=PyHKEY, sam=int) -> Key Key(key=Key, sam

Source from the content-addressed store, hash-verified

137 HKEY_CURRENT_CONFIG = property(__HKEY_CURRENT_CONFIG, doc='The CURRENT_CONFIG hive.')
138
139class Key(object):
140
141 '''Key(**kwargs) -> Key
142
143 Key(key=int) -> Key
144 Key(key=PyHKEY) -> Key
145 Key(key=Key) -> Key
146 Key(key=int, sub_key=str) -> Key
147 Key(key=PyHKEY, sub_key=str) -> Key
148 Key(key=Key, sub_key=str) -> Key
149 Key(key=int, sam=int) -> Key
150 Key(key=PyHKEY, sam=int) -> Key
151 Key(key=Key, sam=int) -> Key
152 Key(key=int, sub_key=str, sam=int) -> Key
153 Key(key=PyHKEY, sub_key=str, sam=int) -> Key
154 Key(key=Key, sub_key=str, sam=int) -> Key
155 Key(key=int, computer_name=str) -> Key
156 Key(key=int, sub_key=str, computer_name=str) -> Key
157 Key(key=int, sam=int, computer_name=str) -> Key
158 Key(key=int, sub_key=str, sam=int, computer_name=str) -> Key'''
159
160 def __init__(self, **kwargs):
161 'Initialize the Key object.'
162 assert kwargs, 'No Keyword Arguments Were Found'
163 self.__repr, key, sub_key, sam, computer_name = '%s(%s)' % (self.__class__.__name__, ', '.join(['%s=%r' % (key, kwargs[key]) for key in kwargs])), kwargs.pop('key', None), kwargs.pop('sub_key', None), kwargs.pop('sam', None), kwargs.pop('computer_name', None)
164 assert not kwargs, 'Invalid Keyword Arguments Were Found'
165 if isinstance(key, (int, _winreg.HKEYType)) and sub_key is None and sam is None and computer_name is None:
166 self.__self = _winreg.OpenKey(key, '')
167 elif isinstance(key, Key) and sub_key is None and sam is None and computer_name is None:
168 self.__self = _winreg.OpenKey(key.__self, '')
169 elif isinstance(key, (int, _winreg.HKEYType)) and isinstance(sub_key, str) and sam is None and computer_name is None:
170 self.__self = _winreg.OpenKey(key, sub_key)
171 elif isinstance(key, Key) and isinstance(sub_key, str) and sam is None and computer_name is None:
172 self.__self = _winreg.OpenKey(key.__self, sub_key)
173 elif isinstance(key, (int, _winreg.HKEYType)) and sub_key is None and isinstance(sam, int) and computer_name is None:
174 self.__self = _winreg.OpenKey(key, '', 0, sam)
175 elif isinstance(key, Key) and sub_key is None and isinstance(sam, int) and computer_name is None:
176 self.__self = _winreg.OpenKey(key.__self, '', 0, sam)
177 elif isinstance(key, (int, _winreg.HKEYType)) and isinstance(sub_key, str) and isinstance(sam, int) and computer_name is None:
178 self.__self = _winreg.OpenKey(key, sub_key, 0, sam)
179 elif isinstance(key, Key) and isinstance(sub_key, str) and isinstance(sam, int) and computer_name is None:
180 self.__self = _winreg.OpenKey(key.__self, sub_key, 0, sam)
181 elif isinstance(key, int) and sub_key is None and sam is None and isinstance(computer_name, str):
182 self.__self = _winreg.ConnectRegistry(computer_name, key)
183 elif isinstance(key, int) and isinstance(sub_key, str) and sam is None and isinstance(computer_name, str):
184 self.__self = _winreg.OpenKey(_winreg.ConnectRegistry(computer_name, key), sub_key)
185 elif isinstance(key, int) and sub_key is None and isinstance(sam, int) and isinstance(computer_name, str):
186 self.__self = _winreg.OpenKey(_winreg.ConnectRegistry(computer_name, key), '', 0, sam)
187 elif isinstance(key, int) and isinstance(sub_key, str) and isinstance(sam, int) and isinstance(computer_name, str):
188 self.__self = _winreg.OpenKey(_winreg.ConnectRegistry(computer_name, key), sub_key, 0, sam)
189 else:
190 raise TypeError, 'Key Could Not Be Initialized'
191
192 def __repr__(self):
193 'Return the object\'s representation.'
194 return self.__repr
195
196 def save(self, file_name):

Callers 4

__hiveMethod · 0.70
__getitem__Method · 0.70
do_exitFunction · 0.50
do_configFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected