Changeset 210 for trunk/python
- Timestamp:
- 10/22/10 18:46:49 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/pyregfi/__init__.py
r209 r210 1 1 #!/usr/bin/env python 2 3 ## @package pyregfi 4 # Python interface to the regfi library. 5 # 2 6 3 7 import sys … … 106 110 107 111 108 109 regfi.regfi_get_value110 111 112 regfi.regfi_init.argtypes = [] 112 113 regfi.regfi_init.restype = None … … 114 115 115 116 117 ## Retrieves messages produced by regfi during parsing and interpretation 118 # 116 119 def GetLogMessages(): 117 120 msgs = regfi.regfi_log_get_str() … … 142 145 143 146 return ret_val 144 145 147 148 149 ## Abstract class which Handles memory management and proxies attribute 150 # access to base structures 146 151 class _StructureWrapper(): 147 "Handles memory management and proxies attribute access to base structures" 152 148 153 hive = None 149 154 base = None … … 166 171 return (not self.__eq__(other)) 167 172 168 173 ## Registry key 169 174 class Key(_StructureWrapper): 170 175 pass … … 173 178 pass 174 179 180 ## Registry value data 175 181 class Data(_StructureWrapper): 176 182 pass 177 183 184 ## Registry security record/permissions 178 185 class Security(_StructureWrapper): 179 186 pass … … 277 284 278 285 286 ## Registry value (metadata) 287 # 288 # These represent registry values (@ref REGFI_VK records) and provide 289 # access to their associated data. 290 # 279 291 class Value(_StructureWrapper): 280 292 def __getattr__(self, name): … … 343 355 344 356 345 class Hive(): 357 ## Represents a single registry hive (file) 358 # 359 class Hive(): 346 360 file = None 347 361 raw_file = None … … 366 380 return getattr(self.file.contents, name) 367 381 368 def __del__(self): 382 def __del__(self): 369 383 regfi.regfi_free(self.file) 370 384 if self.raw_file != None: … … 375 389 return HiveIterator(self) 376 390 391 ## Creates a @ref HiveIterator initialized at the specified path in 392 # the hive. 393 # 394 # Raises an Exception if the path could not be found/traversed. 377 395 def subtree(self, path): 378 396 hi = HiveIterator(self) … … 381 399 382 400 401 ## A special purpose iterator for registry hives 402 # 403 # Iterating over an object of this type causes all keys in a specific 404 # hive subtree to be returned in a depth-first manner. These iterators 405 # are typically created using the @ref Hive.subtree() function on a @ref Hive 406 # object. 407 # 408 # HiveIterators can also be used to manually traverse up and down a 409 # registry hive as they retain information about the current position in 410 # the hive, along with which iteration state for subkeys and values for 411 # every parent key. See the @ref up and @ref down methods for more 412 # information. 383 413 class HiveIterator(): 384 414 hive = None … … 419 449 raise StopIteration('') 420 450 451 # XXX: Use non-generic exception 421 452 if not regfi.regfi_iterator_down(self.iter): 422 453 raise Exception('Error traversing iterator downward.'+ … … 439 470 apath = (c_char_p*len(path))(*cpath) 440 471 472 # XXX: Use non-generic exception 441 473 if not regfi.regfi_iterator_walk_path(self.iter,apath): 442 474 raise Exception('Could not locate path.\n'+GetLogMessages()) … … 444 476 def current_key(self): 445 477 return Key(self.hive, regfi.regfi_iterator_cur_key(self.iter)) 478 479 #XXX Add subkey/value search accessor functions (?)
Note: See TracChangeset
for help on using the changeset viewer.