Skip to main content

A Python library for interacting with the Windows registry

Project description

WinRegistry

PyPI PyPI

A Python library for interacting with the Windows registry. This library provides a simple and intuitive API for performing common registry operations, making it easier to work with the Windows registry in Python applications and automated tests.

Installation

Install via PyPI:

pip install winregistry

Usage

Creating and Deleting Registry Keys

import winreg
from winregistry import open_key

# Create a registry key
with open_key(
  winreg.HKEY_LOCAL_MACHINE,
  sub_key="SOFTWARE\\MyApp",
  sub_key_ensure=True,
  sub_key_access=winreg.KEY_WRITE
) as key:
  print("Registry key created")

# Delete a registry key
with open_key(
  winreg.HKEY_LOCAL_MACHINE,
  sub_key="SOFTWARE",
  sub_key_access=winreg.KEY_WRITE
) as key:
  key.delete_key("MyApp")
  print("Registry key deleted")

Setting and Reading Registry Values

from winregistry import open_key, open_value

# Set a registry value
with open_key(
  "HKLM\\SOFTWARE\\MyApp",
  sub_key_ensure=True,
  sub_key_access=winreg.KEY_SET_VALUE
) as key:
  key.set_value("MyValue", "Sample Data", winreg.REG_SZ)
  print("Registry value set")

# Read a registry value
with open_value(
  "HKLM\\SOFTWARE\\MyApp",
  value_name="MyValue"
) as value:
  print(f"Registry value: {value.data}")

Enumerating Subkeys and Values

from winregistry import open_key

# Enumerate subkeys
with open_key(
  "HKLM\\SOFTWARE",
  sub_key_access=winreg.KEY_READ
) as key:
  subkeys = key.enum_subkeys()
  print(f"Subkeys: {subkeys}")

# Enumerate values
with open_key(
  "HKLM\\SOFTWARE\\MyApp",
  sub_key_access=winreg.KEY_READ
) as key:
  values = key.enum_values()
  print(f"Values: {values}")

Usage with Robot Testing Framework

The library provides a Robot Framework library that makes it easy to work with the Windows registry in automated tests. The library is available as winregistry.robot.

Documentation

For detailed documentation of the Robot Framework library, visit: https://shpaker.github.io/winregistry/winregistry.robot

Example Tests

A complete set of example tests demonstrating various registry operations can be found in the winregistry_tests.robot file. These tests cover:

  • Creating and deleting registry keys
  • Working with nested registry keys
  • Setting and reading registry values
  • Verifying registry key and value existence
  • Enumerating subkeys and values

Contributing

Contributions are welcome! Please read our contributing guidelines for more details.

Setting Up the Development Environment

We use uv for dependency management and packaging. To set up your development environment, follow these steps:

  1. Install uv if you haven't already:

    pip install uv
    
  2. Install the project dependencies:

    uv sync --verbose --no-progress --locked --all-extras
    

Code Formatting and Linting

We use ruff for code formatting and linting. The following tasks are defined in the Justfile to help with these processes:

  • Format the code:

    just fmt
    
  • Run the linter:

    just lint
    

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

winregistry-2.1.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

winregistry-2.1.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file winregistry-2.1.1.tar.gz.

File metadata

  • Download URL: winregistry-2.1.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.11

File hashes

Hashes for winregistry-2.1.1.tar.gz
Algorithm Hash digest
SHA256 8233c4261a9d937cd8f0670da0d1e61fd7b86712c39b1af08cb83e91316195a7
MD5 f2933507b5067c293f0237d60cb3a9b3
BLAKE2b-256 953f26e92c49fe41237d8f5e996c46998351eb1cc5994206537eb3402dd51f93

See more details on using hashes here.

File details

Details for the file winregistry-2.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for winregistry-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c42fac2f074b7f2898d07176c90118136b19da5f77e5b528a4699cc280c5a47b
MD5 403fe00d068a3819e30c5caf34affc71
BLAKE2b-256 f6338885812cb34f488e363feee3e24e81c922ba25de5789e9d013e34d40cc94

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page