Skip to content

Commit

Permalink
feat: documentation generated with co-pilot (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
shpaker authored Jan 1, 2025
1 parent 10074ea commit c8e40b4
Show file tree
Hide file tree
Showing 3 changed files with 539 additions and 37 deletions.
119 changes: 97 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
[![PyPI](https://img.shields.io/pypi/v/winregistry.svg)](https://pypi.python.org/pypi/winregistry)
[![PyPI](https://img.shields.io/pypi/dm/winregistry.svg)](https://pypi.python.org/pypi/winregistry)

Python package aimed at working with Windows Registry
A Python library for interacting with the Windows registry

## Features

- Easy to use API for Windows registry operations
- Supports creating, reading, updating, and deleting registry keys and values
- Compatible with Robot Framework for automated testing

## Installation

Expand All @@ -15,44 +21,73 @@ pip install winregistry

## Usage

### Creating and Deleting Registry Keys

```python
import winreg
from winregistry import open_key, open_value
from winregistry import open_key

# connect to registry and ensure sub-key
# Create a registry key
with open_key(
winreg.HKEY_LOCAL_MACHINE,
sub_key="SOFTWARE\_REMOVE_ME_",
) as key:
...

# also you can connect to registry with string key
with open_key(
"HKLM\SOFTWARE\_REMOVE_ME_",
sub_key="SOFTWARE\\MyApp",
sub_key_ensure=True,
sub_key_access=winreg.KEY_WRITE
) as key:
...
print("Registry key created")

# delete key
# 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("_REMOVE_ME_")
key.delete_key("MyApp")
print("Registry key deleted")
```

# create value
### Setting and Reading Registry Values

```python
from winregistry import open_key, open_value

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

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

### Enumerating Subkeys and Values

```python
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](https://robotframework.org/)
Expand Down Expand Up @@ -107,3 +142,43 @@ TEST REGISTRY VALUES
Should Be Equal ${ value.data } Remove me!
Delete Registry Value ${ CASE_KEY_NAME } ${ VALUE_NAME }
```

## Contributing

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

### Setting Up the Development Environment

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

1. Install `poetry` if you haven't already:

```bash
pip install poetry
```

2. Install the project dependencies:

```bash
poetry install --sync
```

### 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:**

```bash
just fmt
```

- **Run the linter:**

```bash
just lint
```

## License

This project is licensed under the MIT License.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "winregistry"
version = "0.0.0"
description = "Library aimed at working with Windows registry"
description = "A Python library for interacting with the Windows registry"
authors = ["Aleksandr Shpak <[email protected]>"]
readme = "README.md"
repository = "https://github.com/shpaker/winregistry"
Expand Down
Loading

0 comments on commit c8e40b4

Please sign in to comment.