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

Class Root

recipes/Python/502268_Win_Registry_module/recipe-502268.py:140–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138 return '/%s/' % self.name
139
140class Root(Key):
141 # Registry Root
142 def __init__(self):
143 self.hkey={}
144 for key in (k for k in dir(reg) if k.startswith('HKEY_')):
145 try:
146 chk = reg.ConnectRegistry(None, getattr(reg, key))
147 inf = reg.QueryInfoKey(chk)
148 reg.CloseKey(chk)
149 except WindowsError: pass # some keys may appear in _winreg but can't be reached
150 else:
151 hk = Hkey(key)
152 try:
153 chk=hk.keys
154 except WindowsError: pass # some keys can be accessed but not enumerated
155 else: # some keys work fine ...
156 name=key[5:].lower()
157 self.hkey[name]=hk # for iterating
158 setattr(self, name, hk) # for easy access
159 @property
160 def keys(self):
161 return self.hkey
162
163root=Root() # we should need only one Root per application, so let's instanciate it here.
164

Callers 1

recipe-502268.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected