Skip to content

a Python dictionary-like interface to the Windows Registry

Notifications You must be signed in to change notification settings

blaquee/infi.registry

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Python bindings to the Windows registry Usage

The first thing you do is open the registry for the local computer:

>>> from infi.registry import LocalComputer
>>> local_computer = LocalComputer()

You can browse different registry hives:

>>> local_machine = local_computer.local_machine
>>> current_usrr = local_computer.current_user

You can travel the hive in two ways:

>>> # direct
>>> key = local_machine[r'Software\Microsoft\Windows NT\\CurrentVersion']
>>> # indirect
>>> key = local_machine['Software']['Microsoft']['Windows NT']['CurrentVersion']

Accessing a non-existing key raises KeyError.

The registry values are stored in a dictionary:

>>> key.values_store.keys()[:2]
[u'CurrentVersion',
 u'CurrentBuild']

Updating a value is easy:

>>> from infi.registry import RegistryFactory
>>> factory = RegistryFactory()
>>> new_value = factory.by_value('this is a string')
>>> key.values_store['name'] = new_value

The by_value method guesses the registry value type but the type of the instance. You can define the value type on our own by using factory.by_type method.

Checking out the code

This project uses buildout and infi-projector, and git to generate setup.py and version.py. In order to generate these, first get infi-projector:

easy_install infi.projector

and then run in the project directory:

projector devenv build

About

a Python dictionary-like interface to the Windows Registry

Resources

Stars

Watchers

Forks

Packages

No packages published