winregkit 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,52 @@
1
+ # Copilot Instructions for winregkit
2
+
3
+ ## Project context
4
+ - `winregkit` is a small Python library around Windows Registry operations.
5
+ - Main implementation lives in `src/winregkit/`.
6
+ - Tests rely heavily on `tests/fakewinreg.py` to validate behavior on non-Windows and to compare against real `winreg` when available.
7
+
8
+ ## Tech and tooling
9
+ - Python version target: **3.11+**.
10
+ - Packaging/build: `hatchling` (`pyproject.toml`).
11
+ - Environment/dependency workflow uses **uv**.
12
+ - Version management should use `uv version` (e.g. `uv version --bump patch`, `uv version 0.0.1rc1`) instead of manually editing `pyproject.toml`.
13
+ - Type checking uses **mypy strict mode** on `src/winregkit`.
14
+ - Linting/import order uses **ruff** with import sorting (`I`).
15
+
16
+ ## Code style and implementation rules
17
+ - Keep changes minimal and focused; do not refactor unrelated code.
18
+ - Preserve existing API shape and naming unless explicitly asked.
19
+ - Prefer explicit type annotations that satisfy strict mypy.
20
+ - Follow existing patterns:
21
+ - `Key` methods raise `KeyError` for missing values/keys where the library API currently does so.
22
+ - Low-level backend exceptions (`FileNotFoundError`, `OSError`, `PermissionError`) are translated only where the current code already translates them.
23
+ - Keep compatibility with both real `winreg` and `tests.fakewinreg` behavior.
24
+ - Avoid platform-specific assumptions that would break tests on non-Windows.
25
+
26
+ ## Testing expectations
27
+ - Run targeted tests first for touched behavior, then broader tests.
28
+ - Typical commands:
29
+ - `uv sync --dev`
30
+ - `pytest`
31
+ - If type-significant code is changed, also run:
32
+ - `uv run mypy src/winregkit`
33
+
34
+ ## File-specific guidance
35
+ - `src/winregkit/registry.py` is the core behavior surface; changes here should preserve context-manager and handle lifecycle semantics (`open`, `close`, `opened`, `create`, `delete`).
36
+ - `tests/fakewinreg.py` is a behavioral compatibility shim. If production behavior changes, update tests and shim only when required by the requested change.
37
+ - CLI (`src/winregkit/cli.py`) is intentionally minimal currently; do not expand it unless requested.
38
+
39
+ ## When adding or changing code
40
+ - Add/adjust tests in `tests/` for any behavior change.
41
+ - Keep imports sorted and remove unused imports.
42
+ - Keep docstrings concise and consistent with existing style.
43
+ - Prefer straightforward implementations over abstractions.
44
+ - Update `CHANGELOG.md` for release-worthy changes (including `rc`/pre-release tags).
45
+ - Keep changelog entries concise and user-facing; avoid listing individual development bug-fix details.
46
+
47
+ ## Things to double-check before finishing
48
+ - No accidental public API breaks in `winregkit.__init__` exports.
49
+ - Tests pass locally.
50
+ - New code passes strict typing.
51
+ - Run `uvx ruff check` and `uvx ruff format --check` before pushing.
52
+ - No unrelated formatting-only churn.
@@ -0,0 +1,53 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ - main
8
+ tags:
9
+ - "v*"
10
+ pull_request:
11
+
12
+ jobs:
13
+ test:
14
+ name: ${{ matrix.os }} / py${{ matrix.python-version }}
15
+ runs-on: ${{ matrix.os }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ os: [ubuntu-latest, windows-latest]
20
+ python-version: ["3.11", "3.12", "3.13", "3.14"]
21
+ exclude:
22
+ - os: windows-latest
23
+ python-version: "3.11"
24
+ - os: windows-latest
25
+ python-version: "3.12"
26
+ - os: windows-latest
27
+ python-version: "3.13"
28
+
29
+ steps:
30
+ - name: Checkout
31
+ uses: actions/checkout@v4
32
+
33
+ - name: Install uv
34
+ uses: astral-sh/setup-uv@v7
35
+ with:
36
+ python-version: ${{ matrix.python-version }}
37
+ enable-cache: true
38
+
39
+ - name: Lint (ruff)
40
+ run: uvx ruff check
41
+
42
+ - name: Format check (ruff)
43
+ run: uvx ruff format --check
44
+
45
+ - name: Sync dependencies
46
+ run: uv sync --locked --dev
47
+
48
+ - name: Run tests
49
+ run: uv run pytest
50
+
51
+ - name: Type check (mypy)
52
+ if: runner.os == 'Windows'
53
+ run: uv run mypy src/winregkit
@@ -0,0 +1,84 @@
1
+ name: Publish
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows:
6
+ - CI
7
+ types:
8
+ - completed
9
+
10
+ jobs:
11
+ detect-tag:
12
+ if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
13
+ runs-on: ubuntu-latest
14
+ outputs:
15
+ publish_tag: ${{ steps.tag.outputs.publish_tag }}
16
+ commit_sha: ${{ steps.sha.outputs.commit_sha }}
17
+
18
+ steps:
19
+ - name: Checkout
20
+ uses: actions/checkout@v4
21
+ with:
22
+ fetch-depth: 0
23
+
24
+ - name: Capture CI commit SHA
25
+ id: sha
26
+ run: echo "commit_sha=${{ github.event.workflow_run.head_sha }}" >> "$GITHUB_OUTPUT"
27
+
28
+ - name: Detect version tag at CI commit
29
+ id: tag
30
+ run: |
31
+ git fetch --tags --force
32
+ TAG=$(git tag --points-at "${{ github.event.workflow_run.head_sha }}" | grep '^v' | head -n 1 || true)
33
+ echo "publish_tag=$TAG" >> "$GITHUB_OUTPUT"
34
+
35
+ publish:
36
+ needs: detect-tag
37
+ if: needs.detect-tag.outputs.publish_tag != ''
38
+ runs-on: ubuntu-latest
39
+ permissions:
40
+ id-token: write
41
+ contents: write
42
+
43
+ environment:
44
+ name: pypi
45
+
46
+ steps:
47
+ - name: Checkout
48
+ uses: actions/checkout@v4
49
+ with:
50
+ ref: ${{ needs.detect-tag.outputs.commit_sha }}
51
+
52
+ - name: Install uv
53
+ uses: astral-sh/setup-uv@v7
54
+ with:
55
+ python-version: "3.12"
56
+ enable-cache: true
57
+
58
+ - name: Build distributions
59
+ run: uv build
60
+
61
+ - name: Verify built artifacts
62
+ run: ls -la dist
63
+
64
+ - name: Publish to PyPI
65
+ run: uv publish
66
+
67
+ - name: Create GitHub Release
68
+ env:
69
+ GH_TOKEN: ${{ github.token }}
70
+ TAG: ${{ needs.detect-tag.outputs.publish_tag }}
71
+ run: |
72
+ gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1 && exit 0
73
+
74
+ PRERELEASE_FLAG=""
75
+ case "$TAG" in
76
+ *a*|*b*|*rc*|*dev*) PRERELEASE_FLAG="--prerelease" ;;
77
+ esac
78
+
79
+ gh release create "$TAG" dist/* \
80
+ --repo "$GITHUB_REPOSITORY" \
81
+ --verify-tag \
82
+ --title "$TAG" \
83
+ --notes "See CHANGELOG.md for release details." \
84
+ $PRERELEASE_FLAG
@@ -0,0 +1,65 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *.pyd
6
+ *.pyc
7
+
8
+ # Distribution / packaging
9
+ .Python
10
+ build/
11
+ dist/
12
+ *.egg-info/
13
+ .eggs/
14
+ *.egg
15
+
16
+ # Installer logs
17
+ pip-log.txt
18
+ pip-delete-this-directory.txt
19
+
20
+ # Unit test / coverage reports
21
+ htmlcov/
22
+ .tox/
23
+ .nox/
24
+ .coverage
25
+ .coverage.*
26
+ .cache
27
+ nosetests.xml
28
+ coverage.xml
29
+ *.cover
30
+ *.py,cover
31
+ .hypothesis/
32
+ .pytest_cache/
33
+
34
+ # Jupyter Notebook
35
+ .ipynb_checkpoints
36
+
37
+ # VS Code
38
+ .vscode/
39
+
40
+ # Environments
41
+ .env
42
+ .venv
43
+ env/
44
+ venv/
45
+ ENV/
46
+
47
+ # mypy
48
+ .mypy_cache/
49
+ .dmypy.json
50
+
51
+ # Ruff
52
+ .ruff_cache/
53
+
54
+ # Other
55
+ *.log
56
+ *.pot
57
+ *.mo
58
+ *.swp
59
+ *.swo
60
+
61
+ # Mac
62
+ .DS_Store
63
+
64
+ # Windows
65
+ Thumbs.db
@@ -0,0 +1 @@
1
+ 3.14
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## Unreleased
6
+
7
+ No tracked entries yet.
8
+
9
+ ## 0.1.0 - 2026-02-21
10
+
11
+ First stable 0.1 release.
12
+
13
+ - Finalizes the 0.1 API surface for key traversal, typed value operations, and path-based key construction.
14
+ - Strengthens test coverage across fake and real backends, with backend-selective test flags for CI and local runs.
15
+ - Enforces formatting checks in CI alongside linting, tests, and Windows mypy checks.
16
+
17
+ ## 0.1.0rc2 - 2026-02-21
18
+
19
+ Second release candidate for the 0.1 line.
20
+
21
+ - Publish workflow now creates a basic GitHub Release alongside PyPI publication.
22
+ - Release automation now avoids duplicate publish attempts from branch-triggered CI runs.
23
+
24
+ ## 0.1.0rc1 - 2026-02-21
25
+
26
+ Initial release candidate for the 0.1 line.
27
+
28
+ - API surface refined for clearer typed value access and iteration naming.
29
+ - Cross-platform test strategy stabilized for real Windows `winreg` and fake backend coverage.
30
+ - CI and publish workflows aligned around `uv` tooling with release-tag-driven publishing.
31
+ - Project release/version workflow standardized on `uv version`.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kristján Valur Jónsson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.4
2
+ Name: winregkit
3
+ Version: 0.1.0
4
+ Summary: A modern, pythonic interface to the Windows registry.
5
+ License-File: LICENSE
6
+ Classifier: Operating System :: Microsoft :: Windows
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Requires-Python: >=3.11
13
+ Provides-Extra: dev
14
+ Requires-Dist: mypy; extra == 'dev'
15
+ Requires-Dist: pytest>=8.0; extra == 'dev'
@@ -0,0 +1,100 @@
1
+ # winregkit
2
+
3
+ A modern, pythonic interface to the Windows registry.
4
+
5
+ ## Introduction
6
+
7
+ Python comes with `winreg` for registry operations, but it is a thin wrapper over
8
+ Win32 APIs and can be cumbersome for day-to-day usage.
9
+
10
+ `winregkit` provides a higher-level, object-oriented interface with simple tree
11
+ navigation, dict-like value access, and context-manager support.
12
+
13
+ ## Features
14
+ - Easy-to-use API for reading and writing Windows Registry keys
15
+ - Python 3.11+
16
+ - Windows platform
17
+ - MIT License
18
+ - Managed and built with [uv](https://github.com/astral-sh/uv)
19
+
20
+
21
+ ## Installation
22
+
23
+ ```sh
24
+ pip install winregkit
25
+ ```
26
+
27
+ Or the equivalent command in your preferred package manager.
28
+
29
+ ## Usage
30
+
31
+ ### Library
32
+ ```python
33
+ from winregkit import current_user
34
+ import winreg
35
+
36
+
37
+ # open for read
38
+ with current_user.subkey("Software", "MyApp").open() as key:
39
+ print(key["name"])
40
+ print(key.get("missing", "default"))
41
+
42
+ # open for write (subkeys can be passed directly to open as a convenience)
43
+ with current_user.open("Software", "MyApp", write=True) as key:
44
+ key["name"] = "winregkit"
45
+ key["enabled"] = 1
46
+
47
+ # create/open for write (create is shorthand for open(create=True, write=True))
48
+ with current_user.create("Software", "MyApp") as key:
49
+ key["name"] = "winregkit"
50
+ key["enabled"] = 1
51
+
52
+ # the Key object provides dict access and values can be iterated over:
53
+ with current_user.open("Software", "MyApp") as key:
54
+ for name, value in key.items():
55
+ print(name, value)
56
+
57
+ # the underlying type of a value can be retrieved, and a custom type can be
58
+ # set, overriding default conversions:
59
+ with current_user.open("Software", "MyApp", write=True) as key:
60
+ value, value_type = key.get_typed("enabled")
61
+ print(value, value_type)
62
+
63
+ key.set_typed("payload", b"\x00\x01\x02", winreg.REG_BINARY)
64
+
65
+ # existence checks are available on keys:
66
+ app_key = current_user.subkey("Software", "MyApp")
67
+ print(app_key.exists())
68
+
69
+ ```
70
+
71
+ `subkey(...)` is optional convenience for pre-building a path. You can either
72
+ chain with `subkey(...)` first, or pass subkeys directly to `open(...)` / `create(...)`.
73
+
74
+ ### Preferred API style
75
+ - Use root factories (`current_user`, `local_machine`, etc.)
76
+ - Navigate with `subkey(...)` (optional)
77
+ - Open with `open(...)` or `create(...)` and a context manager
78
+ - Use dict-style value access (`key[name]`, `key[name] = value`)
79
+ - Use `get_typed` / `set_typed` only when explicit registry types are needed
80
+
81
+ ## Development
82
+
83
+ This project uses the [uv](https://docs.astral.sh/uv/) package manager.
84
+
85
+ - Install uv, e.g. using `pip install uv`
86
+
87
+ - Install dev dependencies:
88
+ ```sh
89
+ uv sync --dev
90
+ ```
91
+ - Run tests:
92
+ ```sh
93
+ uv run pytest
94
+ ```
95
+
96
+ ## License
97
+ MIT License. See `LICENSE` for details.
98
+
99
+ ## Changelog
100
+ See `CHANGELOG.md` for release history and policy.
@@ -0,0 +1,37 @@
1
+ [project]
2
+ name = "winregkit"
3
+ version = "0.1.0"
4
+ description = "A modern, pythonic interface to the Windows registry."
5
+ requires-python = ">=3.11"
6
+ classifiers = [
7
+ "Programming Language :: Python :: 3",
8
+ "Programming Language :: Python :: 3.11",
9
+ "Programming Language :: Python :: 3.12",
10
+ "Programming Language :: Python :: 3.13",
11
+ "Programming Language :: Python :: 3.14",
12
+ "Operating System :: Microsoft :: Windows",
13
+ ]
14
+ [license]
15
+ text = "MIT"
16
+
17
+ [project.optional-dependencies]
18
+ dev = ["pytest>=8.0", "mypy"]
19
+
20
+ [dependency-groups]
21
+ dev = ["pytest>=8.0", "mypy"]
22
+
23
+ [tool.mypy]
24
+ python_version = "3.11"
25
+ strict = true
26
+ files = ["src/winregkit"]
27
+
28
+ [build-system]
29
+ requires = ["hatchling"]
30
+ build-backend = "hatchling.build"
31
+
32
+ [tool.ruff]
33
+ line-length = 120
34
+ target-version = "py311"
35
+ src = ["src", "tests"]
36
+ lint.extend-select = ["I"] # Ensure import order is checked
37
+
@@ -0,0 +1,3 @@
1
+ from .registry import Key, classes_root, current_config, current_user, local_machine, users
2
+
3
+ __all__ = ["Key", "classes_root", "current_user", "local_machine", "users", "current_config"]